Closest Pair



Author:

Categories: Lectures

Tagged with: | | | |


Shortest Distance Between Two Points

The goal of this exercise is to find two closest points in a point cloud, learn C# basics  and to compare efficiency of code with classic GH definition.


1. Basic Loop

Indexing points using GH component Series, later C# loop.

loop-series_fc

Download: basic_loop

2. Closest Point

closest_point

  1. Loop training
  2. Conditional Statements
Download: loop_&_conditions
2.1. Connections
  1. List (value) declaration
  2. List methods (Add value to list of values)
  3. Return connections as list of lines
Download: connections ; avoiding_yourself
2.2. Shortest Distance
  1. Declaration min distance (double value)
  2. Find distance between two points (method)
  3. ..is it smaller then actual (if condition)
  4. Create/Return shortest line
Download: closest_pt_exercise ; closest_pt_solution

3. Nesting Loop

  1. Create a loop inside the loop
  2. Cross references (round-robin)

HomeWork_closeCurves

Download: closest_pair_solution (with homework)

Conclusion

Comparison with the first/previous GH definitions. Answer to the question: Why should I use a code? (Can I? Do I?)

Download: initial_GH_solutions (from different students)