.NET

## .NET

Contributor
14 Posts
0 Kudos
Registered: ‎07-17-2011
Post 1 of 6

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

650 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.How can I change it to 0-2PI?

37 Posts
3 Kudos
Registered: ‎05-25-2011
Post 2 of 6

# 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
3 Posts
0 Kudos
Registered: ‎04-20-2011
Post 3 of 6

# 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
14 Posts
0 Kudos
Registered: ‎07-17-2011
Post 4 of 6

# 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
95 Posts
1 Kudo
Registered: ‎11-15-2011
Post 5 of 6

# 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
95 Posts
1 Kudo
Registered: ‎11-15-2011
Post 6 of 6

# 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

Post to the Community