I’m working on an arc class, that creates an arc from 3 locations. I tested the math before starting with jme3.
So with jme3 I did this:
create a Vector3f for each location
substract the center from startpoint and endpoint
create a Vector3f(1f, 0, 0) for angle 0
use center.angleBetween(vector2start) and center.angleBetween(vector2end) - which results in both 0 or both Math.PI
That looked a bit strange to me, so I created a class VectorMath which calculates the angleBetween from 2 given vectors.
With the math I was using before, I got the expected angles.
So I don’t know - is my usage of Vector3f wrong, or does the angleBetween of Vector3f have a bug?
Also, code matters.
To know what values to expect, we have to know the definition of center which you don’t give.
If it’s the average of the two vectors then of course the angle will be 180°?
Do you wan the angle between start and end or the angle between center and start? Because the code you have is trying to find the angle between center and start… but not like you think.
angleBetween() works fine. In 14 years, I suspect we’d have gotten more complaints before now otherwise.
Yes, my fault. Usually I only skim the method summry and don’t read whole docs.
So with normalized vectors I get some reasonable results, but its quite different from my calculations.
Isn’t angle 0 horizontally to the right?
Well, I write code for any possible circle with the limitation, that the circle is a projection to xy-plane, and z-axis may convert the circle into a spiral.
I’m not a mathematician, so I work from bug to bug.
No, my writings where wrong. Of cause I want the angle from each vector to the base vector (1, 0, 0) which I supposed to point to angle 0.
I duplicated my test function and changed it to work with Vector3f - with the result, that it looks mirrored by y-axis.
I read about axis definitions from jme3 and thought, that it matches axis from swing/awt: x-axis from left to right, y-axis top-down and z-axis from screen towards me.
In swing angle 0 is vector(1,0,0).
Where is angle 0 in jme3?