how to caculate the angle between the SimpleVector

Started by luozi, November 06, 2011, 02:54:55 AM

Previous topic - Next topic

luozi

I want to caculate the angle between two SimpleVectors, I using the following code:
SimpleVector sp=new SimpleVector(0,1,0);
float angle=sp.calcAngle(new SimpleVector(0,0,1));
Logger.log("angle is "+angle);

I thought the angle should be 90, but the  output "angle is 1.5707964", is there something I misunderstand? Thank you!

luozi

Anybody give me a help? I have try many times but it is still not what I expect. Thanks!

EgonOlsen

jPCT (just like Java) doesn't work with degrees but with radians. In your example 90 degrees is pi/2, which is what you get.

luozi

Oh, I almost foget the math. Thank you! By the way, can you tell me if a model's texture coordinates have been difinited, does the size of the texture or the size of the picture have influnce on the result?

EgonOlsen

Quote from: luozi on November 06, 2011, 04:40:05 PM
By the way, can you tell me if a model's texture coordinates have been difinited, does the size of the texture or the size of the picture have influnce on the result?
No. Everything works with normalized coordinates. Texture size doesn't matter.