| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281 |
- #if defined _inc_rotation_misc
- #undef _inc_rotation_misc
- #endif
- #if defined _rotation_misc_included
- #endinput
- #endif
- #define _rotation_misc_included
- #include "rotation.inc"
- // unfinished or random functions
- // misc - Get real / offset position of attached vehicle objects
- stock GetVehicleObjectPositionWorld(vehicleid,
- Float: att_X, Float: att_Y, Float: att_Z, Float: att_rotX, Float: att_rotY, Float: att_rotZ,
- &Float: X, &Float: Y, &Float: Z, &Float: rotX, &Float: rotY, &Float: rotZ
- ) {
- if(GetVehiclePos(vehicleid, X, Y, Z)) {
- new
- Float: w,
- Float: x,
- Float: y,
- Float: z,
- Float: matrix1[4][4],
- Float: matrix2[4][4];
- GetVehicleRotationQuat(vehicleid, w, x, y, z);
- GetRotationMatrixFromEuler(matrix1, att_rotX, att_rotY, att_rotZ);
- GetRotationMatrixFromQuat(matrix2, w, x, y, z);
- MatrixRotate(matrix2, att_X, att_Y, att_Z, 0.0, X, Y, Z);
- RotateMatrixWithMatrix(matrix1, matrix2);
- GetEulerFromMatrix(matrix1, rotX, rotY, rotZ);
- return true;
- }
- return false;
- }
- stock GetVehicleObjectPositionOffset(vehicleid,
- Float: X, Float: Y, Float: Z, Float: rotX, Float: rotY, Float: rotZ,
- &Float: att_X, &Float: att_Y, &Float: att_Z, &Float: att_rotX, &Float: att_rotY, &Float: att_rotZ
- ) {
- if(GetVehiclePos(vehicleid, att_X, att_Y, att_Z)) {
- new
- Float: w,
- Float: x,
- Float: y,
- Float: z,
- Float: matrix1[4][4],
- Float: matrix2[4][4];
- GetVehicleRotationQuat(vehicleid, w, x, y, z);
- GetRotationMatrixFromEuler(matrix1, rotX, rotY, rotZ);
- GetRotationMatrixFromQuat(matrix2, -w, x, y, z);
- X -= att_X;
- Y -= att_Y;
- Z -= att_Z;
- att_X = matrix2[0][0] * X + matrix2[0][1] * Y + matrix2[0][2] * Z;
- att_Y = matrix2[1][0] * X + matrix2[1][1] * Y + matrix2[1][2] * Z;
- att_Z = matrix2[2][0] * X + matrix2[2][1] * Y + matrix2[2][2] * Z;
- RotateMatrixWithMatrix(matrix1, matrix2);
- GetEulerFromMatrix(matrix1, att_rotX, att_rotY, att_rotZ);
- return true;
- }
- return false;
- }
- stock MatrixMulMatrix(Float: A[][], Float: B[][], Float: C[][], a1 = sizeof A, a2 = sizeof A[], b1 = sizeof B, b2 = sizeof B[], c1 = sizeof C, c2 = sizeof C[]) {
- if(a1 == c1 && a2 == b1 && b2 == c2) {
- for(a1 = 0; a1 < c1; ++a1) {
- for(b2 = 0; b2 < c2; ++b2) {
- for(C[a1][b2] = Float: a2 = 0; a2 < b1; ++a2) {
- C[a1][b2] += A[a1][a2] * B[a2][b2];
- }
- }
- }
- }
- }
- stock GetRotMatX(Float: matrix[][], Float: angle) {
- matrix[0][0] = 1.0;
- matrix[0][1] = 0.0;
- matrix[0][2] = 0.0;
- matrix[1][0] = 0.0;
- matrix[2][0] = 0.0;
- matrix[2][2] = matrix[1][1] = floatcos(angle, degrees);
- matrix[1][2] = -(matrix[2][1] = floatsin(angle, degrees));
- }
- stock GetRotMatY(Float: matrix[][], Float: angle) {
- matrix[1][1] = 1.0;
- matrix[0][1] = 0.0;
- matrix[1][0] = 0.0;
- matrix[1][2] = 0.0;
- matrix[2][1] = 0.0;
- matrix[2][2] = matrix[0][0] = floatcos(angle, degrees);
- matrix[2][0] = -(matrix[0][2] = floatsin(angle, degrees));
- }
- stock GetRotMatZ(Float: matrix[][], Float: angle) {
- matrix[2][2] = 1.0;
- matrix[0][2] = 0.0;
- matrix[1][2] = 0.0;
- matrix[2][0] = 0.0;
- matrix[2][1] = 0.0;
- matrix[1][1] = matrix[0][0] = floatcos(angle, degrees);
- matrix[0][1] = -(matrix[1][0] = floatsin(angle, degrees));
- }
- stock MatrixSub(Float: A[][], Float: B[][], Float: C[][], a1 = sizeof A, a2 = sizeof A[], b1 = sizeof B, b2 = sizeof B[], c1 = sizeof C, c2 = sizeof C[]) {
- if(a1 == b1 && b1 == c1 && a2 == b2 && b2 == c2) {
- for(a1 = 0; a1 < b1; ++a1) {
- for(a2 = 0; a2 < b2; ++a2) {
- C[a1][a2] = A[a1][a2] - B[a1][a2];
- }
- }
- }
- }
- stock GetRotFromFlight(Float: pitch, Float: roll, Float: yaw, & Float: rX, & Float: rY, & Float: rZ) {
- new
- Float: cosY = floatcos(roll, degrees),
- Float: sinX = floatsin(pitch, degrees);
- rX = cosY * sinX;
- if(rX > 0.9999) {
- rX = 90.0;
- rY = 0.0;
- rZ = yaw;
- } else if(rX < -0.9999) {
- rX = -90.0;
- rY = 0.0;
- rZ = yaw;
- } else {
- new
- Float: cosX = floatcos(pitch, degrees),
- Float: cosZ = floatcos(yaw, degrees),
- Float: sinY = floatsin(roll, degrees),
- Float: sinZ = floatsin(yaw, degrees);
- rX = asin(rX);
- rY = atan2(sinY, cosY * cosX);
- rZ = atan2(cosX * sinZ - cosZ * sinY * sinX, cosZ * cosX + sinZ * sinY * sinX);
- }
- }
- stock GetFlightFromRot(Float: rX, Float: rY, Float: rZ, & Float: pitch, & Float: roll, & Float: yaw) {
- new
- Float: cosX = floatcos(rX, degrees),
- Float: sinY = floatsin(rY, degrees);
- roll = cosX * sinY;
- if(roll < -0.9999) {
- pitch = 0.0;
- roll = 90.0;
- yaw = rZ;
- } else if(roll > 0.9999) {
- pitch = 0.0;
- roll = -90.0;
- yaw = rZ;
- } else {
- new
- Float: cosY = floatcos(rY, degrees),
- Float: cosZ = floatcos(rZ, degrees),
- Float: sinX = floatsin(rX, degrees),
- Float: sinZ = floatsin(rZ, degrees);
- roll = asin(roll);
- pitch = atan2(sinX, cosX * cosY);
- yaw = atan2(sinZ * cosY + cosZ * sinX * sinY, cosZ * cosY - sinZ * sinX * sinY);
- }
- }
- // (w + xi + yj + zk)(ai + bj + ck)(w - xi - yj - zk)
- // ((ai + bj + ck)w + (-a + bk -cj)x + (-ak - b + ci)y + (aj - bi -c)z)(w - xi - yj - zk)
- // ((-a*x - b*y - c*z) + (w*a - b*z + c*y)i + (a*z + w*b - c*x)j + (-a*y + b*x + w*c)k) * (w - xi - yj - zk)
- // ((-a*x*w - b*y*w - c*z*w) + (w^2*a - b*z*w + c*y*w)i + (a*z*w + w^2*b - c*x*w)j + (-a*y*w + b*x*w + w^2*c)k) +
- // ((a*x^2 + b*y*x + c*z*x)i + (w*a*x - b*z*x + c*y*x) + (a*z*x + w*b*x - c*x^2)k + (a*y*x - b*x^2 - w*c*x)j) +
- // ((a*x*y + b*y^2 + c*z*y)j + (-w*a*y + b*z*y - c*y^2)k + (a*z*y + w*b*y - c*x*y) + (-a*y^2 + b*x*y + w*c*y)i) +
- // ((a*x*z + b*y*z + c*z^2)k + (w*a*z - b*z^2 + c*y*z)j + (-a*z^2 - w*b*z + c*x*z)i + (-a*y*z + b*x*z + w*c*z))
- // ((-a*x*w - b*y*w - c*z*w) + (w*a*x - b*z*x + c*y*x) + (a*z*y + w*b*y - c*x*y) + (-a*y*z + b*x*z + w*c*z)) +
- // ((w^2*a - b*z*w + c*y*w) + (a*x^2 + b*y*x + c*z*x) + (-a*y^2 + b*x*y + w*c*y) + (-a*z^2 - w*b*z + c*x*z))i +
- // ((a*z*w + w^2*b - c*x*w) + (a*y*x - b*x^2 - w*c*x) + (a*x*y + b*y^2 + c*z*y) + (w*a*z - b*z^2 + c*y*z))j +
- // ((-a*y*w + b*x*w + w^2*c) + (a*z*x + w*b*x - c*x^2) + (-w*a*y + b*z*y - c*y^2) + (a*x*z + b*y*z + c*z^2))k
- // (w^2*a + a*x^2 - a*y^2 - a*z^2 + 2*((c*y*w + c*x*z + b*y*x) - b*z*w))i +
- // (w^2*b - b*x^2 + b*y^2 - b*z^2 + 2*((a*z*w + a*y*x + c*z*y) - c*x*w))j +
- // (w^2*c - c*x^2 - c*y^2 + c*z^2 + 2*((b*x*w + b*z*y + a*x*z) - a*y*w))k
- stock QuatMul(Float: w1, Float: x1, Float: y1, Float: z1, Float: w2, Float: x2, Float: y2, Float: z2, & Float: w, & Float: x, & Float: y, & Float: z) {
- // v1v2 = (v1 x v2) - (v1 . v2) | (w1, v1)(w2, v2) = (w1 * w2 - v1 . v2), (w1 * v2) + (w2 * v1) + (v1 x v2)
- w = (w1*w2 - x1*x2 - y1*y2 - z1*z2);
- x = (w1*x2 + w2*x1 + y1*z2 - z1*y2);
- y = (w1*y2 + w2*y1 + z1*x2 - x1*z2);
- z = (w1*z2 + w2*z1 + x1*y2 - y1*x2);
- }
- stock CrossProduct(Float: x1, Float: y1, Float: z1, Float: x2, Float: y2, Float: z2, & Float: x, & Float: y, & Float: z) {
- x = y1 * z2 - z1 * y2;
- y = z1 * x2 - x1 * z2;
- z = x1 * y2 - y1 * x2;
- }
- stock QuatRotateVector(Float: w, Float: i, Float: j, Float: k, Float: X, Float: Y, Float: Z, & Float: x, & Float: y, & Float: z) {
- // q * v * q^-1
- // x = (w*w*X + X*i*i - X*j*j - X*k*k + 2.0*((Z*j*w + Z*i*k + Y*j*i) - Y*k*w));
- // y = (w*w*Y - Y*i*i + Y*j*j - Y*k*k + 2.0*((X*k*w + X*j*i + Z*k*j) - Z*i*w));
- // z = (w*w*Z - Z*i*i - Z*j*j + Z*k*k + 2.0*((Y*i*w + Y*k*j + X*i*k) - X*j*w));
- // after a lot of computing you get to the formula "v1 + 2*(w*(v1 x v2) + v1x(v1 x v2));" but only valid with versors (unit quaternion)
- // x = (X + 2.0*(w*(j*Z - k*Y) + j*(i*Y - j*X) - k*(k*X - i*Z)));
- // y = (Y + 2.0*(w*(k*X - i*Z) + k*(j*Z - k*Y) - i*(i*Y - j*X)));
- // z = (Z + 2.0*(w*(i*Y - j*X) + i*(k*X - i*Z) - j*(j*Z - k*Y)));
- // x = (X + 2.0*(w*(j*Z - k*Y) + i*(j*Y + k*Z) - X*(j*j + k*k)));
- // y = (Y + 2.0*(w*(k*X - i*Z) + k*(j*Z - k*Y) - i*(i*Y - j*X)));
- // z = (Z + 2.0*(w*(i*Y - j*X) + i*(k*X - i*Z) - j*(j*Z - k*Y)));
- // 18 muls, 12 adds
- // CrossProduct(i, j, k, X, Y, Z, x, y, z);
- // CrossProduct(i, j, k, x, y, z, i, j, k);
- // x = (X + 2.0 * (w * x + i));
- // y = (Y + 2.0 * (w * y + j));
- // z = (Z + 2.0 * (w * z + k));
- // 15 muls, 15 adds
- CrossProduct(i, j, k, X, Y, Z, x, y, z);
- CrossProduct(
- i + i,
- j + j,
- k + k,
- x + w * X,
- y + w * Y,
- z + w * Z,
- x, y, z
- );
- x += X;
- y += Y;
- z += Z;
- }
- stock GetVehicleRelativePos(vehicleid, & Float: x, & Float: y, & Float: z, Float: oX = 0.0, Float: oY = 0.0, Float: oZ = 0.0) {
- if(GetVehiclePos(vehicleid, x, y, z) && ((_: oX != 0) || (_: oY != 0) || (_: oZ != 0))) {
- new
- Float: qW,
- Float: qX,
- Float: qY,
- Float: qZ
- ;
- GetVehicleRotationQuat(vehicleid, qW, qX, qY, qZ);
- QuatRotateVector(qW, -qX, -qY, -qZ, oX, oY, oZ, qX, qY, qZ);
- x += qX;
- y += qY;
- z += qZ;
- return true;
- }
- return false;
- }
- stock QuatForwardVector(Float: w, Float: i, Float: j, Float: k, & Float: x, & Float: y, & Float: z) {
- x = 2.0 * (j * i - k * w);
- y = 1.0 - 2.0 * (k * k + i * i);
- z = 2.0 * (i * w + j * k);
- }
- stock GetVehicleForwardVector(vehicleid, & Float: x, & Float: y, & Float: z) {
- if(GetVehicleRotationQuat(vehicleid, Float: vehicleid, x, y, z)) {
- QuatForwardVector(Float: vehicleid, -x, -y, -z, x, y, z);
- return true;
- }
- return false;
- }
- stock QuatRightVector(Float: w, Float: i, Float: j, Float: k, & Float: x, & Float: y, & Float: z) {
- x = 1.0 - 2.0 * (j * j + k * k);
- y = 2.0 * (k * w + i * j);
- z = 2.0 * (i * k - j * w);
- }
- stock GetVehicleRightVector(vehicleid, & Float: x, & Float: y, & Float: z) {
- if(GetVehicleRotationQuat(vehicleid, Float: vehicleid, x, y, z)) {
- QuatRightVector(Float: vehicleid, -x, -y, -z, x, y, z);
- return true;
- }
- return false;
- }
- stock QuatUpVector(Float: w, Float: i, Float: j, Float: k, & Float: x, & Float: y, & Float: z) {
- x = 2.0 * (j * w + k * i);
- y = 2.0 * (k * j - i * w);
- z = 1.0 - 2.0 * (i * i + j * j);
- }
- stock GetVehicleUpVector(vehicleid, & Float: x, & Float: y, & Float: z) {
- if(GetVehicleRotationQuat(vehicleid, Float: vehicleid, x, y, z)) {
- QuatUpVector(Float: vehicleid, -x, -y, -z, x, y, z);
- return true;
- }
- return false;
- }
- stock EulerVectorToQuat(Float: X, Float: Y, Float: Z, Float: angle, & Float: w, & Float: i, & Float: j, & Float: k, anglemode: mode = degrees) {
- if((w = VectorSize(X, Y, Z)) != 1.0) {
- X /= w;
- Y /= w;
- Z /= w;
- }
- angle /= 2.0;
- w = floatsin(angle, mode);
- i = X * w;
- j = Y * w;
- k = Z * w;
- w = floatcos(angle, mode);
- }
- // stock GetEulerFromEuler(Float: oX, Float: oY, Float: oZ, eulermode: omode, & Float: rX, & Float: rY, & Float: rZ, eulermode: mode = euler_samp) {
- // // new Float: matrix[3][3]; //
- // // GetRotationMatrixFromEuler(matrix, oX, oY, oZ, omode);
- // // GetEulerFromMatrix(matrix, rX, rY, rZ, mode);
- // GetQuatFromEuler(oX, oY, oZ, rX, oX, oY, oZ, omode);
- // GetEulerFromQuat(rX, oX, oY, oZ, rX, rY, rZ, mode);
- // #emit retn // tried to unravel these but to much work
- // new
- // Float: cosX = floatcos(oX, degrees),
- // Float: sinY = floatsin(oY, degrees),
- // Float: cosY = floatcos(oY, degrees),
- // Float: cosZ = floatcos(oZ, degrees),
- // Float: sinX = floatsin(oX, degrees),
- // Float: sinZ = floatsin(oZ, degrees);
- // switch(omode) {
- // /*
- // matrix[1][1] = cosX * cosY;
- // matrix[1][2] = -sinX;
- // matrix[2][1] = cosY * sinX;
- // matrix[2][2] = cosX;
- // */
- // case euler_xzx: {
- // switch(mode) {
- // case euler_xzx: {
- // rX = oX;
- // rY = oZ;
- // rZ = oZ;
- // }
- // case euler_xyx: {
- // rX = oX + 90.0;
- // rY = oY;
- // rZ = oZ - 90.0;
- // }
- // case euler_yxy: {
- // rY = cosX * cosY * cosZ - sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = atan2(sinY * sinZ, cosY);
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = -atan2(sinY * sinZ, cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = atan2(-cosZ * sinY, cosX * sinZ + cosY * cosZ * sinX);
- // rY = acos(rY);
- // rZ = atan2(cosX * sinY, cosZ * sinX + cosX * cosY * sinZ);
- // }
- // }
- // case euler_yzy: {
- // rY = cosX * cosY * cosZ - sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = atan2(sinY * sinZ, cosY);
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = atan2(sinY * sinZ, -cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = atan2(cosX * sinZ + cosY * cosZ * sinX, cosZ * sinY);
- // rY = acos(rY);
- // rZ = -atan2(cosZ * sinX + cosX * cosY * sinZ, cosX * sinY);
- // }
- // }
- // case euler_zyz: {
- // rY = cosX * cosZ - cosY * sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = atan2(cosX * sinY, cosY);
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = atan2(cosX * sinY, cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = -atan2(cosZ * sinX + cosX * cosY * sinZ, sinY * sinZ);
- // rY = acos(rY);
- // rZ = atan2(cosX * sinZ + cosY * cosZ * sinX, -sinX * sinY);
- // }
- // }
- // case euler_zxz: {
- // rY = cosX * cosZ - cosY * sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = atan2(cosX * sinY, cosY);
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = atan2(cosX * sinY, cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = atan2(sinY * sinZ, cosZ * sinX + cosX * cosY * sinZ);
- // rY = acos(rY);
- // rZ = atan2(sinX * sinY, cosX * sinZ + cosY * cosZ * sinX);
- // }
- // }
- // case euler_xzy: {
- // rZ = cosZ * sinY;
- // if(rZ > 0.9999) {
- // rX = oX;
- // rY = 0.0;
- // rZ = 90.0;
- // } else if(rZ < -0.9999) {
- // rX = oX;
- // rY = 0.0;
- // rZ = -90.0;
- // } else {
- // rX = atan2(cosX * sinZ + cosY * cosZ * sinX, cosX * cosY * cosZ - sinX * sinZ);
- // rY = atan2(sinY * sinZ, cosY);
- // rZ = asin(rZ);
- // }
- // }
- // case euler_xyz: {
- // rY = sinY * sinZ;
- // if(rY > 0.9999) {
- // rX = 90.0 + oX;
- // rY = 90.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = 90.0 + oX;
- // rY = -90.0;
- // rZ = 0.0;
- // } else {
- // rX = atan2(cosZ * sinX + cosX * cosY * sinZ, cosX * cosZ - cosY * sinX * sinZ);
- // rY = asin(rY);
- // rZ = atan2(cosZ * sinY, cosY);
- // }
- // }
- // case euler_yxz: {
- // rX = cosZ * sinX + cosX * cosY * sinZ;
- // if(rX > 0.9999) {
- // rX = 90.0;
- // rY = -atan2(cosZ * sinY, cosY);
- // rZ = 0.0;
- // } else if(rX < -0.9999) {
- // rX = -90.0;
- // rY = atan2(cosZ * sinY, cosY);
- // rZ = 0.0;
- // } else {
- // rX = asin(rX);
- // rY = atan2(sinY * sinZ, cosX * cosZ - cosY * sinX * sinZ);
- // rZ = atan2(cosX * sinY, cosX * cosY * cosZ - sinX * sinZ);
- // }
- // }
- // case euler_yzx: {
- // rZ = cosX * sinY;
- // if(rZ > 0.9999) {
- // rX = 0.0;
- // rY = oZ;
- // rZ = 90.0;
- // } else if(rZ < -0.9999) {
- // rX = 0.0;
- // rY = 180.0 - oZ;
- // rZ = -90.0;
- // } else {
- // rX = atan2(cosZ * sinX + cosX * cosY * sinZ, cosX * cosY * cosZ - sinX * sinZ);
- // rY = -atan2(sinX * sinY, cosY);
- // rZ = asin(rZ);
- // }
- // }
- // case euler_zyx: {
- // rY = sinX * sinY;
- // if(rY < -0.9999) {
- // rX = 0.0;
- // rY = 90.0;
- // rZ = 90.0 - oZ;
- // } else if(rY > 0.9999) {
- // rX = 0.0;
- // rY = -90.0;
- // rZ = oZ - 90.0;
- // } else {
- // rX = atan2(cosX * sinZ + cosY * cosZ * sinX, cosX * cosZ - cosY * sinX * sinZ);
- // rY = -asin(rY);
- // rZ = atan2(cosX * sinY, cosY);
- // }
- // }
- // case euler_zxy: {
- // rX = cosX * sinZ + cosY * cosZ * sinX;
- // if(rX > 0.9999) {
- // rX = 90.0;
- // rY = 0.0;
- // rZ = atan2(cosX * sinY, cosY);
- // } else if(rX < -0.9999) {
- // rX = -90.0;
- // rY = 0.0;
- // rZ = atan2(cosX * sinY, cosY);
- // } else {
- // rX = asin(rX);
- // rY = -atan2(sinX * sinY, cosX * cosZ - cosY * sinX * sinZ);
- // rZ = atan2(cosZ * sinY, cosX * cosY * cosZ - sinX * sinZ);
- // }
- // }
- // }
- // }
- // /*
- // matrix[1][1] = cosX;
- // matrix[1][2] = - cosY * sinX;
- // matrix[2][1] = sinX;
- // matrix[2][2] = cosX * cosY;
- // */
- // case euler_xyx: {
- // switch(mode) {
- // case euler_xzx: {
- // rX = oX - 90.0;
- // rY = oY;
- // rZ = oZ + 90.0;
- // }
- // case euler_xyx: {
- // rX = oX;
- // rY = oY;
- // rZ = oZ;
- // }
- // case euler_yxy: {
- // rY = cosX * cosZ - cosY * sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = atan2(cosX * sinY, cosY); // -20, 00
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = atan2(cosX * sinY, cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = atan2(sinY * sinZ, cosZ * sinX + cosX * cosY * sinZ);
- // rY = acos(rY);
- // rZ = atan2(sinX * sinY, cosX * sinZ + cosY * cosZ * sinX);
- // }
- // }
- // case euler_yzy: {
- // rY = cosX * cosZ - cosY * sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = atan2(cosX * sinY, cosY); // -20, 00
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = atan2(cosX * sinY, cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = atan2(cosZ * sinX + cosX * cosY * sinZ, -sinY * sinZ);
- // rY = acos(rY);
- // rZ = -atan2(cosX * sinZ + cosY * cosZ * sinX, sinX * sinY);
- // }
- // }
- // case euler_zyz: {
- // rY = cosX * cosY * cosZ - sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = atan2(sinX * sinY, cosY); // -01, 11
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = atan2(sinX * sinY, cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = -atan2(cosX * sinZ + cosY * cosZ * sinX, cosZ * sinY);
- // rY = acos(rY);
- // rZ = atan2(cosZ * sinX + cosX * cosY * sinZ, cosX * sinY);
- // }
- // }
- // case euler_zxz: {
- // rY = cosX * cosY * cosZ - sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = atan2(sinX * sinY, cosY); // -01, 11
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = atan2(sinX * sinY, cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = atan2(cosZ * sinY, cosX * sinZ + cosY * cosZ * sinX);
- // rY = acos(rY);
- // rZ = -atan2(cosX * sinY, cosZ * sinX + cosX * cosY * sinZ);
- // }
- // }
- // case euler_xzy: {
- // rZ = sinY * sinZ;
- // if(rZ < -0.9999) {
- // rX = oX - 90.0; // -12, 22
- // rY = 0.0;
- // rZ = 90.0;
- // } else if(rZ > 0.9999) {
- // rX = oX - 90.0;
- // rY = 0.0;
- // rZ = -90.0;
- // } else {
- // rX = atan2(cosZ * sinX + cosX * cosY * sinZ, cosX * cosZ - cosY * sinX * sinZ);
- // rY = atan2(cosZ * sinY, cosY);
- // rZ = -asin(rZ);
- // }
- // }
- // case euler_xyz: {
- // rY = cosZ * sinY;
- // if(rY > 0.9999) {
- // rX = oX; // 10, -20
- // rY = 90.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = oX;
- // rY = -90.0;
- // rZ = 0.0;
- // } else {
- // rX = atan2(cosX * sinZ + cosY * cosZ * sinX, cosX * cosY * cosZ - sinX * sinZ);
- // rY = asin(rY);
- // rZ = -atan2(sinY * sinZ, cosY);
- // }
- // }
- // case euler_yxz: {
- // rX = cosX * sinZ + cosY * cosZ * sinX;
- // if(rX > 0.9999) {
- // rX = 90.0;
- // rY = atan2(cosX * sinY, cosY); // -20, 00
- // rZ = 0.0;
- // } else if(rX < -0.9999) {
- // rX = -90.0;
- // rY = atan2(cosX * sinY, cosY);
- // rZ = 0.0;
- // } else {
- // rX = asin(rX);
- // rY = atan2(cosZ * sinY, cosX * cosY * cosZ - sinX * sinZ);
- // rZ = atan2(sinX * sinY, cosX * cosZ - cosY * sinX * sinZ);
- // }
- // }
- // case euler_yzx: {
- // rZ = sinX * sinY;
- // if(rZ > 0.9999) {
- // rX = 0.0;
- // rY = 90.0 + oZ; // 21, -01
- // rZ = 90.0;
- // } else if(rZ < -0.9999) {
- // rX = 0.0;
- // rY = 90.0 - oZ;
- // rZ = -90.0;
- // } else {
- // rX = atan2(cosX * sinZ + cosY * cosZ * sinX, cosX * cosZ - cosY * sinX * sinZ);
- // rY = atan2(cosX * sinY, cosY);
- // rZ = asin(rZ);
- // }
- // }
- // case euler_zyx: { // pitch roll yaw
- // rY = cosX * sinY;
- // if(rY > 0.9999) {
- // rX = 0.0;
- // rY = 90.0;
- // rZ = -oZ; // -01, 11
- // } else if(rY < -0.9999) {
- // rX = 0.0;
- // rY = -90.0;
- // rZ = oZ;
- // } else {
- // rX = atan2(cosZ * sinX + cosX * cosY * sinZ, cosX * cosY * cosZ - sinX * sinZ);
- // rY = asin(rY);
- // rZ = atan2(sinX * sinY, cosY);
- // }
- // }
- // case euler_zxy: { // sa-mp
- // rX = cosZ * sinX + cosX * cosY * sinZ;
- // if(rX > 0.9999) {
- // rX = 90.0;
- // rY = 0.0;
- // rZ = atan2(sinX * sinY, cosY); // 02, -12
- // } else if(rX < -0.9999) {
- // rX = -90.0;
- // rY = 0.0;
- // rZ = atan2(sinX * sinY, cosY);
- // } else {
- // rX = asin(rX);
- // rY = atan2(cosX * sinY, cosX * cosY * cosZ - sinX * sinZ);
- // rZ = -atan2(sinY * sinZ, cosX * cosZ - cosY * sinX * sinZ);
- // }
- // }
- // }
- // }
- // /*
- // matrix[0][0] = cosX;
- // matrix[0][2] = cosY * sinX;
- // matrix[2][0] = -sinX;
- // matrix[2][2] = cosX * cosY;
- // */
- // case euler_yxy: {
- // switch(mode) {
- // case euler_xzx: {
- // rY = cosX * cosZ - cosY * sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = atan2(cosX * sinY, cosY); // -12, 22
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = atan2(cosX * sinY, cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = -atan2(cosZ * sinX + cosX * cosY * sinZ, sinY * sinZ);
- // rY = acos(rY);
- // rZ = atan2(cosX * sinZ + cosY * cosZ * sinX, -sinX * sinY);
- // }
- // }
- // case euler_xyx: {
- // rY = cosX * cosZ - cosY * sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = atan2(cosX * sinY, cosY); // -12, 22
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = atan2(cosX * sinY, cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = atan2(sinY * sinZ, cosZ * sinX + cosX * cosY * sinZ);
- // rY = acos(rY);
- // rZ = atan2(sinX * sinY, cosX * sinZ + cosY * cosZ * sinX);
- // }
- // }
- // case euler_yxy: {
- // rX = oX;
- // rY = oY;
- // rZ = oZ;
- // }
- // case euler_yzy: {
- // rX = oX + 90.0;
- // rY = oY;
- // rZ = oZ - 90.0;
- // }
- // case euler_zyz: {
- // rY = cosX * cosY * cosZ - sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = -atan2(sinX * sinY, cosY); // -01, 11
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = -atan2(sinX * sinY, cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = -atan2(cosZ * sinY, cosX * sinZ + cosY * cosZ * sinX);
- // rY = acos(rY);
- // rZ = atan2(cosX * sinY, cosZ * sinX + cosX * cosY * sinZ);
- // }
- // }
- // case euler_zxz: {
- // rY = cosX * cosY * cosZ - sinX * sinZ;
- // if(rY > 0.9999) {
- // rX = -atan2(sinX * sinY, cosY); // -01, 11
- // rY = 0.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = -atan2(sinX * sinY, cosY);
- // rY = 180.0;
- // rZ = 0.0;
- // } else {
- // rX = atan2(cosX * sinZ + cosY * cosZ * sinX, cosZ * sinY);
- // rY = acos(rY);
- // rZ = -atan2(cosZ * sinX + cosX * cosY * sinZ, cosX * sinY);
- // }
- // }
- // case euler_xzy: {
- // rZ = sinX * sinY;
- // if(rZ < -0.9999) {
- // rX = 90.0 - oZ; // -12, 22
- // rY = 0.0;
- // rZ = 90.0;
- // } else if(rZ > 0.9999) {
- // rX = 90.0 + oZ;
- // rY = 0.0;
- // rZ = -90.0;
- // } else {
- // rX = atan2(cosX * sinY, cosY);
- // rY = atan2(cosX * sinZ + cosY * cosZ * sinX, cosX * cosZ - cosY * sinX * sinZ);
- // rZ = -asin(rZ);
- // }
- // }
- // case euler_xyz: {
- // rY = cosX * sinZ + cosY * cosZ * sinX;
- // if(rY > 0.9999) {
- // rX = atan2(cosX * sinY, cosY); // 10, -20
- // rY = 90.0;
- // rZ = 0.0;
- // } else if(rY < -0.9999) {
- // rX = atan2(cosX * sinY, cosY);
- // rY = -90.0;
- // rZ = 0.0;
- // } else {
- // rX = atan2(cosZ * sinY, cosX * cosY * cosZ - sinX * sinZ);
- // rY = asin(rY);
- // rZ = -atan2(sinX * sinY, cosX * cosZ - cosY * sinX * sinZ);
- // }
- // }
- // case euler_yxz: {
- // rX = cosZ * sinY;
- // if(rX > 0.9999) {
- // rX = 90.0;
- // rY = oX; // -20, 00
- // rZ = 0.0;
- // } else if(rX < -0.9999) {
- // rX = -90.0;
- // rY = oX;
- // rZ = 0.0;
- // } else {
- // rX = asin(rX);
- // rY = atan2(cosX * sinZ + cosY * cosZ * sinX, cosX * cosY * cosZ - sinX * sinZ);
- // rZ = atan2(sinY * sinZ, cosY);
- // }
- // }
- // case euler_yzx: {
- // rZ = sinY * sinZ;
- // if(rZ > 0.9999) {
- // rX = 0.0;
- // rY = 90.0 + oX; // 21, -01
- // rZ = 90.0;
- // } else if(rZ < -0.9999) {
- // rX = 0.0;
- // rY = 90.0 + oX;
- // rZ = -90.0;
- // } else {
- // rX = atan2(cosZ * sinY, cosY);
- // rY = atan2(cosZ * sinX + cosX * cosY * sinZ, cosX * cosZ - cosY * sinX * sinZ);
- // rZ = asin(rZ);
- // }
- // }
- // case euler_zyx: { // pitch roll yaw
- // rY = cosZ * sinX + cosX * cosY * sinZ;
- // if(rY > 0.9999) {
- // rX = 0.0;
- // rY = 90.0;
- // rZ = -atan2(sinX * sinY, cosY); // -01, 11
- // } else if(rY < -0.9999) {
- // rX = 0.0;
- // rY = -90.0;
- // rZ = -atan2(sinX * sinY, cosY);
- // } else {
- // rX = atan2(cosX * sinY, cosX * cosY * cosZ - sinX * sinZ);
- // rY = asin(rY);
- // rZ = atan2(sinY * sinZ, cosX * cosZ - cosY * sinX * sinZ);
- // }
- // }
- // case euler_zxy: { // sa-mp
- // rX = cosX * sinY;
- // if(rX > 0.9999) {
- // rX = 90.0;
- // rY = 0.0;
- // rZ = oZ; // 02, -12
- // } else if(rX < -0.9999) {
- // rX = -90.0;
- // rY = 0.0;
- // rZ = 180.0 - oZ;
- // } else {
- // rX = asin(rX);
- // rY = atan2(cosZ * sinX + cosX * cosY * sinZ, cosX * cosY * cosZ - sinX * sinZ);
- // rZ = -atan2(sinX * sinY, cosY);
- // }
- // }
- // }
- // }
- // /*
- // matrix[0][0] = cosX * cosY * cosZ - sinX * sinZ;
- // matrix[0][1] = -cosX * sinY;
- // matrix[0][2] = cosZ * sinX + cosX * cosY * sinZ;
- // matrix[1][0] = cosZ * sinY;
- // matrix[1][1] = cosY;
- // matrix[1][2] = sinY * sinZ;
- // matrix[2][0] = -cosX * sinZ - cosY * cosZ * sinX;
- // matrix[2][1] = sinX * sinY;
- // matrix[2][2] = cosX * cosZ - cosY * sinX * sinZ;
- // rZ = 0 rY = 0 / 180
- // matrix[0][0] = cosX * cosY;
- // matrix[0][2] = sinX;
- // matrix[2][0] = - cosY * sinX;
- // matrix[2][2] = cosX;
- // */
- // case euler_yzy: {
- // switch(mode) {
- // case euler_xzx: {}
- // case euler_xyx: {}
- // case euler_yxy: {}
- // case euler_yzy: {
- // rX = oX;
- // rY = oZ;
- // rZ = oZ;
- // }
- // case euler_zyz: {}
- // case euler_zxz: {}
- // case euler_xzy: {}
- // case euler_xyz: {}
- // case euler_yxz: {}
- // case euler_yzx: {}
- // case euler_zyx: {}
- // case euler_zxy: {}
- // }
- // }
- // /*
- // matrix[0][0] = cosX * cosY * cosZ - sinX * sinZ;
- // matrix[0][1] = -cosZ * sinX - cosX * cosY * sinZ;
- // matrix[0][2] = cosX * sinY;
- // matrix[1][0] = cosX * sinZ + cosY * cosZ * sinX;
- // matrix[1][1] = cosX * cosZ - cosY * sinX * sinZ;
- // matrix[1][2] = sinX * sinY;
- // matrix[2][0] = -cosZ * sinY;
- // matrix[2][1] = sinY * sinZ;
- // matrix[2][2] = cosY;
- // rZ = 0 rY = 0 / 180
- // matrix[0][0] = cosX * cosY;
- // matrix[0][1] = -sinX;
- // matrix[1][0] = cosY * sinX;
- // matrix[1][1] = cosX;
- // */
- // case euler_zyz: {
- // switch(mode) {
- // case euler_xzx: {}
- // case euler_xyx: {}
- // case euler_yxy: {}
- // case euler_yzy: {}
- // case euler_zyz: {
- // rX = oX;
- // rY = oZ;
- // rZ = oZ;
- // }
- // case euler_zxz: {}
- // case euler_xzy: {}
- // case euler_xyz: {}
- // case euler_yxz: {}
- // case euler_yzx: {}
- // case euler_zyx: {}
- // case euler_zxy: {}
- // }
- // }
- // /*
- // matrix[0][0] = cosX * cosZ - cosY * sinX * sinZ;
- // matrix[0][1] = -cosX * sinZ - cosY * cosZ * sinX;
- // matrix[0][2] = sinX * sinY;
- // matrix[1][0] = cosZ * sinX + cosX * cosY * sinZ;
- // matrix[1][1] = cosX * cosY * cosZ - sinX * sinZ;
- // matrix[1][2] = -cosX * sinY;
- // matrix[2][0] = sinY * sinZ;
- // matrix[2][1] = cosZ * sinY;
- // matrix[2][2] = cosY;
- // rZ = 0.0 rY = 0 / 180
- // matrix[0][0] = cosX;
- // matrix[0][1] = -cosY * sinX;
- // matrix[1][0] = sinX;
- // matrix[1][1] = cosX * cosY;
- // */
- // case euler_zxz: {
- // switch(mode) {
- // case euler_xzx: {}
- // case euler_xyx: {}
- // case euler_yxy: {}
- // case euler_yzy: {}
- // case euler_zyz: {}
- // case euler_zxz: {
- // rX = oX;
- // rY = oZ;
- // rZ = oZ;
- // }
- // case euler_xzy: {}
- // case euler_xyz: {}
- // case euler_yxz: {}
- // case euler_yzx: {}
- // case euler_zyx: {}
- // case euler_zxy: {}
- // }
- // }
- // /*
- // matrix[0][0] = cosZ * cosY;
- // matrix[0][1] = -sinZ;
- // matrix[0][2] = cosZ * sinY;
- // matrix[1][0] = sinX * sinY + cosX * cosY * sinZ;
- // matrix[1][1] = cosX * cosZ;
- // matrix[1][2] = cosX * sinZ * sinY - cosY * sinX;
- // matrix[2][0] = cosY * sinX * sinZ - cosX * sinY;
- // matrix[2][1] = cosZ * sinX;
- // matrix[2][2] = cosX * cosY + sinX * sinZ * sinY;
- // rY = 0 rZ = 90 / -90
- // matrix[1][0] = cosX * sinZ;
- // matrix[1][2] = -sinX;
- // matrix[2][0] = sinX * sinZ;
- // matrix[2][2] = cosX;
- // */
- // case euler_xzy: {
- // switch(mode) {
- // case euler_xzx: {}
- // case euler_xyx: {}
- // case euler_yxy: {}
- // case euler_yzy: {}
- // case euler_zyz: {}
- // case euler_zxz: {}
- // case euler_xzy: {
- // rX = oX;
- // rY = oZ;
- // rZ = oZ;
- // }
- // case euler_xyz: {}
- // case euler_yxz: {}
- // case euler_yzx: {}
- // case euler_zyx: {}
- // case euler_zxy: {}
- // }
- // }
- // /*
- // matrix[0][0] = cosY * cosZ;
- // matrix[0][1] = -cosY * sinZ;
- // matrix[0][2] = sinY;
- // matrix[1][0] = cosX * sinZ + cosZ * sinX * sinY;
- // matrix[1][1] = cosX * cosZ - sinX * sinY * sinZ;
- // matrix[1][2] = -cosY * sinX;
- // matrix[2][0] = sinX * sinZ - cosX * cosZ * sinY;
- // matrix[2][1] = cosZ * sinX + cosX * sinY * sinZ;
- // matrix[2][2] = cosX * cosY;
- // rZ = 0 rY = 90 / -90
- // matrix[1][0] = sinX * sinY;
- // matrix[1][1] = cosX;
- // matrix[2][0] = -cosX * sinY;
- // matrix[2][1] = sinX;
- // */
- // case euler_xyz: {
- // switch(mode) {
- // case euler_xzx: {}
- // case euler_xyx: {}
- // case euler_yxy: {}
- // case euler_yzy: {}
- // case euler_zyz: {}
- // case euler_zxz: {}
- // case euler_xzy: {}
- // case euler_xyz: {
- // rX = oX;
- // rY = oZ;
- // rZ = oZ;
- // }
- // case euler_yxz: {}
- // case euler_yzx: {}
- // case euler_zyx: {}
- // case euler_zxy: {}
- // }
- // }
- // /*
- // matrix[0][0] = cosY * cosZ + sinY * sinX * sinZ;
- // matrix[0][1] = cosZ * sinY * sinX - cosY * sinZ;
- // matrix[0][2] = cosX * sinY;
- // matrix[1][0] = cosX * sinZ;
- // matrix[1][1] = cosX * cosZ;
- // matrix[1][2] = -sinX;
- // matrix[2][0] = cosY * sinX * sinZ - cosZ * sinY;
- // matrix[2][1] = cosY * cosZ * sinX + sinY * sinZ;
- // matrix[2][2] = cosY * cosX;
- // rZ = 0 rX = 90 / -90
- // matrix[0][0] = cosY;
- // matrix[0][1] = sinY * sinX;
- // matrix[2][0] = -sinY;
- // matrix[2][1] = cosY * sinX;
- // */
- // case euler_yxz: {
- // switch(mode) {
- // case euler_xzx: {}
- // case euler_xyx: {}
- // case euler_yxy: {}
- // case euler_yzy: {}
- // case euler_zyz: {}
- // case euler_zxz: {}
- // case euler_xzy: {}
- // case euler_xyz: {}
- // case euler_yxz: {
- // rX = oX;
- // rY = oZ;
- // rZ = oZ;
- // }
- // case euler_yzx: {}
- // case euler_zyx: {}
- // case euler_zxy: {}
- // }
- // }
- // /*
- // matrix[0][0] = cosY * cosZ;
- // matrix[0][1] = sinY * sinX - cosY * cosX * sinZ;
- // matrix[0][2] = cosX * sinY + cosY * sinZ * sinX;
- // matrix[1][0] = sinZ;
- // matrix[1][1] = cosZ * cosX;
- // matrix[1][2] = -cosZ * sinX;
- // matrix[2][0] = -cosZ * sinY;
- // matrix[2][1] = cosY * sinX + cosX * sinY * sinZ;
- // matrix[2][2] = cosY * cosX - sinY * sinZ * sinX;
- // rX = 0 rZ = 90 / -90
- // matrix[0][1] = -cosY * sinZ;
- // matrix[0][2] = sinY;
- // matrix[2][1] = sinY * sinZ;
- // matrix[2][2] = cosY;
- // */
- // case euler_yzx: {
- // switch(mode) {
- // case euler_xzx: {}
- // case euler_xyx: {}
- // case euler_yxy: {}
- // case euler_yzy: {}
- // case euler_zyz: {}
- // case euler_zxz: {}
- // case euler_xzy: {}
- // case euler_xyz: {}
- // case euler_yxz: {}
- // case euler_yzx: {
- // rX = oX;
- // rY = oZ;
- // rZ = oZ;
- // }
- // case euler_zyx: {}
- // case euler_zxy: {}
- // }
- // }
- // /*
- // matrix[0][0] = cosZ * cosY;
- // matrix[0][1] = cosZ * sinY * sinX - cosX * sinZ;
- // matrix[0][2] = sinZ * sinX + cosZ * cosX * sinY;
- // matrix[1][0] = cosY * sinZ;
- // matrix[1][1] = cosZ * cosX + sinZ * sinY * sinX;
- // matrix[1][2] = cosX * sinZ * sinY - cosZ * sinX;
- // matrix[2][0] = -sinY;
- // matrix[2][1] = cosY * sinX;
- // matrix[2][2] = cosY * cosX;
- // rX = 0 rY = 90 / -90
- // matrix[0][1] = -sinZ;
- // matrix[0][2] = cosZ * sinY;
- // matrix[1][1] = cosZ;
- // matrix[1][2] = sinZ * sinY;
- // */
- // case euler_zyx: { // pitch roll yaw
- // switch(mode) {
- // case euler_xzx: {}
- // case euler_xyx: {}
- // case euler_yxy: {}
- // case euler_yzy: {}
- // case euler_zyz: {}
- // case euler_zxz: {}
- // case euler_xzy: {}
- // case euler_xyz: {}
- // case euler_yxz: {}
- // case euler_yzx: {}
- // case euler_zyx: { // pitch roll yaw
- // rX = oX;
- // rY = oZ;
- // rZ = oZ;
- // }
- // case euler_zxy: { // sa-mp
- // rX = cosY * sinX;
- // if(rX > 0.9999) {
- // rX = 90.0;
- // rY = 0.0;
- // rZ = oZ;
- // } else if(rX < -0.9999) {
- // rX = -90.0;
- // rY = 0.0;
- // rZ = oZ;
- // } else {
- // rX = asin(rX);
- // rY = atan2(sinY, cosY * cosX);
- // rZ = atan2(cosX * sinZ - cosZ * sinY * sinX, cosZ * cosX + sinZ * sinY * sinX);
- // }
- // }
- // }
- // }
- // /*
- // matrix[0][0] = cosZ * cosY - sinZ * sinX * sinY;
- // matrix[0][1] = -sinZ * cosX;
- // matrix[0][2] = cosZ * sinY + sinZ * sinX * cosY;
- // matrix[1][0] = sinZ * cosY + cosZ * sinX * sinY;
- // matrix[1][1] = cosZ * cosX;
- // matrix[1][2] = sinZ * sinY - cosZ * sinX * cosY;
- // matrix[2][0] = -cosX * sinY;
- // matrix[2][1] = sinX;
- // matrix[2][2] = cosX * cosY;
- // rY = 0 rX = 90 / -90
- // matrix[0][0] = cosZ;
- // matrix[0][2] = sinZ * sinX;
- // matrix[1][0] = sinZ ;
- // matrix[1][2] = -cosZ * sinX;
- // */
- // case euler_zxy: { // sa-mp
- // switch(mode) {
- // case euler_xzx: {}
- // case euler_xyx: {}
- // case euler_yxy: {}
- // case euler_yzy: {}
- // case euler_zyz: {}
- // case euler_zxz: {}
- // case euler_xzy: {}
- // case euler_xyz: {}
- // case euler_yxz: {}
- // case euler_yzx: {}
- // case euler_zyx: { // pitch roll yaw
- // rY = cosX * sinY;
- // if(rY < -0.9999) {
- // rX = 0.0;
- // rY = 90.0;
- // rZ = oZ;
- // } else if(rY > 0.9999) {
- // rX = 0.0;
- // rY = -90.0;
- // rZ = oZ;
- // } else {
- // rX = atan2(sinX, cosX * cosY);
- // rY = asin(rY);
- // rZ = atan2(sinZ * cosY + cosZ * sinX * sinY, cosZ * cosY - sinZ * sinX * sinY);
- // }
- // }
- // case euler_zxy: { // sa-mp
- // rX = oX;
- // rY = oZ;
- // rZ = oZ;
- // }
- // }
- // }
- // }
- // }
|