Sorry, I pretty much ignored your edit because I couldn't understand what you were trying to do and concentrated on getting the first part right...Still doesn't work... the trouble is, I have to rotate the heading (see the second code I posted above), and I'll probably have to rotate the three vectors differently so they add up to something meaningfull in the end... the question is just how?
So, on to your code.
Code:
VECTOR3 HeadX, HeadY, HeadZ;
VECTOR3 mROT;
MATRIX3 HeadMatrix;
ship->GlobalRot(_V(1,0,0), HeadX);
ship->GlobalRot(_V(0,1,0), HeadY);
ship->GlobalRot(_V(0,0,1), HeadZ);
Code:
double phi = data.SourceStar->EclipticRot.X *RAD;
double theta = data.SourceStar->EclipticRot.Y *RAD;
double lambda = data.SourceStar->EclipticRot.Z *RAD;
double sint = sin(theta), cost = cos(theta);
double sinp = sin(phi), cosp = cos(phi);
double sinl = sin(lambda), cosl = cos(lambda);
MATRIX3 gal2ecl = mul(mul(_M(cosp,0,sinp, 0,1,0, -sinp,0,cosp),
_M(1,0,0, 0,cost,sint, 0,-sint,cost)),
_M(cosl,0,-sinl, 0,1,0, sinl,0,cosl));
HeadX = tmul (gal2ecl, HeadX);
HeadY = tmul (gal2ecl, HeadY);
HeadZ = tmul (gal2ecl, HeadZ);
Code:
phi = data.TargetStar->EclipticRot.X *RAD;
theta = data.TargetStar->EclipticRot.Y *RAD;
lambda = data.TargetStar->EclipticRot.Z *RAD;
sint = sin(theta), cost = cos(theta);
sinp = sin(phi), cosp = cos(phi);
sinl = sin(lambda), cosl = cos(lambda);
gal2ecl = mul(mul(_M(cosp,0,sinp, 0,1,0, -sinp,0,cosp),
_M(1,0,0, 0,cost,sint, 0,-sint,cost)),
_M(cosl,0,-sinl, 0,1,0, sinl,0,cosl));
HeadX = mul (gal2ecl, HeadX);
HeadY = mul (gal2ecl, HeadY);
HeadZ = mul (gal2ecl, HeadZ);
Code:
HeadMatrix.m11 = HeadX.x;
HeadMatrix.m12 = HeadY.x;
HeadMatrix.m13 = HeadZ.x;
HeadMatrix.m21 = HeadX.y;
HeadMatrix.m22 = HeadY.y;
HeadMatrix.m23 = HeadZ.y;
HeadMatrix.m31 = HeadX.z;
HeadMatrix.m32 = HeadY.z;
HeadMatrix.m33 = HeadZ.z;
ship->SetRotationMatrix(HeadMatrix);