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.
Download: basic_loop
2. Closest Point
- Loop training
- Conditional Statements
- Rythm exercises
Download: loop_&_conditions
2.1. Connections
- List (value) declaration
- List methods (Add value to list of values)
- Return connections as list of lines
- How to avoid connection by yourself (equals)?
Download: connections ; avoiding_yourself
2.2. Shortest Distance
- Declaration min distance (double value)
- Find distance between two points (method)
- ..is it smaller then actual (if condition)
- Create/Return shortest line
- Custom method (function) definition.
- How to avoid connection by yourself (if condition)?
Download: closest_pt_exercise ; closest_pt_solution
3. Nesting Loop
- Create a loop inside the loop
- Cross references (round-robin)
- How to avoid duplicate points connections (sequence)?
- Homework: Create all connections smaller than distance limit.
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?)
- Use the power of a code to customize predefined solutions and improve their efficiency
- Deal with preconceived fears and concepts about code (code-phobia)
Download: initial_GH_solutions (from different students)