GH排序计算器解读

我们来自江河梦小组(Scond Effect Group),工程用到gh,所以必须学习好GH插件,而大部分权威资料都来自国外,所以就组织组员翻译来自GH官方论坛的帖子,以便学习。下面是一篇David的帖子讲解Sort计算器的原理,由黄思颖同学翻译。

Sorting using Keys & Values(aka Synchronous Sorting)

用主键和值排序(即同步排序)

·      Posted byDavid Rutten on June 20, 2012at 2:47am inFAQ (FrequentQuestions and Problems)

Sorting data is acommon task in programming. Unfortunately only numbers and

数据排序在编程中是个经常性工作。不幸的是只有数字和字符串有规范,

text have awell-defined sorting behaviour, and even text can be pretty ambiguous

甚至文本也模棱两可,取决于所用的语言以及地方文化的系统设置。

depending on thelanguage it is in and the local culture setting of the system.

Other types of data-say colours- do not have an obviously correct way to sort

其他类型的数据-比如颜色-表现形式没有一个明确的方法来区分。

them. Shouldcolours be sorted by brightness, or amount of red, or hue, or

颜色应该用亮度、红色总数、色度,或者色彩饱和度来分类吗?

saturation? All ofthese could be correct depending on the problem at hand and

取决于当前的问题所有这些都可以是正确的,因此它们没有一个明确分类规则

therefore none ofthem can be designated as thesensible default. The same is

true for3-dimensional entities such as points or meshes. When you sort a

同样三维的实体比如点或网格也是这样的。

collection ofmeshes there's an almost infinite amount of metrics you could apply;

当你把一系列网进行分类的时候,有接近于无穷多个度量你可以应用(你可以用很多度量去作为键值排序);

volume, area,vertex-count,elevation, distance to some arbitrary point, ratio of

体积、面积、顶点数、正面图、距任一点的距离、高宽比例等。

width vs. heightetc. etc. etc.

When you need tosort data using some arbitrary rule, you have to use the

当你需要以任意规则排序时,你必须使用GH里同步的分类特征(这个分类

synchronous sortingfeature in Grasshopper (this type of sorting is usually called

类型在编程中通常被称为“主键-值”排序)。

'Key-Value' sortinginprogramming). The basic idea is that you sort your

基本概念是使用可排序代理品(使用一个可以以排序的变量的集合)来排序本不可排序的数据。

unsortable datausing a collection of sortableproxies. Let's say you want to sort a

比如你想从短到长排序一系列曲线。

collection ofcurves from shortest to longest. The first thing you need to do is

compute the lengthof each curve, so that you have a collection of numbers (which

首先你需要计算每条曲线的长度,得到一系列可排序数据,

are sortable). Thenyou can sort the lengthswhile synchronously sorting the

然后你就可以排序长度的同时对曲线进行排序。

curves. The change inorder that is applied to the collection of numbers is also

按顺序排列的改变不仅仅对于一系列数字,同样对于一系列的曲线也是适用的,(数字集合在次序上的改变同样可以用于曲线集合)

applied to thecollection of curves, thus putting them in a shortest-longest sorting

这样将它们置于从最短到最长的序列之中。

order.

You can zoom in onthe Sorting component to add any number of additional

你可以在排序数组中导入或导出任何数字,所有的数据将与从K导入同样的方式进行排序。

(你可以对排序计算器进行缩放(缩放视口的时候会出现+-号)去添加任意数量的同步参数,所有的输入列表将会按照K输入端的排序方式进行排序)

synchronous inputs/outputs,all of them will be re-ordered in the same way as the

K input.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Tags: Key,Key-Value,Sort,Sorting,Synchronous,Value

ShareTwitterFacebookFacebook

Views: 1580

窗体顶端

Reply to This

 

