int main (){ double angle = 0.1; double line[3] = {1,0,0}; double u[4] = {1,0,0,0}, v[4] = {0,1,0,0}; double rot3D[3][3], rot4D[4][4]; int row, col; printf("Enter 3D vector to rotate about: "); scanf("%lf%lf%lf", &line[0], &line[1], &line[2]); printf("Enter angle to rotate through (in radians): "); scanf("%lf", &angle); Rotate3D(line,angle,rot3D); printf("Rotation matrix is:\n"); for (row = 0; row < 3; row++) { for (col = 0; col < 3; col++) printf("% f ", rot3D[row][col]); printf("\n"); } printf("\n"); Rotate4D(u,v,angle,rot4D); for (row = 0; row < 4; row++) { for (col = 0; col < 4; col++) printf("% f ", rot4D[row][col]); printf("\n"); } return 0; }
void PrepareInvMatrix(float Tx, float Ty, float Tz, float Sx, float Sy, float Sz, float Rx, float Ry, float Rz, Matx4x4 XForm) { Matx4x4 M1, M2, M3, M4, M5, M6, M7, M8, M9; Scale3D(Sx, Sy, Sz, M1); Rotate3D(1, Rx, M2); Rotate3D(2, Ry, M3); Rotate3D(3, Rz, M4); Translate3D(Tx, Ty, Tz, M5); Multiply3DMatricies(M4, M5, M6); Multiply3DMatricies(M3, M6, M7); Multiply3DMatricies(M2, M7, M8); Multiply3DMatricies(M1, M8, M9); MatCopy(M9, XForm); }
void AnimationEffectBurst::FlingRadial(float pRadialDegrees, float pSpeed) { FVec3 aPushSpeed = FVec3(Sin(pRadialDegrees), 0.0f, Cos(pRadialDegrees)); FVec3 aRotationAxis = FVec3(0.0f, 0.0f, 1.0f); aPushSpeed = Rotate3D(aPushSpeed, aRotationAxis, (180.0f - mOrbit)); aPushSpeed *= pSpeed; mVel += aPushSpeed; }
std::vector<PointDD*>ProjectionComplexDD::Projection(ObjectTD* pObjectTD, CameraDD* pCamera) { std::vector<PointDD*>result; float fX = pCamera->iXShift; float fY = pCamera->iYShift; float fZ = pCamera->iZShift; if (this->Par.iProjStyle == PROJ_NONE) { for (unsigned int i = 0; i < pObjectTD->pPointsTD.size(); i++) { PointDD* pPointDD = Rotate3D(*pObjectTD->pPointsTD[i]); result.push_back(pPointDD); } } if (this->Par.iProjStyle == PROJ_LINES || this->Par.iProjStyle == PROJ_LINES_NIGGA) { for (unsigned int i = 0; i < pObjectTD->pPointsTD.size(); i++) { if (pObjectTD->pPointsTD[i]->iType != TYPE_TEXT) { PointDD* pPointTDXZ = Rotate3D(*pObjectTD->pPointsTD[i], QXZ); PointDD* pPointTDZY = Rotate3D(*pObjectTD->pPointsTD[i], QYZ); PointDD* pPointTDYY = Rotate3D(*pObjectTD->pPointsTD[i], QYY); PointDD* pPointTDXY = Rotate3D(*pObjectTD->pPointsTD[i], QXY); // Lines PointDD* pPointDDXZ = new PointDD(*pPointTDXZ); PointDD* pPointDDZY = new PointDD(*pPointTDZY); PointDD* pPointDDYY0 = new PointDD(*pPointTDYY); PointDD* pPointDDXY = new PointDD(*pPointTDXY); PointDD* pPointDDXZ0 = new PointDD(*pPointTDXZ); PointDD* pPointDDXZ1 = new PointDD(*pPointTDXZ); PointDD* pPointDDZY1 = new PointDD(*pPointTDZY); PointDD* pPointDDXY1 = new PointDD(*pPointTDXY); pPointDDXZ1->fX = 0; pPointDDZY1->fY = 0; pPointDDXY1->fY = 0; pPointDDXZ->SetSettings(ACT_MOVE, TYPE_OBJECT, ""); pPointDDXZ1->SetSettings(ACT_DRAW, TYPE_OBJECT, ""); pPointDDZY->SetSettings(ACT_DRAW, TYPE_OBJECT, ""); pPointDDZY1->SetSettings(ACT_DRAW, TYPE_OBJECT, ""); pPointDDYY0->SetSettings(ACT_ARC, TYPE_OBJECT, ""); pPointDDXY->SetSettings(ACT_DRAW, TYPE_OBJECT, ""); pPointDDXY1->SetSettings(ACT_DRAW, TYPE_OBJECT, ""); pPointDDXZ0->SetSettings(ACT_DRAW, TYPE_OBJECT, ""); pPointDDYY0->fX = 0; result.push_back(pPointDDXZ); result.push_back(pPointDDXZ1); result.push_back(pPointDDZY); result.push_back(pPointDDZY1); result.push_back(pPointDDYY0); result.push_back(pPointDDXY); result.push_back(pPointDDXY1); result.push_back(pPointDDXZ0); // result.push_back(pPointDDXY0); // result.push_back(pPointDDXY1); // result.push_back(pPointDDYY1); // result.push_back(pPointDDYY1); // result.push_back(pPointDDZY); /* result.push_back(pPointDDXY); result.push_back(pPointDDXY1); result.push_back(pPointDDXZ); */ // Dots /* PointDD* pPointDDXZ2 = new PointDD(*pPointTDXZ); PointDD* pPointDDXY2 = new PointDD(*pPointTDXY); PointDD* pPointDDYY2 = new PointDD(*pPointTDYY); PointDD* pPointDDYZ2 = new PointDD(*pPointTDYZ); pPointDDXZ2->fY = 0; pPointDDXY2->fX = 0; pPointDDYY2->fY = 0; pPointDDYZ2->fX = 0; result.push_back(pPointDDXZ2); result.push_back(pPointDDXY2); result.push_back(pPointDDYY2); result.push_back(pPointDDYZ2); */ } } } for (unsigned int i = 0; i < pObjectTD->pPointsTD.size(); i++) { if (this->Par.iProjStyle == PROJ_DOTS) { // if (pObjectTD->pPointsTD[i]->iType != TYPE_TEXT) { PointDD* pPointDDXZ = Rotate3D(*pObjectTD->pPointsTD[i], QXZ); PointDD* pPointDDXY = Rotate3D(*pObjectTD->pPointsTD[i], QXY); PointDD* pPointDDYY = Rotate3D(*pObjectTD->pPointsTD[i], QYY); PointDD* pPointDDYZ = Rotate3D(*pObjectTD->pPointsTD[i], QYZ); // Dots PointDD* pPointDDXZ2 = new PointDD(*pPointDDXZ); PointDD* pPointDDXY2 = new PointDD(*pPointDDXY); PointDD* pPointDDYY2 = new PointDD(*pPointDDYY); PointDD* pPointDDYZ2 = new PointDD(*pPointDDYZ); pPointDDXZ2->fY = 0; pPointDDXY2->fX = 0; pPointDDYY2->fY = 0; pPointDDYZ2->fX = 0; pPointDDXZ2->sText += "X"; pPointDDXY2->sText += "Y1"; pPointDDYY2->sText += "Y2"; pPointDDYZ2->sText += "Z"; result.push_back(pPointDDXZ); result.push_back(pPointDDXY); result.push_back(pPointDDYZ); pPointDDXZ->sText += "2"; pPointDDXY->sText += "1"; pPointDDYZ->sText += "3"; result.push_back(pPointDDXZ2); result.push_back(pPointDDXY2); result.push_back(pPointDDYY2); result.push_back(pPointDDYZ2); } } AddShift(result, fX, fY, fZ); return result; };
std::vector<PointDD*>ProjectionOrtoDD::Projection(ObjectTD* pObjectTD, CameraTD* pCamera) { std::vector<PointDD*>result; float fX = pCamera->iXShift; float fY = pCamera->iYShift; float fZ = pCamera->iZShift; if (Par.iProjStyle == PROJ_NONE) { for (unsigned int i = 0; i < pObjectTD->pPointsTD.size(); i++) { PointTD* pPoint = pObjectTD->pPointsTD[i]; // PointTD* pPointTD = Rotate3D(*pObjectTD->pPointsTD[i], fP, fR, // fW, fA); PointTD* pPointTD = CreatePointTD(pPoint, ACT_NONE, pPoint->fX, pPoint->fY, pPoint->fZ); // PointDD* pPointDD = static_cast<PointDD*>(pPointTD); PointDD* pPointDD = static_cast<PointDD*>(Rotate3D(*pPointTD, pCamera)); result.push_back(pPointDD); } } if (Par.iProjStyle == PROJ_LINES || Par.iProjStyle == PROJ_LINES_NIGGA) { for (unsigned int i = 0; i < pObjectTD->pPointsTD.size(); i++) { if (pObjectTD->pPointsTD[i]->iType != TYPE_TEXT) { if ((Par.iProjStyle == PROJ_LINES && pObjectTD->pPointsTD[i]->fX >= 0 && pObjectTD->pPointsTD[i]->fY >= 0 && pObjectTD->pPointsTD[i]->fZ >= 0) || (Par.iProjStyle == PROJ_LINES_NIGGA && (pObjectTD->pPointsTD[i]->fX <= 0 || pObjectTD->pPointsTD[i]->fY <= 0 || pObjectTD->pPointsTD[i]->fZ <= 0))) { PointTD* pPoint = pObjectTD->pPointsTD[i]; PointTD* pPointTD = CreatePointTD(pPoint, ACT_MOVE, pPoint->fX, pPoint->fY, pPoint->fZ); PointTD* pPointTDXY = CreatePointTD(pPoint, ACT_DRAW, 1, 1, 0); PointTD* pPointTDXZ = CreatePointTD(pPoint, ACT_DRAW, 1, 0, 1); PointTD* pPointTDZY = CreatePointTD(pPoint, ACT_DRAW, 0, 1, 1); PointTD* pPointTDXYX = CreatePointTD(pPoint, ACT_DRAW, 0, 1, 0); PointTD* pPointTDXYY = CreatePointTD(pPoint, ACT_DRAW, 1, 0, 0); PointTD* pPointTDXZX = CreatePointTD(pPoint, ACT_DRAW, 0, 0, 1); PointTD* pPointTDXZZ = CreatePointTD(pPoint, ACT_DRAW, 1, 0, 0); PointTD* pPointTDZYZ = CreatePointTD(pPoint, ACT_DRAW, 0, 1, 0); PointTD* pPointTDZYY = CreatePointTD(pPoint, ACT_DRAW, 0, 0, 1); PointDD* pPointDD = static_cast<PointDD*>(Rotate3D(*pPointTD, pCamera)); PointDD* pPointDDXY = static_cast<PointDD*>(Rotate3D(*pPointTDXY, pCamera)); PointDD* pPointDDXZ = static_cast<PointDD*>(Rotate3D(*pPointTDXZ, pCamera)); PointDD* pPointDDZY = static_cast<PointDD*>(Rotate3D(*pPointTDZY, pCamera)); PointDD* pPointDDXYX = static_cast<PointDD*>(Rotate3D(*pPointTDXYX, pCamera)); PointDD* pPointDDXYY = static_cast<PointDD*>(Rotate3D(*pPointTDXYY, pCamera)); PointDD* pPointDDXZX = static_cast<PointDD*>(Rotate3D(*pPointTDXZX, pCamera)); PointDD* pPointDDXZZ = static_cast<PointDD*>(Rotate3D(*pPointTDXZZ, pCamera)); PointDD* pPointDDZYZ = static_cast<PointDD*>(Rotate3D(*pPointTDZYZ, pCamera)); PointDD* pPointDDZYY = static_cast<PointDD*>(Rotate3D(*pPointTDZYY, pCamera)); result.push_back(pPointDD); result.push_back(pPointDDXY); result.push_back(pPointDDXYX); result.push_back(pPointDDXY); result.push_back(pPointDDXYY); result.push_back(pPointDD); result.push_back(pPointDDXZ); result.push_back(pPointDDXZX); result.push_back(pPointDDXZ); result.push_back(pPointDDXZZ); result.push_back(pPointDD); result.push_back(pPointDDZY); result.push_back(pPointDDZYZ); result.push_back(pPointDDZY); result.push_back(pPointDDZYY); } } } } if (Par.iProjStyle == PROJ_DOTS || Par.iProjStyle == PROJ_DOTS_NIGGA) { for (unsigned int i = 0; i < pObjectTD->pPointsTD.size(); i++) { if ((Par.iProjStyle == PROJ_DOTS && pObjectTD->pPointsTD[i]->fX >= 0 && pObjectTD->pPointsTD[i]->fY >= 0 && pObjectTD->pPointsTD[i]->fZ >= 0) || (Par.iProjStyle == PROJ_DOTS_NIGGA && (pObjectTD->pPointsTD[i]->fX <= 0 || pObjectTD->pPointsTD[i]->fY <= 0 || pObjectTD->pPointsTD[i]->fZ <= 0))) { PointTD* pPoint = pObjectTD->pPointsTD[i]; PointTD* pPointTDXZ = CreatePointTD(pPoint, ACT_NONE, 1, 0, 1); PointTD* pPointTDXY = CreatePointTD(pPoint, ACT_NONE, 1, 1, 0); PointTD* pPointTDZY = CreatePointTD(pPoint, ACT_NONE, 0, 1, 1); PointTD* pPointTDX = CreatePointTD(pPoint, ACT_NONE, 1, 0, 0); PointTD* pPointTDY = CreatePointTD(pPoint, ACT_NONE, 0, 1, 0); PointTD* pPointTDZ = CreatePointTD(pPoint, ACT_NONE, 0, 0, 1); pPointTDXZ->sText += "2"; pPointTDXY->sText += "1"; pPointTDZY->sText += "3"; pPointTDX->sText += "X"; pPointTDY->sText += "Y"; pPointTDZ->sText += "Z"; PointDD* pPointDDXZ = static_cast<PointDD*>(Rotate3D(*pPointTDXZ, pCamera)); PointDD* pPointDDXY = static_cast<PointDD*>(Rotate3D(*pPointTDXY, pCamera)); PointDD* pPointDDZY = static_cast<PointDD*>(Rotate3D(*pPointTDZY, pCamera)); PointDD* pPointDDX = static_cast<PointDD*>(Rotate3D(*pPointTDX, pCamera)); PointDD* pPointDDY = static_cast<PointDD*>(Rotate3D(*pPointTDY, pCamera)); PointDD* pPointDDZ = static_cast<PointDD*>(Rotate3D(*pPointTDZ, pCamera)); result.push_back(pPointDDXZ); result.push_back(pPointDDXY); result.push_back(pPointDDZY); result.push_back(pPointDDX); result.push_back(pPointDDY); result.push_back(pPointDDZ); } } } AddShift(result, fX, fY, fZ); return result; };