Author Topic: Converting world-space coordinates  (Read 2785 times)

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Converting world-space coordinates
« on: December 10, 2008, 03:33:42 am »
What would be a good way to convert a SimpleVector in world-space into one in camera-space (i.e. the look-direction +z axis, up-direction -y axis, etc)?

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Converting world-space coordinates
« Reply #1 on: December 10, 2008, 03:59:01 am »
Oh, never mind, I forgot that you can apply a rotation matrix to a SimpleVector (oops :-[)  Something like this should work:

Code: [Select]
public SimpleVector toCameraSpace( SimpleVector v, Camera c )
{
    SimpleVector dest = v.calcSub( c.getPosition() );
    dest.matMul( c.getBack() );
    return dest;
}