Author Topic: how to caculate the angle between the SimpleVector  (Read 3083 times)

Offline luozi

  • byte
  • *
  • Posts: 20
    • View Profile
how to caculate the angle between the SimpleVector
« 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!

Offline luozi

  • byte
  • *
  • Posts: 20
    • View Profile
Re: how to caculate the angle between the SimpleVector
« Reply #1 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!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: how to caculate the angle between the SimpleVector
« Reply #2 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.

Offline luozi

  • byte
  • *
  • Posts: 20
    • View Profile
Re: how to caculate the angle between the SimpleVector
« Reply #3 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: how to caculate the angle between the SimpleVector
« Reply #4 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.

Offline luozi

  • byte
  • *
  • Posts: 20
    • View Profile
Re: how to caculate the angle between the SimpleVector
« Reply #5 on: November 06, 2011, 06:04:40 pm »
Thank you very much !