-1

I'm by no means an expert in math, what I'm trying to do is to Isolate a force aligned with a vehicle in a game (specifically to do a directional friction).

the equation is simple I take a vector $v_1$ (1,0,0) rotate it by a quaternion rotation (this part works well I get a vector of length 1 that is rotated in space), and then I multiply another vector (force) by the rotated vector.

$v_2 = q * v_1 * q^{-1}$ (idk how to draw line above characters in mathjax, let's pretend this is a inverse quaternion)

$v_3 = F * v_1$

The thing is $v_3$ is all of a sudden not aligned with $v_1$ which makes absolutely no sense to me, As I imagine it, $v_3$ should point in the direction of $v_1$.

Am I missing something here? or does this look like a bug?

This is how it looks like in game: The blue line is $v_1$ and the red line is $v_3$, as you can see $v_3$ isn't aligned properly (and it's shape wildly changes during runtime).

image of two vectors above the car

Qmechanic
  • 201,751

1 Answers1

1

Please define what $*$ is in $v_3 = F * v_1$

You need to take the dot product, and not any quaternion product or other product.

The reason I suspect you did not, is because the result isn't along the unit vector. If you use the dot product, then the result is the magnitude of the force vector along the direction.

To make it into a vector quantity multiply scale the unit vector $\hat{v}$ with the dot product value.

$$ \vec{F}_{\parallel} = ( \hat{v} \cdot \vec{F}) \hat{v}$$

John Alexiou
  • 38,341