.NET

Reply
Contributor
waterharbin
Posts: 14
Registered: ‎07-17-2011
Message 1 of 6 (578 Views)

How to obtain the angle between two vector3d? The angle 's range should be 0-2PI

578 Views, 5 Replies
07-19-2011 07:46 PM

Hello,I define a vextor via two points(ptStart and ptDirection).And now I want to get the angle between my vector3d and the X Axis.Here is my code:

Dim Ang As Double = ptStart.GetVectorTo(ptDirection).GetAngleTo(Vector3d.XAxis)

But the range is 0-PI.:smileysad:How can I change it to 0-2PI?

ADN Support Specialist
Marat.Mirgaleev
Posts: 37
Registered: ‎05-25-2011
Message 2 of 6 (551 Views)

Re: How to obtain the angle between two vector3d? The angle 's range should be 0

07-20-2011 10:12 AM in reply to: waterharbin

Hi,

 

   I see there is another version of this method:

 

      Vector3d.GetAngleTo Method (Vector3d, Vector3d)

      Returns the angle between this vector and the vector vector in the range [0, 2 x Pi]. 

 

   Please, find its description in the Managed Class Reference Guide (\ObjectARX 2012\docs\arxmgd.chm).



Marat Mirgaleev
Developer Technical Services
Autodesk Developer Network
Member
BabylonLion
Posts: 3
Registered: ‎04-20-2011
Message 3 of 6 (508 Views)

Re: How to obtain the angle between two vector3d? The angle 's range should be 0

07-25-2011 05:17 AM in reply to: waterharbin

Hi! Try this.

 

double Ang = ptStart.GetVectorTo(ptDirection).GetAngleTo(Vector3d.XAxis, Vector3d.ZAxis.Negate());

 

Contributor
waterharbin
Posts: 14
Registered: ‎07-17-2011
Message 4 of 6 (476 Views)

Re: How to obtain the angle between two vector3d? The angle 's range should be 0

07-30-2011 03:21 AM in reply to: BabylonLion

Nice code.haha.

Valued Contributor
FFlix
Posts: 95
Registered: ‎11-15-2011
Message 5 of 6 (404 Views)

Re: How to obtain the angle between two vector3d? The angle 's range should be 0

12-07-2011 09:00 AM in reply to: Marat.Mirgaleev

hi marat

 

although i do not want to spoil the party, i desperately fail to obtain any angles above the 0-pi interval. i admit i still use autocad 2011, however, the documentation for the .getangleto(vec; vecref) appears as you state.

 

considering the problem, i could do myself with some clarification as to how it's supposed to work:

 

starting with a vector3d, i look for the angle to another vector3d. to keep things simple, let's say they both originate in the same point and 'point away' from it in separate directions. why is there an optional reference-vector3d? if it's only to expand the interval from 0-pi to 0-2*pi, then an optional boolean would have been satisfactory.

 

many thanks, felix

Valued Contributor
FFlix
Posts: 95
Registered: ‎11-15-2011
Message 6 of 6 (402 Views)

Re: How to obtain the angle between two vector3d? The angle 's range should be 0

12-07-2011 09:15 AM in reply to: FFlix

yes of course, as soon as i posted it...

 

to whom it may concern

 

the additional vecref can be used to define [or fixate] that one dimension of the three (in 3d) that leaves the other two to span the plane in which the angle is measured. in turn it means that the option without the vecref leaves it completely to the two original vectors, i.e. the calling one and the parameter one, to define a plane and the angle within, which also explains why then with the information given it is not possible to give angles above pi, because 'they technically then do not exist'.

 

hope you enjoyed the show

 

felix

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community