当前位置: 首页>>代码示例>>C++>>正文


C++ QQuaternion函数代码示例

本文整理汇总了C++中QQuaternion函数的典型用法代码示例。如果您正苦于以下问题:C++ QQuaternion函数的具体用法?C++ QQuaternion怎么用?C++ QQuaternion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了QQuaternion函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QQuaternion

AHRS::AHRS()
{
	foundZero = false;
	zeroSamples = 0;
	zx = zy = zz = 0.0f;

	quat = QQuaternion(1.0f, 0.0f, 0.0f, 0.0f);
	err[0] = err[1] = err[2] = 0.0f;
}
开发者ID:MatzElectronics,项目名称:Flight-Controller,代码行数:9,代码来源:ahrs.cpp

示例2: p

void GLWidget::mouseReleaseEvent(QMouseEvent *e){
    if ( m_mouseClick){
        float x = 2.0 * (float(e->x()) / w) - 1.0;
        float y = 1.0 - 2.0 * (float(e->y()) / h);
        QPointF p(x, y);
        m_trackBalls.release( p, QQuaternion());
        m_mouseClick = 0;
    }
}
开发者ID:gokul989,项目名称:VirtualEndoscopy,代码行数:9,代码来源:glwidget.cpp

示例3: QQuaternion

void OpenGLWidget::mouseDoubleClickEvent(QMouseEvent *)
{
    m_angularSpeed = 0;
    m_rotation = QQuaternion();

    resetCamera();

    updateGL();
}
开发者ID:sadika9,项目名称:ChemView,代码行数:9,代码来源:openglwidget.cpp

示例4: M4toQuat

QQuaternion M4toQuat(QMatrix4x4 mat) {
	double trace = mat(0,0) + mat(1,1) + mat(2,2) + 1;
	double s = 0.5 / sqrt(trace);
	double w = 0.25 / s;
	double x = (mat(2, 1) - mat(1, 2)) * s;
	double y = (mat(0, 2) - mat(2, 0)) * s;
	double z = (mat(1, 0) - mat(0, 1)) * s;
	return QQuaternion(w, x, y, z);
}
开发者ID:TheSlothExperience,项目名称:SheepBattleBoats,代码行数:9,代码来源:glwidget.cpp

示例5: _processIndex

QVRRenderContext::QVRRenderContext() :
    _processIndex(-1),
    _windowIndex(-1),
    _windowGeometry(),
    _screenGeometry(),
    _navigationPosition(0.0f, 0.0f, 0.0f),
    _navigationOrientation(0.0f, 0.0f, 0.0f, 0.0f),
    _screenWall { QVector3D(), QVector3D(), QVector3D() },
    _outputMode(QVR_Output_Center),
    _viewPasses(0),
    _eye { QVR_Eye_Center, QVR_Eye_Center },
    _trackingPosition { QVector3D(0.0f, 0.0f, 0.0f), QVector3D(0.0f, 0.0f, 0.0f) },
    _trackingOrientation { QQuaternion(0.0f, 0.0f, 0.0f, 0.0f), QQuaternion(0.0f, 0.0f, 0.0f, 0.0f) },
    _frustum { { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } },
    _viewMatrix { QMatrix4x4(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f),
                  QMatrix4x4(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f) }
{
}
开发者ID:marlam,项目名称:qvr,代码行数:18,代码来源:rendercontext.cpp

示例6: mouseReleaseEvent

void MainWidget::mouseReleaseEvent(QMouseEvent *event)
{

    if(event->button() == Qt::LeftButton)
    {
        this->trackball.release(pixelPosToViewPos(event->pos()),QQuaternion());
        event->accept();
    }

}
开发者ID:QtOpenGL,项目名称:Earth3D,代码行数:10,代码来源:mainwidget.cpp

示例7: m_angularVelocity

TrackBall::TrackBall(TrackMode mode)
    : m_angularVelocity(0)
    , m_paused(false)
    , m_pressed(false)
    , m_mode(mode)
{
    m_axis = QVector3D(0, 1, 0);
    m_rotation = QQuaternion();
    m_lastTime = QTime::currentTime();
}
开发者ID:BGmot,项目名称:Qt,代码行数:10,代码来源:trackball.cpp

示例8: m_axis

TrackBall::TrackBall(float angularVelocity, const QVector3D& axis, TrackMode mode)
    : m_axis(axis)
    , m_angularVelocity(angularVelocity)
    , m_paused(false)
    , m_pressed(false)
    , m_mode(mode)
{
    m_rotation = QQuaternion();
    m_lastTime = QTime::currentTime();
}
开发者ID:BGmot,项目名称:Qt,代码行数:10,代码来源:trackball.cpp

示例9: QQuaternion

Camera::Camera()
{
	quaternion = QQuaternion(1.0, 0.0, 0.0, 0.0);	
	target = QVector3D(0.0, 0.0, 0.0);
	xAxis = QVector3D(1.0, 0.0, 0.0);
	yAxis = QVector3D(0.0, 1.0, 0.0);
	zAxis = QVector3D(0.0, 0.0, 1.0);
	zoomOffset = 0.0;
	zoomSpeed = 0.005;
	rotationSpeed = 0.3;	
	viewMatrix.loadIdentity();		
}
开发者ID:jonatascmedeiros,项目名称:Skeleton-Extraction,代码行数:12,代码来源:Camera.cpp

示例10: qSin

/*!
    Creates a normalized quaternion that corresponds to rotating through
    \a angle degrees about the specified 3D \a axis.
*/
QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
{
    // Algorithm from:
    // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56
    // We normalize the result just in case the values are close
    // to zero, as suggested in the above FAQ.
    qreal a = (angle / 2.0f) * M_PI / 180.0f;
    qreal s = qSin(a);
    qreal c = qCos(a);
    QVector3D ax = axis.normalized();
    return QQuaternion(c, ax.x() * s, ax.y() * s, ax.z() * s).normalized();
}
开发者ID:phen89,项目名称:rtqt,代码行数:16,代码来源:qquaternion.cpp

示例11: QCOMPARE

// Test getting and setting quaternion properties via the metaobject system.
void tst_QQuaternion::properties()
{
    tst_QQuaternionProperties obj;

    obj.setQuaternion(QQuaternion(6.0f, 7.0f, 8.0f, 9.0f));

    QQuaternion q = qVariantValue<QQuaternion>(obj.property("quaternion"));
    QCOMPARE(q.scalar(), (qreal)6.0f);
    QCOMPARE(q.x(), (qreal)7.0f);
    QCOMPARE(q.y(), (qreal)8.0f);
    QCOMPARE(q.z(), (qreal)9.0f);

    obj.setProperty("quaternion",
                    qVariantFromValue(QQuaternion(-6.0f, -7.0f, -8.0f, -9.0f)));

    q = qVariantValue<QQuaternion>(obj.property("quaternion"));
    QCOMPARE(q.scalar(), (qreal)-6.0f);
    QCOMPARE(q.x(), (qreal)-7.0f);
    QCOMPARE(q.y(), (qreal)-8.0f);
    QCOMPARE(q.z(), (qreal)-9.0f);
}
开发者ID:husninazer,项目名称:qt,代码行数:22,代码来源:tst_qquaternion.cpp

示例12: rotationMatrix

QQuaternion GLC_Matrix4x4::quaternion() const
{
	QQuaternion subject;
	GLC_Matrix4x4 rotMat= rotationMatrix();
	if ((this->type() != GLC_Matrix4x4::Identity) && (rotMat != GLC_Matrix4x4()))
	{
		const double matrixTrace= rotMat.trace();
		double s, w, x, y, z;

		if (matrixTrace > 0.0)
		{
			s= 0.5 / sqrt(matrixTrace);
			w= 0.25 / s;
			x= (rotMat.m_Matrix[9] - rotMat.m_Matrix[6]) * s;
			y= (rotMat.m_Matrix[2] - rotMat.m_Matrix[8]) * s;
			z= (rotMat.m_Matrix[4] - rotMat.m_Matrix[1]) * s;
		}
		else
		{
			if ((abs(rotMat.m_Matrix[0]) > abs(rotMat.m_Matrix[5])) &&  (abs(rotMat.m_Matrix[0]) > abs(rotMat.m_Matrix[15])))
			{	// column 0 greater
		        s= sqrt(1.0 + rotMat.m_Matrix[0] - rotMat.m_Matrix[5] - rotMat.m_Matrix[10]) * 2.0;

		        w= (rotMat.m_Matrix[6] + rotMat.m_Matrix[9] ) / s;
		        x= 0.5 / s;
		        y= (rotMat.m_Matrix[1] + rotMat.m_Matrix[4] ) / s;
		        z= (rotMat.m_Matrix[2] + rotMat.m_Matrix[8] ) / s;
			}
			else if ((abs(rotMat.m_Matrix[5]) > abs(rotMat.m_Matrix[0])) &&  (abs(rotMat.m_Matrix[5]) > abs(rotMat.m_Matrix[15])))
			{	// column 1 greater
		        s= sqrt(1.0 + rotMat.m_Matrix[5] - rotMat.m_Matrix[0] - rotMat.m_Matrix[10]) * 2.0;

		        w= (rotMat.m_Matrix[2] + rotMat.m_Matrix[8]) / s;
		        x= (rotMat.m_Matrix[1] + rotMat.m_Matrix[4]) / s;
		        y= 0.5 / s;
		        z= (rotMat.m_Matrix[6] + rotMat.m_Matrix[9]) / s;
			}
			else
			{	// column 3 greater
		        s= sqrt(1.0 + rotMat.m_Matrix[10] - rotMat.m_Matrix[0] - rotMat.m_Matrix[5]) * 2.0;

		        w = (rotMat.m_Matrix[1] + rotMat.m_Matrix[4]) / s;
		        x = (rotMat.m_Matrix[2] + rotMat.m_Matrix[8]) / s;
		        y = (rotMat.m_Matrix[6] + rotMat.m_Matrix[9]) / s;
		        z = 0.5 / s;
			}
		}
		subject= QQuaternion(w, x, y, z);
	}

	return subject;
}
开发者ID:Alex-Rongzhen-Huang,项目名称:OpenPilot,代码行数:52,代码来源:glc_matrix4x4.cpp

示例13: QOpenGLShaderProgram

void OpenGLWindow::initialize()
{
    m_program = new QOpenGLShaderProgram(this);
    // see declaration of sources on top
    m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
    m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
    m_program->link();
    m_posAttr = m_program->attributeLocation("posAttr");
    m_colAttr = m_program->attributeLocation("colAttr");
    m_matrixUniform = m_program->uniformLocation("matrix");
    qrotation = QQuaternion(1, 0, 0, 0);
    rotationMode = 0; // 0 = simple rotation, 1 = trackball
}
开发者ID:gollabaer,项目名称:3DScanningLecture,代码行数:13,代码来源:mainwindow.cpp

示例14: switch

void EditCameraDialog::setCamRot(Dim axis){
    switch (axis) {
    case X:
        parent->setCameraRot(QQuaternion::fromAxisAndAngle(0, 1, 0, 90));
        break;
    case Y:
        parent->setCameraRot(QQuaternion::fromAxisAndAngle(1, 0, 0, 90));
        break;
    case Z:
        parent->setCameraRot(QQuaternion());
        break;
    }
}
开发者ID:QtOpenGL,项目名称:Modeler3D,代码行数:13,代码来源:editcameradialog.cpp

示例15: if

void  OpenGLWindow::mouseMoveEvent(QMouseEvent* event) {
    /*Change Model matrix according to mouse movement when left mouse button is pressed*/
    if (event->buttons() & Qt::LeftButton) {
        // check if position values are valid
        if (oldMousePosition.x() != -1 && oldMousePosition.y() != -1) {
            // quaterion q is used to store additional rotation
            QQuaternion q;
            if (rotationMode == 0) // simple rotation
            {
                //difference of new and old mouse position
                float xDiff = oldMousePosition.x() - event->x();
                float yDiff = oldMousePosition.y() - event->y();

                q = q.fromEulerAngles(QVector3D(yDiff, -xDiff, 0));
                //q2 = q2.fromEulerAngles(QVector3D(0, 0, -yDiff));
            }
            else if (rotationMode == 1) //trackball
            {
                // define center of window
                float centerX = float(this->width() / 2);
                float centerY = float(this->height() / 2);

                //difference of new and old mouse position
                float oldX = (oldMousePosition.x() - centerX) / centerX;
                float oldY = (oldMousePosition.y() - centerY) / centerY;
                float newX = (event->x() - centerX) / centerX;
                float newY = (event->y() - centerY) / centerY;

                //model.rotate(2, -xDiff, 0, -yDiff);
                float rotation[4];
                // get rotation as quaterion from trackball function
                gfs_gl_trackball(rotation, newX, newY, oldX, oldY);
                q = QQuaternion(QVector4D(rotation[0], rotation[1], rotation[2], rotation[3]));
            }
            // combine new rotation and current rotation
            qrotation = q  * qrotation;
            QMatrix4x4 m;
            m.rotate(qrotation);
            model.setToIdentity();
            // translate to center for rotation
            model.translate(center);
            model = model * m;
            //move back to former position
            model.translate(-center);
        }
        // set current mouse position as old
        oldMousePosition.setX(event->x());
        oldMousePosition.setY(event->y());
    }
}
开发者ID:gollabaer,项目名称:3DScanningLecture,代码行数:50,代码来源:mainwindow.cpp


注:本文中的QQuaternion函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。