RotationSettings::RotationSettings( QWidget* parent, Qt::WFlags fl ) : QDialog( parent, fl ), changeRotTo(-1) { setupUi(this); reset(); rot0->setIcon(QIcon(":icon/up")); connect(rot0, SIGNAL(clicked()),this, SLOT(applyRotation())); rot90->setIcon(QIcon(":icon/left")); connect(rot90, SIGNAL(clicked()),this, SLOT(applyRotation())); rot180->setIcon(QIcon(":icon/down")); connect(rot180, SIGNAL(clicked()),this, SLOT(applyRotation())); rot270->setIcon(QIcon(":icon/right")); connect(rot270, SIGNAL(clicked()),this, SLOT(applyRotation())); rotation_message->setAlignment(Qt::AlignCenter); rotation_message->setWordWrap(true); grabKeyboard(); QString display = qgetenv("QWS_DISPLAY"); qLog(Hardware) << display; // transformed can be capitalized or not. if ( display.indexOf("ransformed:") == -1 ) rotation_message->setText(tr("Rotion will not work because the Transformed driver is not in use.")); }
void RotateHandle::renderRing(Model::RotateHandleHit* hit, Renderer::Vbo& vbo, Renderer::RenderContext& context, float angle) { assert(hit != NULL); Vec3f xAxis, yAxis, zAxis; axes(context.camera().position(), xAxis, yAxis, zAxis); Renderer::ActivateShader shader(context.shaderManager(), Renderer::Shaders::HandleShader); Mat4f rotation; if (hit->hitArea() == Model::RotateHandleHit::HAXAxis) { rotation = rotationMatrix(angle, Vec3f::PosX); Renderer::ApplyModelMatrix applyRotation(context.transformation(), rotation); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 0.25f)); Renderer::RingFigure(Axis::AX, yAxis, zAxis, m_ringRadius, m_ringThickness, 8).render(vbo, context); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 1.0f)); Renderer::CircleFigure(Axis::AX, 0.0f, 2.0f * Math<float>::Pi, m_ringRadius + m_ringThickness, 32, false).render(vbo, context); } else if (hit->hitArea() == Model::RotateHandleHit::HAYAxis) { rotation = rotationMatrix(angle, Vec3f::PosY); Renderer::ApplyModelMatrix applyRotation(context.transformation(), rotation); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 0.25f)); Renderer::RingFigure(Axis::AY, xAxis, zAxis, m_ringRadius, m_ringThickness, 8).render(vbo, context); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 1.0f)); Renderer::CircleFigure(Axis::AY, 0.0f, 2.0f * Math<float>::Pi, m_ringRadius + m_ringThickness, 32, false).render(vbo, context); } else { rotation = rotationMatrix(angle, Vec3f::PosZ); Renderer::ApplyModelMatrix applyRotation(context.transformation(), rotation); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 0.25f)); Renderer::RingFigure(Axis::AZ, xAxis, yAxis, m_ringRadius, m_ringThickness, 8).render(vbo, context); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 1.0f)); Renderer::CircleFigure(Axis::AZ, 0.0f, 2.0f * Math<float>::Pi, m_ringRadius + m_ringThickness, 32, false).render(vbo, context); } }
void FPSControls::computeXboxRotation( XINPUT_GAMEPAD* pGamepad, PerspectiveCamera& camera ) { bool doRotate = false; float yaw = 0; float pitch = 0; int rx = pGamepad->sThumbRX; int ry = pGamepad->sThumbRY; // right stick: rotate if( std::abs( rx ) > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE ) { yaw = rx * m_xboxGamepadParameters.yawRadiansPerTick; doRotate = true; } if( std::abs( ry ) > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE ) { pitch = ry * m_xboxGamepadParameters.pitchRadiansPerTick; doRotate = true; } if( doRotate ) { if( m_xboxGamepadParameters.invertX ) { yaw = -yaw; } if( m_xboxGamepadParameters.invertY ) { pitch = -pitch; } applyRotation( yaw, pitch, camera ); } }
//-------------------------------------------------------------- void Input::updateTextureIfNeeded() { if ( !textureNeedsUpdate ) return; if (frameBuffer.getWidth() != w || frameBuffer.getHeight() != h) { frameBuffer.allocate(w, h); } // Rotate const ofTexture& texture = raw(); frameBuffer.begin(); ofClear(0); ofSetColor( ofColor::white ); center(texture, frameBuffer, angle); applyRotation(texture, angle); switch (angle) { case RotateNone: ofTranslate(-x, -y); break; case Rotate180: ofTranslate(x, y); break; case Rotate90: ofTranslate(-y, x); break; case Rotate270: ofTranslate(y, -x); break; default: break; } texture.draw(0, 0); frameBuffer.end(); frameBuffer.readToPixels(result); textureNeedsUpdate = false; }
//-------------------------------------------------------------- void Input::draw() { updateTextureIfNeeded(); ofClear(0.f); ofSetColor(ofColor::white); ofTexture& input = raw(); // Center images using original as anchor { ofPushMatrix(); ofRectangle rect(0, 0, input.getWidth(), input.getHeight()); center(rect, angle); applyRotation(input, angle); input.draw(0, 0); ofPopMatrix(); /* Center images */ } // Draw bounding box for crop { ofPushMatrix(); ofRectangle rect(x-1, y-1, w+2, h+2); center(rect, 0); ofNoFill(); ofSetColor(ofColor::red); ofDrawRectangle(rect); ofPopMatrix(); } gui.draw(); }
bool Gaze::moveEye(Joint *eye, Joint *aux_eye, bool simulate) { bool result = true; float angle; Horde3D::Vec3f axis; AxisLock lock(true, false, false); //clear eye rotation eye->update(); Horde3D::Vec3f s = eye->getScale(); Horde3D::Vec3f p = eye->getTranslation(); Horde3D::Vec3f r = eye->getRotation(); h3dSetNodeTransform( eye->getHordeID(), p.x,p.y,p.z, Config::getParamF(IK_Param::DfltEyeRotX_F), Config::getParamF(IK_Param::DfltEyeRotY_F), Config::getParamF(IK_Param::DfltEyeRotZ_F), s.x,s.y,s.z ); m_endEffector = aux_eye; if( computeRotation(eye, &axis, &angle) ) { if(!simulate) result = applyRotation(eye, axis, angle, &lock, false); else result = simulateRotation(eye, axis, angle, &lock, r); } return result; }
bool Gaze::moveHead(bool simulate) { bool result = true; float angle; Horde3D::Vec3f axis; AxisLock lock(false, false, (Config::getParamI(IK_Param::UseZLock_I) == 0) ? false : true); //clear head rotation m_head->update(); Horde3D::Vec3f s = m_head->getScale(); Horde3D::Vec3f p = m_head->getTranslation(); Horde3D::Vec3f r = m_head->getRotation(); h3dSetNodeTransform( m_head->getHordeID(), p.x,p.y,p.z, 0,0,0, s.x,s.y,s.z ); if( computeHeadRotation(&axis, &angle) ) { if(!simulate) result = applyRotation(m_head, axis, angle, &lock, false); else result = simulateRotation(m_head, axis, angle, &lock, r); } return result; }
void ccGLMatrix::shiftRotationCenter(const CCVector3& vec) { //R(X-vec)+T+vec = R(X)+T + vec-R(vec) CCVector3 Rvec = vec; applyRotation(Rvec.u); *this += (vec - Rvec); }
void Entity::transform(const Mat4f& pointTransform, const Mat4f& vectorTransform, const bool lockTextures, const bool invertOrientation) { Vec3f newOrigin = pointTransform * origin(); setProperty(OriginKey, newOrigin, true); applyRotation(vectorTransform); invalidateGeometry(); }
/** * mouse handler determines what kind of actions are being performed */ void alignMouse(int button, int state, vector mousePos) { /* set the sensitivity */ curSensitivity = GLUT_ACTIVE_CTRL == glutGetModifiers() ? fineSensitivity : coarseSensitivity; /* choose action based on button */ switch(button) { case GLUT_LEFT_BUTTON: /* if we are setting the rotation center, set it and break */ if(settingRotCenter == TRUE) { setRotationCenterV(mousePos); if(DEBUG) fprintf(stdout,"current rotation center is (%g,%g)\n", curRotCenter.x, curRotCenter.y); settingRotCenter = FALSE; break; } /* left button: translation */ switch(state) { case GLUT_DOWN: /* translation start */ moving = TRUE; break; case GLUT_UP: /* translation end, apply it */ moving = FALSE; applyTranslation(curTransAction); curTransAction.x = curTransAction.y = 0; break; } break; case GLUT_MIDDLE_BUTTON: /* rotation */ switch(state) { case GLUT_DOWN: /* rotation start */ rotating = TRUE; break; case GLUT_UP: /* rotation end, apply rotation */ rotating = FALSE; applyRotation(curRotCenter, curRotAngle); /* reset the rot angle */ curRotAngle = 0; break; } break; } /* store the last positions for the up */ if(state == GLUT_DOWN) { lastPos = mousePos; } redisplay(); }
OMX_ERRORTYPE ofxRPiCameraVideoGrabber::setRotation(ROTATION value) { switch (value) { case ROTATION_0: {rotationConfig.nRotation=0;} break; case ROTATION_90: {rotationConfig.nRotation=90;} break; case ROTATION_180: {rotationConfig.nRotation=180;} break; case ROTATION_270: {rotationConfig.nRotation=270;} break; default: {rotationConfig.nRotation=0;} break; } return applyRotation(); }
OMX_ERRORTYPE ofxRPiCameraVideoGrabber::rotateClockwise() { int currentRotation = getRotation(); if(currentRotation+90<360) { rotationConfig.nRotation+=90; }else{ rotationConfig.nRotation = 0; } return applyRotation(); }
OMX_ERRORTYPE ofxRPiCameraVideoGrabber::rotateCounterClockwise() { int currentRotation = getRotation(); if(currentRotation-90>=0) { rotationConfig.nRotation-=90; }else{ rotationConfig.nRotation = 270; } return applyRotation(); }
void CObjectView::OnMouseMove(UINT nFlags, CPoint point) { if (GetCapture() == this && (nFlags & MK_LBUTTON)){ if (mode == PAN){ Point2D pL, pC; screenToFrustum(&pL, lastPt); screenToFrustum(&pC, point); // update translate tr[0] += (pC.x - pL.x)*1000.0/scale; tr[1] += (pC.y - pL.y)*1000.0/scale; } else if (mode == ROTATE || mode == LIGHT){ Vector3D vL, vC; screenToVector(&vL, lastPt); screenToVector(&vC, point); // calculate angle prop to length mouse movement float dX = vC.x - vL.x; float dY = vC.y - vL.y; float dZ = vC.z - vL.z; float ang = 90.0 * sqrt(dX*dX + dY*dY + dZ*dZ); // vector is just cross product Vector3D v; v.cross(vL, vC); v.norm(); if (mode == ROTATE) applyRotation(m, ang, v); else applyRotation(mL, ang, v); } lastPt = point; RedrawWindow(); } CView ::OnMouseMove(nFlags, point); }
void ccGLMatrix::invert() { //we invert rotation std::swap(R21,R12); std::swap(R31,R13); std::swap(R32,R23); //we invert translation applyRotation(m_mat+12); R14 = -R14; R24 = -R24; R34 = -R34; }
void camera::update() { applyRotation(); motionvector += forwardVel * direction; motionvector += sideVel * glm::cross(up, direction); motionvector += flightVel * up; position += motionvector; //std::cout << position.x << " " << position.y << " " << position.z << std::endl; view = glm::lookAt( position, //Eye Position position + direction, //Focus point up); //Positive Y is up motionvector = glm::vec3(0, 0, 0); }
void FPSControls::computeMouseRotation( Qt::MouseButtons buttons, const Vector2f& delta, PerspectiveCamera& camera ) { if( buttons == Qt::LeftButton ) { float yawSpeed = m_mouseParameters.invertX ? m_mouseParameters.yawRadiansPerPixel : -m_mouseParameters.yawRadiansPerPixel; float pitchSpeed = m_mouseParameters.invertY ? m_mouseParameters.pitchRadiansPerPixel : -m_mouseParameters.pitchRadiansPerPixel; applyRotation( yawSpeed * delta.x, pitchSpeed * delta.y, camera ); } }
void Calibration::calibrationRotation(){ namedWindow("input"); while(true){ if(!device){ inputImage = imread(imagePath); }else{ cam >> inputImage; } applyRotation(); draw(); for(int i = -1 ; i <= 480 ; i += 160){ line(inputImage, Point(0, i), Point(640, i), Scalar(255, 255, 255), 1, 8, 0); } for(int i = -1 ; i <= 640 ; i += 160){ line(inputImage, Point(i, 0), Point(i, 480), Scalar(255, 255, 255), 1, 8, 0); } imshow("input", inputImage); char key = waitKey(10); if(key == 27){ break; }else if(key == 32){ stringstream ss; ss << PATHSAVE << "Vision/"; ss << "rotation.csv"; crud.saveRotation(ss.str(), rotation); break; }else if(key == 'd'){ rotation += 0.1; }else if(key == 'a'){ rotation -= 0.1; } } }
void rotationControl() { if(state==1) { int i; for(i=0; i<getNumberOfActuators(); i++) { if(!dynamixelApi_isWheelMode(i)) { dynamixelApi_setWheelMode(i, true); } } state++; } else if(state==2) { int i; for(i=0; i<getNumberOfActuators(); i++) { //dynamixelApi_wheelMove(i, 1023, false); applyRotation(i); } } delay = 0; }
void ccGLMatrix::invert() { //inverse scale as well! PointCoordinateType s2 = CCVector3(m_mat).norm2(); //we use the first column == X (its norm should be 1 for an 'unscaled' matrix ;) //we invert rotation std::swap(R21,R12); std::swap(R31,R13); std::swap(R32,R23); if (s2 != 0.0 && s2 != 1.0) { R11 /= s2; R12 /= s2; R13 /= s2; R21 /= s2; R22 /= s2; R23 /= s2; R31 /= s2; R32 /= s2; R33 /= s2; } //eventually we invert translation applyRotation(m_mat+12); R14 = -R14; R24 = -R24; R34 = -R34; }
void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent *e ) { if ( !mCanvas ) { return; } QgsVectorLayer *vlayer = currentVectorLayer(); if ( !vlayer ) { deleteRotationWidget(); deleteRubberband(); notifyNotVectorLayer(); return; } if ( e->button() == Qt::RightButton ) { cancel(); return; } // place anchor point on CTRL + click if ( e->modifiers() & Qt::ControlModifier ) { if ( !mAnchorPoint ) { return; } mAnchorPoint->setCenter( toMapCoordinates( e->pos() ) ); mStartPointMapCoords = toMapCoordinates( e->pos() ); mStPoint = e->pos(); return; } deleteRotationWidget(); // Initialize rotation if not yet active if ( !mRotationActive ) { mRotation = 0; mRotationOffset = 0; deleteRubberband(); mInitialPos = e->pos(); if ( !vlayer->isEditable() ) { notifyNotEditableLayer(); return; } QgsPointXY layerCoords = toLayerCoordinates( vlayer, e->pos() ); double searchRadius = QgsTolerance::vertexSearchRadius( mCanvas->currentLayer(), mCanvas->mapSettings() ); QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius, layerCoords.x() + searchRadius, layerCoords.y() + searchRadius ); if ( vlayer->selectedFeatureCount() == 0 ) { QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( selectRect ).setNoAttributes() ); //find the closest feature QgsGeometry pointGeometry = QgsGeometry::fromPointXY( layerCoords ); if ( pointGeometry.isNull() ) { return; } double minDistance = std::numeric_limits<double>::max(); QgsFeature cf; QgsFeature f; while ( fit.nextFeature( f ) ) { if ( f.hasGeometry() ) { double currentDistance = pointGeometry.distance( f.geometry() ); if ( currentDistance < minDistance ) { minDistance = currentDistance; cf = f; } } } if ( minDistance == std::numeric_limits<double>::max() ) { emit messageEmitted( tr( "Could not find a nearby feature in the current layer." ) ); return; } QgsRectangle bound = cf.geometry().boundingBox(); mStartPointMapCoords = toMapCoordinates( vlayer, bound.center() ); if ( !mAnchorPoint ) { mAnchorPoint = qgis::make_unique<QgsVertexMarker>( mCanvas ); } mAnchorPoint->setIconType( QgsVertexMarker::ICON_CROSS ); mAnchorPoint->setCenter( mStartPointMapCoords ); mStPoint = toCanvasCoordinates( mStartPointMapCoords ); mRotatedFeatures.clear(); mRotatedFeatures << cf.id(); //todo: take the closest feature, not the first one... mRubberBand = createRubberBand( vlayer->geometryType() ); mRubberBand->setToGeometry( cf.geometry(), vlayer ); } else { mRotatedFeatures = vlayer->selectedFeatureIds(); mRubberBand = createRubberBand( vlayer->geometryType() ); QgsFeature feat; QgsFeatureIterator it = vlayer->getSelectedFeatures(); while ( it.nextFeature( feat ) ) { mRubberBand->addGeometry( feat.geometry(), vlayer ); } } mRubberBand->show(); double XDistance = mInitialPos.x() - mAnchorPoint->x(); double YDistance = mInitialPos.y() - mAnchorPoint->y(); mRotationOffset = std::atan2( YDistance, XDistance ) * ( 180 / M_PI ); createRotationWidget(); if ( e->modifiers() & Qt::ShiftModifier ) { if ( mRotationWidget ) { mRotationWidget->setMagnet( 45 ); } } mRotationActive = true; return; } applyRotation( mRotation ); }
void Trackball::applyTransform() { glTranslatef( _rotCen[0], _rotCen[1], _rotCen[2] ); applyRotation( _qRot ); glTranslatef( -_rotCen[0], -_rotCen[1], -_rotCen[2] ); }
/** Permet de tourner le texte de maniere relative. L'angle added_rotation est ajoute a l'orientation actuelle du texte. @param added_rotation Angle a ajouter a la rotation actuelle @see applyRotation */ void DiagramTextItem::rotateBy(const qreal &added_rotation) { qreal applied_added_rotation = QET::correctAngle(added_rotation); rotation_angle_ = QET::correctAngle(rotation_angle_ + applied_added_rotation); applyRotation(applied_added_rotation); }
/** Permet de tourner le texte a un angle donne de maniere absolue. Un angle de 0 degres correspond a un texte horizontal non retourne. @param rotation Nouvel angle de rotation de ce texte @see applyRotation */ void DiagramTextItem::setRotationAngle(const qreal &rotation) { qreal applied_rotation = QET::correctAngle(rotation); applyRotation(applied_rotation - rotation_angle_); rotation_angle_ = applied_rotation; }
void DirectionalLight::applyRotation(const XMFLOAT4X4& transform) { XMMATRIX transformMatrix = XMLoadFloat4x4(&transform); applyRotation(transformMatrix); }
void Matrix3f::applyRotation(float* g) { applyRotation(g[XAXIS], g[YAXIS], g[ZAXIS]); }