DPoint3.angle2D()

User 870ab5b546

27-09-2012 19:49:35

I got the following output from JChem 5.10.1:


authVector = DPoint3(0.0, -50.0, 0.0), 
authVector.angle2D(1.0, 0.0) in radians = 1.550798992821746,
authVector.angle2D(1.0, 0.0) in degrees = 88.8542371618249

Why doesn't the angle2D() method return exactly π/2 radians or 90°?


Here's another one:


authVector = DPoint3(63.0, 0.0, 0.0), 
authVector.angle2D(1.0, 0.0) in radians = 3.141592653589793,
authVector.angle2D(1.0, 0.0) in degrees = 180.0

The correct value is 0 radians or 0°, because the two vectors are pointing in the same direction.

ChemAxon 5433b8e56b

01-10-2012 02:39:12

Hi Bob,


the APIDoc of the angle2D method states that the method calculates the absolute angle of the vector that points from the given DPoint3D to the point that is given by its x and y coordinates.


In the first case, the basepoint is (0,-50) in the xy plane, and the parameters specifies the (1, 0) point. The absolute angle is the angle of the vector points from the origo to the (1, 50) point, which is the result you got (88.85 degree, or 1.55 radians).


In the second case the vector will be (-62, 0) which also has the angle value as the result you got(180 degree, and π radians.


I hope this clears the situation here.


Regards,
Istvan

User 870ab5b546

01-10-2012 13:36:05

Ah, I see.  The APIDoc is not so clear.  It says,


Calculates the absolute angle of the vector to the other point on the XY plane.


I think it should say,



Calculates the absolute angle in the XY plane of the vector pointing from this point to the other point.  In other words, takes the difference between this vector and the vector pointing from the origin to the other point and returns the angle of the resultant vector's projection onto the XY plane.


Is that right?


ChemAxon 5433b8e56b

01-10-2012 15:07:59

Hi Bob,


thank you for your suggestion, it seems legit, and I am forwarding this suggestion to the core team, they will update the documentation, and it will be published with one of the upcoming releases.


Regards,
Istvan

ChemAxon 25dcd765a3

09-10-2012 09:08:59

Thank you for the clarification.


We have changed the APIDoc accordingly.