/*! The matrix is:\n * \verbatim * [0][0] = (RtFloat)(x*x + cosw*(1.0 - x*x)); * [0][1] = (RtFloat)(x*y*(1.0 - cosw) + z*sinw); * [0][2] = (RtFloat)(z*x*(1.0 - cosw) - y*sinw); * [1][0] = (RtFloat)(x*y*(1.0 - cosw) - z*sinw); * [1][1] = (RtFloat)(y*y + cosw*(1.0 - y*y)); * [1][2] = (RtFloat)(y*z*(1.0 - cosw) + x*sinw); * [2][0] = (RtFloat)(z*x*(1.0 - cosw) + y*sinw); * [2][1] = (RtFloat)(y*z*(1.0 - cosw) - x*sinw); * [2][2] = (RtFloat)(z*z + cosw*(1.0 - z*z)); * \endverbatim * \param w degrees to rotate * \param x x-coordinate of the axis vector * \param y y-coordinate of the axis vector * \param z z-coordinate of the axis vector */ void TMatrix3D::rotate(RtFloat w, RtFloat x, RtFloat y, RtFloat z) { TMatrix3D r; if ( x > 0.0 && y == 0.0 && z == 0.0 ) { rotateX(w); return; } if ( x < 0.0 && y == 0.0 && z == 0.0 ) { rotateX(-w); return; } if ( x == 0.0 && y > 0.0 && z == 0.0 ) { rotateY(w); return; } if ( x == 0.0 && y < 0.0 && z == 0.0 ) { rotateY(-w); return; } if ( x == 0.0 && y == 0.0 && z > 0.0 ) { rotateZ(w); return; } if ( x == 0.0 && y == 0.0 && z < 0.0 ) { rotateZ(-w); return; } w = deg2rad(w); RtFloat length = (RtFloat)sqrt(x*x + y*y + z*z); RtFloat sinw = (RtFloat)sin(w); RtFloat cosw = (RtFloat)cos(w); x /= length; y /= length; z /= length; r.m_Matrix[0][0] = (RtFloat)(x*x + cosw*(1.0 - x*x)); r.m_Matrix[0][1] = (RtFloat)(x*y*(1.0 - cosw) + z*sinw); r.m_Matrix[0][2] = (RtFloat)(z*x*(1.0 - cosw) - y*sinw); r.m_Matrix[1][0] = (RtFloat)(x*y*(1.0 - cosw) - z*sinw); r.m_Matrix[1][1] = (RtFloat)(y*y + cosw*(1.0 - y*y)); r.m_Matrix[1][2] = (RtFloat)(y*z*(1.0 - cosw) + x*sinw); r.m_Matrix[2][0] = (RtFloat)(z*x*(1.0 - cosw) + y*sinw); r.m_Matrix[2][1] = (RtFloat)(y*z*(1.0 - cosw) - x*sinw); r.m_Matrix[2][2] = (RtFloat)(z*z + cosw*(1.0 - z*z)); concatTransform(r.m_Matrix); }
/* functie care roteste intreg cubul rubik in orice directie */ void Rubik::rotate_all (int direction, float speed) { for (int i = 0; i < rubik.size(); i++) { switch (direction) { case LEFT: rotateY(i, cs->axiscenter, speed); break; case RIGHT: rotateY(i, cs->axiscenter, -speed); break; case UP: rotateZ(i, cs->axiscenter, speed); break; case DOWN: rotateZ(i, cs->axiscenter, -speed); break; case BOTTOM: rotateX(i, cs->axiscenter, speed); break; case TOP: rotateX(i, cs->axiscenter, -speed); break; } } }
void Window::keyboard( unsigned char key, int x, int y ) { switch( key ) { case '1': setUpOrtho(); break; case '2': setUpFrustrum(); break; //rotations case 'x': rotateX(ANGLEINC); break; case 'y': rotateY(ANGLEINC); break; case 'z': rotateZ(ANGLEINC); break; case 'X': rotateX(-ANGLEINC); break; case 'Y': rotateY(-ANGLEINC); break; case 'Z': rotateZ(-ANGLEINC); break; case 'r': case 'R': //Press R to reload a shader shader->updateShader(); break; case 'a': case 'A': //Press a to move left moveLeft(); break; case 'd': case 'D': //Press d to move right moveRight(); break; case 'w': case 'W': //Press w to move up moveUp(); break; case 's': case 'S': //Press s to move down moveDown(); break; case '+': changeAmbience(AMB_INC); break; case '=': changeAmbience(-AMB_INC); break; case 033: // Escape key case 'q': case 'Q': exit( 0 ); break; } glutPostRedisplay(); }
/* functie care roteste un strat al cubului rubik in orice directie */ void Rubik::rotate_layer (int layer, float speed) { Point3d center; std::vector<int> to_move = get_layer(layer); for (int i = 0; i < to_move.size(); i++) { if (layer == LEFT || layer == RIGHT) { rotateX(to_move[i], cs->axiscenter, speed); } if (layer == TOP || layer == BOTTOM) { rotateY(to_move[i], cs->axiscenter, speed); } if (layer == BACK || layer == FRONT) { rotateZ(to_move[i], cs->axiscenter, speed); } if (layer == CENTER_X) { rotateY(to_move[i], cs->axiscenter, speed); } if (layer == CENTER_Y) { rotateX(to_move[i], cs->axiscenter, speed); } if (layer == CENTER_Z) { rotateZ(to_move[i], cs->axiscenter, speed); } } }
bool equals() { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (strcmp(cubeA, cubeB) == 0) return true; rotateZ(); } rotateX(); } rotateY(); for (j = 0; j < 4; j++) { if (strcmp(cubeA, cubeB) == 0) return true; rotateZ(); } rotateY(); rotateY(); for (j = 0; j < 4; j++) { if (strcmp(cubeA, cubeB) == 0) return true; rotateZ(); } return false; }
void Matrix4x4<T>::smartMove(T inRX, T inRY, T inRZ, T inTX, T inTY, T inTZ) { translate(inTX, inTY, inTZ); rotateY(inRY); rotateX(inRX); rotateZ(inRZ); }
int Viewfinder::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: processFrames((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: processFrame(); break; case 2: toggleCube(); break; case 3: toggleGourd(); break; case 4: paintCube(); break; case 5: paintGourd(); break; case 6: changeX(); break; case 7: changeY(); break; case 8: changeZ(); break; case 9: rotateX(); break; case 10: rotateY(); break; case 11: rotateZ(); break; case 12: plus(); break; case 13: minus(); break; case 14: openDirectory(); break; default: ; } _id -= 15; } return _id; }
void Transform3d::rotateZRelativeToAnotherPoint (Point3d *pct, Point3d *ref, float angleInRadians) { translate (pct, -ref->x, -ref->y, -ref->z); rotateZ(pct, angleInRadians); translate (pct, ref->x, ref->y, ref->z); }
void CThirdPlayerActorSkinned::Update(void) { //need respawn if (m_bSpawn) { dmat4 trans = m_meshPlayer->getWorldTransform(); trans.setColumn3(3, m_vSpawnPos); m_meshPlayer->setWorldTransform(trans); } //update meshPlayer's pos, rot, scale according to camera's pos m_meshPlayer->setWorldTransform(m_playerActor->getWorldTransform() * rotateZ((double)90.0f)); #ifdef debug { dmat4 tempMat = m_meshPlayer->getWorldTransform(); dvec3 tempVec = tempMat.getTranslate(); cout <<"player's pos: "<< tempVec.x << " " << tempVec.y << " " << tempVec.z << endl; if (m_meshPlayer->isEnabled()) { cout << "meshPlayer is Enabled " << endl; } } #endif //update animations { UpdateAnim(); } }
mat4& GDAnim::GetJoint(GDAnim** anims, float* weights, uint numAnims, uint jointID, float time) { GDAnim* anim = anims[0]; time = fmod(time, anim->animLength); vec3 vscale; vec3 rot; vec3 trans; vscale[0] = getAnimValue(anim->scaleKeys, anim->jointTimelines[jointID].s[0], time); vscale[1] = getAnimValue(anim->scaleKeys, anim->jointTimelines[jointID].s[1], time); vscale[2] = getAnimValue(anim->scaleKeys, anim->jointTimelines[jointID].s[2], time); rot[0] = getAnimValue(anim->rotKeys, anim->jointTimelines[jointID].r[0], time); rot[1] = getAnimValue(anim->rotKeys, anim->jointTimelines[jointID].r[1], time); rot[2] = getAnimValue(anim->rotKeys, anim->jointTimelines[jointID].r[2], time); trans[0] = getAnimValue(anim->transKeys, anim->jointTimelines[jointID].t[0], time); trans[1] = getAnimValue(anim->transKeys, anim->jointTimelines[jointID].t[1], time); trans[2] = getAnimValue(anim->transKeys, anim->jointTimelines[jointID].t[2], time); // TODO: Super slow! Fix this! Use SQT's probably mat4 t, rx, ry, rz, s; t = translate(trans); rx = rotateX(rot.x/360.f*2*PI); ry = rotateY(rot.y/360.f*2*PI); rz = rotateZ(rot.z/360.f*2*PI); s = scale(vscale.x, vscale.y, vscale.z); return t*rz*ry*rx; }
void SWQtCamera::rotate(cfloat fX, cfloat fY, cfloat fZ, cfloat fAmount) { QVector3D l_v(fX, fY, fZ); rotateX(fY/l_v.length() * fAmount); rotateY(fX/l_v.length() * fAmount); rotateZ(fZ/l_v.length() * fAmount); }
bool BoundingBoxes::boxesAreWithin(shared_ptr<BoundingBoxes> otherBoxes) { bool collides = false; glm::mat4 rotationMatrix = rotateZ(otherBoxes->rotation.z) * rotateX(otherBoxes->rotation.x) * rotateY(otherBoxes->rotation.y); for (vector<vector<float> >::iterator vertex = otherBoxes->vertices.begin(); vertex != otherBoxes->vertices.end(); ++vertex) { glm::vec4 otherCoords(vertex->at(0), vertex->at(1), vertex->at(2), 1.0f); glm::vec4 rotatedOtherCoords(0.0f, 0.0f, 0.0f, 1.0f); rotatedOtherCoords = rotationMatrix * otherCoords; rotatedOtherCoords.x += otherBoxes->offset.x; rotatedOtherCoords.y += otherBoxes->offset.y; rotatedOtherCoords.z += otherBoxes->offset.z; /*cout << "Checking " << rotatedOtherCoords.x << ", " << rotatedOtherCoords.y << ", " << rotatedOtherCoords.z << " with " << boxesX << ", " << boxesY << ", " << boxesZ << " rotation " << boxesRotation << endl;*/ if (pointIsWithin(rotatedOtherCoords.x, rotatedOtherCoords.y, rotatedOtherCoords.z)) { collides = true; break; } } return collides; }
float f(Mat m, int n) { float z = -1.0f; for (float r = 0.0f; r < 0.8f; r += 0.02f) { Vec v = { 0.0f, r, 0.0f, 1.0f }; transformPosition(&v, m, v); z = opUnion(z, sphere(v, transformLength(m, 0.05f * (0.95f - r)))); } if (n > 0) { Mat ry, rz, s, t, m2, m3; rotateZ(&rz, 1.8f); for (int p = 0; p < 6; p++) { rotateY(&ry, p * (2 * PI / 6)); mul(&m2, ry, rz); float ss = 0.45f; for (float r = 0.2f; r < 0.8f; r += 0.1f) { scale(&s, ss); translate(&t, 0.0f, r, 0.0f); mul(&m3, s, m2); mul(&m3, t, m3); mul(&m3, m, m3); z = opUnion(z, f(m3, n - 1)); ss *= 0.8f; } } } return z; }
void robot_clone_wars(int t) { #define SPACE_FLOOR 1 #define FINAL_WALK_ON 1 #define LINES 6 #define SPACING 16384 int i, j; //rotateX(2560); if ( (t & 1) == 0 ) { // different camera for different screens translate(5120, 44032, 20480); rotateZ(1792); } else { rotateX(2560); } #if SPACE_FLOOR push(); translate(0, -6144, -4096*4); rotateX(-12867/2); scale(4096*16, 4096*10, 4096*10); spot(RGB15(0, 7, 3), RGB15(0, 2, 1), 0, -64); pop(); #endif #if SPACE_FLOOR int z = t*256-16384; #else int z = t*256*8-16384*8; #endif if ( z > 0 ) z = 0; int lines = (t-192+8)/8; if ( lines < 2 ) lines = 2; else if ( lines > LINES ) lines = LINES; for ( i = 1 ; i < lines ; i++ ) { translate(0, 0, -8192); for ( j = 0 ; j < i ; j++ ) { if ( j == 2 && i == 5 ) continue; push(); translate(j * SPACING - ((i-1)*SPACING)/2, jump(t-i*4)+z, 0); #if FINAL_WALK_ON if ( t < 512 ) robot(8, 256); else robot(8+t-512, 256); #else robot(8); #endif pop(); } } }
void rotate3D(t_mat3 *m, t_vec3 deg) { if (deg.z != 0.0) rotateZ(m, deg.z); if (deg.y != 0.0) rotateY(m, deg.y); if (deg.x != 0.0) rotateX(m, deg.x); }
void Vector::rotate(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) { if (x != 0.0f) rotateX(angle); if (y != 0.0f) rotateY(angle); if (z != 0.0f) rotateZ(angle); }
Matr4::Matr4(const Vect4& rotVect, const Vect4& transVect, const Vect4& scaleVect) { memset(_elems, 0, sizeof(_elems)); setTranslate(transVect); rotateX(rotVect[0]); rotateY(rotVect[1]); rotateZ(rotVect[2]); scale(scaleVect); }
int main(){ allegro_init(); install_keyboard(); /* install_sound (DIGI_AUTODETECT, MIDI_AUTODETECT, NULL); MIDI *music; music = load_midi("./99.midd"); if (!music) {std::cerr<<"Couldn't load background music!"<<std::endl;exit(1);} else play_midi(music,1); */ set_gfx_mode( GFX_AUTODETECT, 1920, 1200, 0, 0); buffer = create_bitmap( 1920, 1200); while ( !key[KEY_ESC] ){ clear_keybuf(); if (key[KEY_UP]) rotateY(-2); else if (key[KEY_DOWN]) rotateY(2); else if (key[KEY_RIGHT]) rotateX(2); else if (key[KEY_LEFT]) rotateX(-2); else if (key[KEY_PGUP]) rotateZ(-2); else if (key[KEY_PGDN]) rotateZ(2); draw(); } /* if(music) { stop_midi(); destroy_midi(music); } */ return 0; }
void SimCalcs::rotateAtom(int aIdx, int pivotIdx, Real rotX, Real rotY, Real rotZ, Real** aCoords) { Real pX = aCoords[X_COORD][pivotIdx]; Real pY = aCoords[Y_COORD][pivotIdx]; Real pZ = aCoords[Z_COORD][pivotIdx]; translateAtom(aIdx, -pX, -pY, -pZ, aCoords); rotateX(aIdx, rotX, aCoords); rotateY(aIdx, rotY, aCoords); rotateZ(aIdx, rotZ, aCoords); translateAtom(aIdx, pX, pY, pZ, aCoords); }
/* Derive vertex normals by averaging the normals of the surrounding two lines Note that this all takes place in 2D on the XY plane, since this is called before the slices are rotated into their true 3D positions */ void precalcNormals(void) { int slice, point; point_t current, prev, next; vector3_t prevEdge, nextEdge, normal; vector3_t v1, v2, v3, v4; for(slice = 0; slice < state.sliceCount; slice++) { for(point = 0; point < state.pointsPerSlice; point++) { current = state.data[slice * state.pointsPerSlice + point]; /* Get vectors for previous and next edges relative to current point */ if(point == 0) { /* First point in a slice - previous vertex is last in slice */ prev = state.data[slice * state.pointsPerSlice + state.pointsPerSlice - 1]; } else { prev = state.data[slice * state.pointsPerSlice + point - 1]; } if(point == state.pointsPerSlice - 1) { /* Last point in a slice - next vertex is first in slice */ next = state.data[slice * state.pointsPerSlice]; } else { next = state.data[slice * state.pointsPerSlice + point + 1]; } prevEdge.x = current.position.x - prev.position.x; prevEdge.y = current.position.y - prev.position.y; prevEdge.z = 0.0; nextEdge.x = next.position.x - current.position.x; nextEdge.y = next.position.y - current.position.y; nextEdge.z = 0.0; /* Normalise the edges */ normalise(&prevEdge); normalise(&nextEdge); /* Add them */ normal.x = prevEdge.x + nextEdge.x; normal.y = prevEdge.y + nextEdge.y; normal.z = 0.0; /* Rotate */ rotateZ(&normal, -M_PI / 2.0); /* Normalise the result */ normalise(&normal); /* And store it with the point data */ current.normal = normal; /* Store current point back in the global array */ state.data[slice * state.pointsPerSlice + point] = current; } } }
void SimObjectRenderer::rotateCamera(float x, float y) { if(cameraMode == SimRobotCore2::Renderer::targetCam) { Vector3<> v = cameraPos - cameraTarget; Matrix3x3<> rotateY(Vector3<>(0.f, y, 0.f)); Matrix3x3<> rotateZ(Vector3<>(0.f, 0.f, x)); Vector3<> v2(sqrtf(v.x * v.x + v.y * v.y), 0.f, v.z); v2 = rotateY * v2; if(v2.x < 0.001f) { v2.x = 0.001f; v2.normalize(v.abs()); } Vector3<> v3(v.x, v.y, 0.f); v3.normalize(v2.x); v3.z = v2.z; v = rotateZ * v3; cameraPos = cameraTarget + v; } else // if(cameraMode == SimRobotCore2::Renderer::freeCam) { Vector3<> v = cameraTarget - cameraPos; Matrix3x3<> rotateY(Vector3<>(0.f, y, 0.f)); Matrix3x3<> rotateZ(Vector3<>(0.f, 0.f, -x)); Vector3<> v2(sqrtf(v.x * v.x + v.y * v.y), 0.f, v.z); v2 = rotateY * v2; if(v2.x < 0.001f) { v2.x = 0.001f; v2.normalize(v.abs()); } Vector3<> v3(v.x, v.y, 0.f); v3.normalize(v2.x); v3.z = v2.z; v = rotateZ * v3; cameraTarget = cameraPos + v; } updateCameraTransformation(); }
void arms(int t, int m) { push(); // translate(0.24f*m, 0.4f, 0); translate(983*m, 1638, 0); // rotateZ(30°*m); rotateZ(2145*m); // rotateX(cos(t)*20°+180°); rotateX(((cos(t)*1430)>>12)+12868); // translate(0, 0.3, 0); translate(0, 1229, 0); push(); // scale(0.1, 0.3, 0.1); scale(410, 1229, 410); cube(); pop(); // translate(0, 0.22, 0); translate(0, 901, 0); // rotateY(abs(cos(t))*16*m); int act = cos(t)*1144; if ( act < 0 ) act = -act; rotateY((act>>12)*m); // rotateX(100°); rotateX(7149); // rotateZ(165°*m); rotateZ(11796*m); // translate(0, 0.21, 0); translate(0, 860, 0); push(); // scale(0.09, 0.27, 0.09); scale(369, 1106, 369); cube(); pop(); pop(); }
void drawAnimation() { //Rotate the SphereNormals display in the x-axis. scale(0.35, 0.35, 0.35); rotateX(a); rotateZ(a); translate(0, 0, 4); drawSphereNormals(); glLoadIdentity(); //Rotate the WireCone drawing in the y-axis. scale(0.35, 0.35, 0.35); rotateY(b); rotateX(b); translate(4, 0, 0); drawWireCone(); glLoadIdentity(); //Rotate the WireSphere drawing the the z-axis. scale(0.35, 0.35, 0.35); rotateZ(c); rotateY(c); translate(0, 4, 0); drawWireSphere(); glLoadIdentity(); //Rotate the ShadedSphere drawing (on the spot) through the x-, y- and z- axis. scale(0.35, 0.35, 0.35); rotateY(d); drawShadedSphere(); glLoadIdentity(); //Reset the camera to orthographic. glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-2, 2, -2, 2, 2, -2); glMatrixMode(GL_MODELVIEW); }
void display() { //Clear buffers and set the transformation matrix to the identity matrix. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); //Increment global angle variables (take FPS into account). a += 90 / FPS; b += 90 / FPS; c += 90 / FPS; d += 90 / FPS; a %= 360; b %= 360; c %= 360; d %= 360; //Draw scene depending on program state. switch (state) { case 1: rotateY(a); rotateZ(a); drawWireSphere(); break; case 2: rotateX(20); rotateY(b); drawWireCone(); break; case 3: rotateY(a); rotateZ(a); drawSphereNormals(); break; case 4: rotateY(d); drawShadedSphere(); break; case 5: drawAnimation(); break; } //Swap buffers. SDL_GL_SwapBuffers(); }
//Disegno il cannone void Cannone::draw(void) { glPushMatrix(); rotateX(xRot); rotateY(yRot); rotateZ(zRot); applyTransform(); glColor3f(0.6, 0.6, 0.6); glutSolidSphere(0.35, 25, 43); switch (getCityPosition()) { case 0: glPushMatrix(); glTranslatef(0, 0, -28); drawMirino(); glPopMatrix(); glTranslatef(0, 0, -0.6); glScalef(1, 1, 2.5); break; case 1: glPushMatrix(); glTranslatef(28, 0, 0); glRotatef(90, 0, 1, 0); drawMirino(); glPopMatrix(); glTranslatef(0.6, 0, 0); glScalef(2.5, 1, 1); glRotatef(90, 0, 1, 0); break; case 2: glPushMatrix(); glTranslatef(0, 0, 28); drawMirino(); glPopMatrix(); glTranslatef(0, 0, 0.6); glScalef(1, 1, 2.5); break; case 3: glPushMatrix(); glTranslatef(-28, 0, 0); glRotatef(90, 0, 1, 0); drawMirino(); glPopMatrix(); glTranslatef(-0.6, 0, 0); glScalef(2.5, 1, 1); glRotatef(90, 0, 1, 0); break; } glutSolidTorus(0.25, 0.30, 25, 43); glPopMatrix(); }
int MyGLWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QGLWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: rotateX((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: rotateY((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: rotateZ((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } _id -= 3; } return _id; }
void RegistrationBehavior::OnStart(void) { // adjust scaling //this->VisibleObject1->Actor->SetScale(0.25); // adjust position offsets vct6 bounds; this->VisibleObject1->Lock(); bounds.Assign(this->VisibleObject1->Actor->GetBounds()); this->VisibleObject1->Unlock(); vct3 offset; for (unsigned int i = 0; i < offset.size(); i++) { offset[i] = (bounds[2*i] + bounds[(2*i)+1]) / -2.0; } this->VisibleObject1->Actor->AddPosition(offset.Pointer()); // adjust orientation offsets double thetaX = -60.0 * cmnPI_180; double thetaY = 0.0 * cmnPI_180; double thetaZ = 0.0 * cmnPI_180; vctRot3 rotateX( 1.0, 0.0, 0.0, 0.0, cos(thetaX), -sin(thetaX), 0.0, sin(thetaX), cos(thetaX)); vctRot3 rotateY( cos(thetaY), 0.0, sin(thetaY), 0.0, 1.0, 0.0, -sin(thetaY), 0.0, cos(thetaY)); vctRot3 rotateZ( cos(thetaZ), -sin(thetaZ), 0.0, sin(thetaZ), cos(thetaZ), 0.0, 0.0, 0.0, 1.0); vctRot3 rotateZYX; rotateZYX = rotateZ * rotateY * rotateX; this->VisibleObject1->SetOrientation(rotateZYX); this->ModelFiducials->SetPosition(vct3(0.0)); this->ModelFiducials->Show(); this->Position.Assign(0.0, 0.0, -500.0); this->Widget3D->SetPosition(this->Position); this->Widget3D->SetSize(150.0); this->Widget3D->Show(); }
/** * Creates a tetrimino according to its type * */ Tetrimino* createTetrimino(short type) { Tetrimino* tetrimino = malloc(sizeof(Tetrimino)); tetrimino->type = type; int i, j; for(i=0; i<TETRI_SIZE; i++) for(j=0; j<TETRI_SIZE; j++) tetrimino->array[i][j] = 0; switch(type) { case TETRI_O: rotateO(tetrimino, ROT_0); break; case TETRI_J: rotateJ(tetrimino, ROT_0); break; case TETRI_L: rotateL(tetrimino, ROT_0); break; case TETRI_I: rotateI(tetrimino, ROT_0); break; case TETRI_Z: rotateZ(tetrimino, ROT_0); break; case TETRI_S: rotateS(tetrimino, ROT_0); break; case TETRI_T: rotateT(tetrimino, ROT_0); break; default: break; } return tetrimino; }
void CTransformation::rotate(float ang, CPoint vectorEje, CPoint enRecta ) //Acumula el giro alrededor de un eje generico { // enRecta es un punto que está en el eje de rotacion float lat= vectorEje.latitude(); //latitude float lon= vectorEje.longitude(); //longitude // Me llevo el sistema de coordenadas al punto que quiero girar traslate(enRecta); // Lo giro para que esté como el eje vectorEje rotateY(lon); rotateX(-lat); rotateZ(ang); // ahora a volver al sitio original rotateX(lat); rotateY(-lon); traslate(enRecta.negate()); };
ToyRotationMatrix::ToyRotationMatrix(float degreeX /*=0*/, float degreeY /*=0*/, float degreeZ /*=0*/):ToyMatrix<float>(), DegreeX(degreeX), DegreeY(degreeY), DegreeZ(degreeZ) { makeIdentity(); // Efficiency: Try to initialize in one go if possible // Out of convenience the default C'tor will init with // zero, then the identity matrix is written (only // five entries) and then rotation is constructed and // multiplied. if (DegreeX) { rotateX(DegreeX); } if (DegreeY) { rotateY(DegreeY); } if (DegreeZ) { rotateZ(DegreeZ); } }