Monday, July 29, 2013

Tangent Spheres Tutorial

This tutorial will show how to create two tangent spheres between two input points using Rhino 5 and Grasshopper 0.9.
This is how the result looks:

















INPUT
The input here is two points in the 3D coordinate system.  Let us call them points A and B.











PARAMETERS
This is a diagram of the parameters that we will need in order to solve the problem:
















1- A tangent point D between the two spheres, at some "t" parameter (0-1) between points A and B.
2- The center of the first sphere, or the mid point C1 between A and D.
3- The center of the second sphere, or the mid point C2 between D and B.
4- the radius of the first sphere (r1), or the distance between A and C1.
5- The radius of the second sphere (r2), or the distance between D and C2.

SOLUTION
We need to define or generate all the parameters identified in the above.
1- We will use the "Expression" component to define point D between A and B at some parameter t. The expression we will use is based on the vector equation of a line: D = A + t*(B-A).
  • B-A: is the vector that goes from B to A using vector subtraction operation.
  • t*(B-A): where "t" value is between 0 and 1 to get us a location on the vector.
  • A+t*(B-A): gets a point on the vector between A and B.














2- We will use the "Expression" component to also define the mid points C1 and C2.
.











3- The first sphere radius (r1) and the second sphere (r2) can be calculated using the "Distance" component.
















4- The final step involves creating the sphere from a base plane and radius. We need to make sure the origins are hooked to C1 and C2 and the radius from r1 and r2.

No comments:

Post a Comment