Create specific orthogonal vector

30 Views Asked by At

I've been working on a project where my computer takes the X, Y, and Z accelerometer data from a wii remote and turns it into mouse movement. I'm fairly solid on all of my python, but I'm stuck on a bit of vector math. The setup is fairly tedious, so please bear with me.

The axes of the wii remote are as follows:

  • +x axis : left side
  • +y axis : face up (the side with buttons)
  • +z axis : back (the side with the nunchuk port)

I'm creating a vector V = < x, y, z> where x, y, and z are the accelerometer outputs. This vector points up in the real world regardless of how the wii remote is oriented, so when the script starts and the wii-remote is face up, V = <0, 9.81, 0>.

If I use the Direct Angle formula (alpha = acos(a/||V||)) to find the distance from V to the y-axis, effectively giving me how far up the wii-remote is pointed, regardless of roll.

I need to find a vector U such that U is always orthogonal to V in such a way that when V = <0, 9.81, 0>, U = <9.81, 0, 0>, so that if I can find the angle between U and the x-axis, I can find how far left the wii remote is pointing, regardless of roll.

*note: I've tried U = < y,-x, 0>, but that weirds out on me and only gives me a vector on the XY plane.

*note 2: The vector V always points up. I'm looking for a vector U that always points left.

TL;DR: Given V = < x, y, z>, find U such that if V = <0, 1, 0>, U = <1, 0, 0>