VectorAngle question(solved)

rhinocommon

(Shaunwu25) #1

Hi all,
I have a basic question regarding what’s the exact direction of projected plane on vector angle method.

I made a little experiment to test the angle from two vectors at xy plane and rotate the plane 3-dimensionally to evaluate which is the exact projection direction.

As you can see, the projection direction isn’t toward z-direction.
Much appreciated in advance.

ShaunVectorAngle check.gh (17.1 KB)


(Pascal Golay) #2

Hello - ‘Project’ implies normal to the plane, I would think - does that not match what you’re seeing?

-Pascal


(Dale Fugier) #3

Hi @shaunwu25,

The method you reference is designed to calculate the angle between two 3D vectors that lie on a plane.

The inputs you need to provide are the two vectors and the plane on which they lie.

The source code behind VectorAngle.VectorAngle projects the two vectors onto the input plane, for accuracy. Then, the dot-product between the projected vectors is calculated. The dot-product is then passed to Math.Acos to determine the angle in radians.

Does this help?

– Dale


(Shaunwu25) #4

Hi @pascal , @dale,

Thank you very much for your answer.
Probably, I didn’t describe well for my question earlier. I’m wondering how you calculate the angle between two vectors while the input plane isn’t lying on these two vectors.
For example, at the video, blue vectors always lie on xy plane with angle 90 degree, the input plane is then rotated 3- dimensionally. It’s not clear for me which direction to project vectors on the rotated plane.

Regards
Shaun


(Shaunwu25) #5

Hi Pascal,

Thanks for your answer.
If the direction of projection implies the normal of the plane, in this case, it should be toward to z-direction as two blue vectors lie on xy plane with 90 degree. But as you can see the second panel and third panel were showing different results.

Regards,
Shaun


(Dale Fugier) #6

Hi @shaunwu25,

If you want the angle between two arbitrary angles, then use this version of Vector3d.VectorAngle.

Does this help?

– Dale


(Pascal Golay) #7

Hi Shaun - is the goal to get the angle between two 3d vectors when they are both projected to an arbitrary plane?

-Pascal


#8

It seems that Angle command computes the angles correctly no matter how the lines (vectors) are oriented.


(Shaunwu25) #9

@pascal Exactly!


(Shaunwu25) #10

@Andrew_Nowicki do you have any idea about how to calculate the angle as two vectors projected onto the plane?


(Pascal Golay) #11

Hi Shaun - I guess then that you can calculate the points at the base and tip of the vectors and use Plane.ClosestPoint, then generate new vectors from these projected points and measure the angle.

@shaunwu25 - the link from Dale above gets you a function that does what I just said, but automatically…

http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Vector3d_VectorAngle_1.htm

-Pascal


(Shaunwu25) #12

@pascal YES! it’s as you described. I’m wondering, then the description of rhinocommon SDK would still be corrected? Since the two vectors are finding the closest points on an arbitrary plane rather than “project” onto it with a certain direction. It’s quite misleading for me.


Anyway, thanks for solving my question! you are the best.

Shaun


(Pascal Golay) #13

Hi Shaun - that amounts to the same thing in this case - a Plane.ClosestPoint will always be along the plane normal.

-Pascal


(Shaunwu25) #14

@pascal Thanks, now the puzzle is solved :slight_smile: