I calculated the vectors of my yaw and pitch successfully. Even tho it works fine, I can't seem to understand how the math works exactly.
Could someone (graphically / demonstratively) explain me this with a picture so I can better derive the math?
Vector3d CSMath::AngleToDirection(Vector3d angle) {
// Convert angle to radians
angle.x = (angle.x) * 3.14159265 / 180;
angle.y = (angle.y) * 3.14159265 / 180;
float sinYaw = sin(angle.y);
float cosYaw = cos(angle.y);
float sinPitch = sin(angle.x);
float cosPitch = cos(angle.x);
Vector3d direction;
direction.x = cosPitch * cosYaw;
direction.y = cosPitch * sinYaw;
direction.z = -sinPitch;
return direction;
}
I'd be really grateful! Thanks guys.
direction.x = cosPitch * cosYaw; direction.y = cosPitch * sinYaw; direction.z = -sinPitch;
i dont get why multiplying with cosine of pitch. i just need some visualization of this \$\endgroup\$