{#aria.rich_text_area}

 

{#advanced.toolbar}

Link

Image

Media

Paste as Plain Text

Bold

Italic

Strikethrough

Underline

Left

Center

Right

Blockquote

Unordered list

Ordered list

HTML Editor

 

Upload Files

Attach files (limit: 5MB)

§ 

§ 

§ 

Follow – Email me whenpeople reply

窗体底端

Replies to ThisDiscussion

Permalink Reply by djordje on June 25, 2012at 8:25am

Thank you for the explanation David.

Can I dare to ask one more thing:

Basically, the way this Sort component works, is that it"remembers" (bad

基本来讲,这个排序的工作方式是它“记忆”K输入列表的索引以及A输入的排序成分。

word maybe) the indexes of the list thatgoes into Kinput of the Sort

component, and A input of the sort component.

If K input are always numbers, that means that in A, I can input, what everI

如果K输入总是数字,那意味着在A中我可以任我所想输入圆、多段线、曲线、数字、字母、文本。

want - circles, polylines, curves, numbers, letters, text, whatever.

The way Sort component will work, is that, it will sort the K outputnumbers

排序数组的方法是它将递增或递减来排序K输出数字,“记忆”每个已排序数字的索引。

by decreasing or increasing, and it will "remember" the indexesof each of

these sorted numbers. Then it will use this indexes, to sort the A input.

之后它将使用这些索引来排序A输入。

The same goes for: B, C, D, E ...outputs

对于BCDE输出也是一样。

Am I wrong?

And K input alwaysneeds to be a list of numbers?

K输入必须是一列数字吗?

§   

窗体顶端

Reply

Upload Files

Attach files (limit: 5MB)

    •  
    •  
    •  

窗体底端

§   

Permalink Reply by David Rutten on June 25, 2012at 8:41am

You're basically correct. The .NET framework array base type allows for

你基本上是对的。.NET框架阵列的基本类型同时提供两个阵列给主键-值排序。

key-value sorting of two arrays simultaneously. I do not know how it is

我不知道它内部是如何运行的。

implemented internally.

Yes, the A, B, C etc. fields can be any data. That is of course the whole

是的,A,B,C等区域可以是任意数据。那也当然是主键-值排序的所有要点。

point of key-value sorting. And yes, at the moment only numbers are

当然,目前仅仅允许数字。

allowed. The Sets.Strings panel also has a SortStrings component which

Set-Strings(新版gh中为Set-Text)面板下有一个字符串排序的计算器,这个计算器只允许一个集合同步排序。

allows fora single valuecollection to be added. I'll probably make it so that

在未来的版本中我将努力做到让用户可以添加更多的输入端来同步排序。

in future releases you can add more inputs for synchronous sorting.

Note that sorting strings is not as crisply defined as sorting numbers.There

 需要注意的是排序字符串并不如排序数字那样定义清晰。

are all kinds of cultural dimensions to it that might affect the sort orderof a

各种各样的文化规模影响特殊条件系列的排序顺序。

specific collection ofstrings.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

§   

窗体顶端

Reply

Upload Files

Attach files (limit: 5MB)

    •  
    •  
    •  

窗体底端

§  Message

Permalink Reply by djordje on June 25, 2012at 9:04am

Thank you for the reply David.

I did not just understand you about one thing: "Note that sorting stringsis

我不明白你关于“需要注意的是排序字符串并不如排序数字那样定义清晰。”的说法。

not as crisply defined as sorting numbers."

Is this what you meant:

If I understood itcorrectly, I need to input the data in form of strings separately in order tocreate list out of it.

如果我的理解是对的,我需要输入一系列分开的字符串来获取输出列表。

§   

窗体顶端

Reply

Upload Files

Attach files (limit: 5MB)

    •  
    •  
    •  

窗体底端

§   

Permalink Reply by Philipp on June 25, 2012at 9:11am

Just untag "multylinestring" tag inside panel editor (at the bottom)

§   

窗体顶端

Reply

Upload Files

Attach files (limit: 5MB)

    •  
    •  
    •  

窗体底端

§   

Permalink Reply by David Rutten on June 25, 2012at 9:20am

Nope, I means that different languages (called 'cultures' or 'locales' in

不,我的意思是不同的语言对待文本也不同。

programming) treat text differently. See this post:http://msdn.microsoft.com/en-us/library/a7zyyk0c.aspx

--

David Rutten

david@mcneelcom

Poprad, Slovakia

§   

窗体顶端

Reply

Upload Files

Attach files (limit: 5MB)

    •  
    •  
    •  

窗体底端

§  Message

Permalink Reply by Danny Boyes on June 25, 2012at 10:50am

There is a separateSort Strings component on the Sets Tab > String Panel.

§   

窗体顶端

Reply

Upload Files

Attach files (limit: 5MB)

    •  
    •  
    •  

窗体底端

§   

Permalink Reply by djordje on June 25, 2012at 5:59pm

Danny what is the difference between thesecomponents?Sort List and

这些成分的不同之处在哪?列表与字符串呢?

Sort Strings?

Every string can be converted to list, by simply disabling the"Multiline

每个字符串都能转变成列表,只要去掉有字符串嵌板的“多层数据”选项。

Data" option for the panel which has string in it. Or with solutionsyou

presented here.

In that case, only difference I noticed between the Sort List and Sort

Strings is the that Sort Strings can also sortletters(example B), while Sort

那样的话,我提到的序列与字符串的不同之处仅仅在于字符串可以包含字母,而序列只能是数字。

List can only sort numbers (example A).

Btw, the beginning panels on the left in all four definitions are strings,I just

disabled the "Multiline Data" in all of them:

Is this the only difference?
Thank you.

Again, I am not trying to act like smart, contradict or confront your opinion.I

再次申明,我不是试图表现得比你们的观点更聪明,相违背或者说超前。我

am a newbie in the field of Grasshopper, and I am just tryingto ask,

GH领域还只是一名新手,只是在求解我有所困惑的地方。

whatever I am confused with.

English is my second language, so if sometimes my questions sound like

"hey, you are not right, I know better than you", then that isprobably a

result of my lame(蹩脚的英语知识)knowledge ofEnglish, surely not intention.


@
David Rutten : Thank you.
@
Philipp : It worked. Thankyou.

§   

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值