0
\$\begingroup\$

So I have a velocity vector b in world space and I have a "pointing" vector a in world space. I need to know how to make the velocity vector to be relative to the "pointing" vector. Better explanation in image below:

The Problem

So on the left you can see the vectors in world space, but on the right - vectors in a space. I need to get the vector b in the _a_space from the worldspace.

\$\endgroup\$
1
  • \$\begingroup\$ Rotate b with minus the angle from y-axis to a, in your left pictures? E.g top left, from y to a seems to be about 30 degrees. Rotate b by -30 degrees. \$\endgroup\$
    – Skitskraj
    Mar 5, 2016 at 21:27

3 Answers 3

1
\$\begingroup\$

you can just convert the coodinates.

to do this, you have to use the normalized â as an base vector for the new coodinating system then use the 90º rotated norm(a.y,-a.x) as another base.

lets name they as e1 and e2.

now you can express your vector b as an linear combination of e1 and e2 with the linear system of equations:

b = m*e1+n*e2

b.x = m*e1.x+n*e2.x
b.y = m*e1.y+n*e2.y

solve for m and n and the vector (m,n) is your b in a coodinates

\$\endgroup\$
1
  • \$\begingroup\$ But I have 3D vectors in my case(propably forgot to mention). How would I do it with 3D vectors? Oh, and that means that: m = b / e1; n = b / e2; o = b / e3 right? Yeah, I still need to know the step where you rotate it by 90 degrees in 3D setup. \$\endgroup\$ Mar 6, 2016 at 5:48
1
\$\begingroup\$

So I solved this in kind of simple way. As I had the pointing vector(which in my specific case was y, but it doesn't matter that much) and I found out that I can actually get another vector out here. So I made a vector plane of x and y vectors. Than I did x.cross(y) and obtained z vector. Than I made those vectors 4D by setting w to be 0. After that I created a new matrix and plugged each of those vectors into the matrix - x into column 0, y into comun 1 and z into comlumn 2. In the result I had a transformation matrix which I could use as multiplier for the velocity vector and obtained velocity relative to the vector. Unfourtunately, I should say that vector to vector-space conversion requires 2 vectors. Fourtunately, I had 2:)

\$\endgroup\$
0
\$\begingroup\$

The “velocity in a space” can be broken down in two vectors, one that is the same direction as a, and one that is perpendicular to a.

The first vector has direction u and size su, computed as follows:

u = normalize(a)
su = dot(u, b)

The perpendicular vector has direction v and size sv:

v = normalize(b - su * a)
sv = dot(v, b)
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .