www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: luozi on November 06, 2011, 02:54:55 am

Title: how to caculate the angle between the SimpleVector
Post by: luozi on November 06, 2011, 02:54:55 am
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!
Title: Re: how to caculate the angle between the SimpleVector
Post by: luozi on November 06, 2011, 02:54:25 pm
Anybody give me a help? I have try many times but it is still not what I expect. Thanks!
Title: Re: how to caculate the angle between the SimpleVector
Post by: EgonOlsen on November 06, 2011, 03:51:17 pm
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.
Title: Re: how to caculate the angle between the SimpleVector
Post by: luozi on November 06, 2011, 04:40:05 pm
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?
Title: Re: how to caculate the angle between the SimpleVector
Post by: EgonOlsen on November 06, 2011, 05:30:57 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.
Title: Re: how to caculate the angle between the SimpleVector
Post by: luozi on November 06, 2011, 06:04:40 pm
Thank you very much !