#How would I calculate a direction vector from pitch and yaw?
10 messages · Page 1 of 1 (latest)
direction[0] = cos(yaw) * cos(pitch);
direction[1] = sin(pitch);
direction[2] = sin(yaw) * cos(pitch);
direction[3] = 0;
This vaguely makes sense to me. to get the x component we take the cosine of yaw. The reason why we multiply by cosine of pitch well if i look directly up and turn i still look at the same point in space, but beyond this i do not know.
if coordinate systems do matter then i think i subtract pi / 2 from the yaw
Seems like you're using a spherical coordinate system, for which those equations seem ok to me.
Check a few reference points as sanity checks (yew = pitch = 0, yaw = 0 pitch = pi/4, etc.). This should sort out coordinate system issues (you may have to shift by pi/2 and/or negate).
thanks for responding. Yeah i have tried subtracting yaw by pi / 2 and negating it. Someone said they are using left handed in their game so im taking a look in their code
my problem was that i didnt know cross product was anti communative
.close
Post marked as solved by @brisk mist.
Use .unsolved if this was a mistake.