algorithmic modeling for Rhino
Hi,
As part of solving my Catenary by Height problem, I am trying to create a new plane at a point A where the y-axis aligns with the negative of an arbitrary vector (in this case, gravity), and the x-axis aligns with the horizontal component of the vector between two arbitrary points (A & B). If that doesn't make sense, then what I'm basically trying to do is nullify the component of the vector from A to B that aligns with the gravity vector and use that for the x-axis. I tried simply subtracting the unitized gravity vector from the A-to-B vector, but that didn't work. I also tried creating a new plane at point A normal to the cross-product of the A-to-B vector and the gravity vector (2nd image), but the y-axis was aligned with the gravity vector (not the opposite of the gravity vector) and the x-axis was also in the wrong direction, pointing away from point B instead of towards it (along the horizontal component of A-to-B anyway). I know there is something easy that I'm missing here...sorry for not understanding vectors & planes better.
Thanks!
Tags:
Figured it out...here's the VB code that worked for me:
[inputs: PtA, PtB, Grav (direction of gravity vector)]
Grav.Unitize
Dim line As New Line(PtA, PtB)
Dim v As Vector3d = line.Direction ' get the vector between A and B and unitize it
v.Unitize
Dim plane As New Plane(PtA, Grav, v) ' create the plane with the x-axis in the direction of Grav and the A-to-B vector (v) on the y-axis
Dim nV As Vector3d = Vector3d.CrossProduct(Grav, v) ' get cross product of Grav and v and unitize it
nV.Unitize
plane.Rotate(Math.PI / 2, nV) ' rotate the new plane 90 degrees around the axis of cross product vector so the y-axis is now aligned with the opposite (negative) of Grav
No doubt there's an easier way to do this, but it seemed to work for me.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by