How to calculate left or right vector

I know that 2 vector is perpendicular when x1*x2 + y1*y2 (+ z1*z2) =0, not to mention 3D, just talk about 2D. I still have no ideal how to calculate a left or right vector of a main direction vector. Anyone know how to calculate?

1
2
3
4
5
6
7
8
9
10
11
  //prototype
  Vector2 GetLeftVector(Vector2 Direction)
  {
   Vector2 ToTheLeft;
   //??
   return ToTheLeft;
  }
Vector2 GetRightVector(Vector2 Direction)
  {
return GetLeftVector(Direction)*-1.0f;
  }
Last edited on
Thanks keskiverto, It's just so simple :)
1
2
3
4
5
6
7
Vector2 GetLeftVector(Vector2 Direction)
  {
   Vector2 ToTheLeft;
   ToTheLeft.X = -Direction.Y;
   ToTheLeft.Y = Direction.X
   return ToTheLeft;
  }
Topic archived. No new replies allowed.