I have no idea how I would go on about this, does anyone know how I can rotate x, y, and z using the yaw, pitch, and roll?, I can only manage to do 2D rotation, but that's not what I am looking for. This is the current code I have.
Yaw and pitch, and roll are supposed to be in degrees. Not radians.
class Vector3
{//
public:
float x, y, z;
void rotate(float yaw, float pitch, float roll) {
}
};
A solution that doesn't require a external library is appreciated.
edit :
void rotate(float yaw, float pitch, float roll) { //X Y Z Rotation
float cosa = cos_r(yaw); float cosb = cos_r(pitch); float cosc = cos_r(roll);
float sina = sin_r(yaw); float sinb = sin_r(pitch); float sinc = sin_r(roll);
float Axx = cosa * cosb;
float Axy = cosa * sinb * sinc - sina * cosc;
float Axz = cosa * sinb * cosc + sina * sinc;
float Ayx = sina * cosb;
float Ayy = sina * sinb * sinc + cosa * cosc;
float Ayz = sina * sinb * cosc - cosa * sinc;
float Azx = -sinb;
float Azy = cosb * sinc;
float Azz = cosb * cosc;
float px = x; float py = y; float pz = z;
x = Axx * px + Axy * py + Axz * pz;
y = Ayx * px + Ayy * py + Ayz * pz;
z = Azx * px + Azy * py + Azz * pz;
}
I tried this but it didn't work. cos_r and sin_r are functions that take degrees.