Grasshopper

algorithmic modeling for Rhino

Angle between vectors With optional plane for 2d angle (VB)

Hey everyone, 

How can I get the angle between two vectors using an optional plane for 2d angle (in VB)? In Grasshopper this would be like inputting a plane into the "p" input of the angle component.

I know the angle without the optional plane is:

angle = Vector3d.vectorAngle(v1, v2)


But I'm not sure how to work the plane in.


Thanks,

-Brian

Views: 2198

Replies to This Discussion

Figured it out... I'm measuring the angle from the plane's Y axis, so when the dot product of Plane's X-axis and user-defined vector >0, then the angle = 2pi - angle.

Dim vec As New vector3d
Dim vecDot As Double
Dim angle As Double

vec = y - x.Origin
vecDot = vec * x.Xaxis
angle = Vector3d.vectorAngle(X.YAxis, vec)

If (vecDot > 0) Then
angle = (math.PI * 2) - angle
End If

B = angle

If there is a better way, let me know!

thanks,

brian

Dim angle As Double = Vector3d.VectorAngle(A, B, plane)

VectorAngle has two overloads, one that computes the 3D angle and one that takes a plane and computes the 2D angle.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Awesome, thanks David - that's exactly what I needed.

This may be a stupid question... but where can I find more information like that? I looked through the SDK help and couldn't find anything on VectorAngle. I tried looking through the GH_Vector Class, and searching for "VectorAngle" and "angle" but I didn't see anything. The Grasshopper primer had some vector utilities written out, but not this particular one. The only reason I knew that:

angle = Vector3d.vectorAngle(v1, v2)

was because someone had posted it in a discussion.


thanks again,

Brian

I believe you'll find what you seek in RhinoCommon.


http://www.rhino3d.com/5/rhinocommon/html/AllMembers_T_Rhino_Geomet...

Don't look in Grasshopper for geometric functionality. That's all RhinoCommon as Aaron pointed out. Grasshopper is 75% graphic interface and 24% solution accounting. 

In RhinoCommon most functions are located in the classes to which they pertain. Intersection methods are a bit of an odd duck, they are all located in the Intersection class.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks Aaron and David, this is a big help.

Nice, Brian!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service