本文整理汇总了C++中ofQuaternion::y方法的典型用法代码示例。如果您正苦于以下问题:C++ ofQuaternion::y方法的具体用法?C++ ofQuaternion::y怎么用?C++ ofQuaternion::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofQuaternion
的用法示例。
在下文中一共展示了ofQuaternion::y方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMatrix
//--------------------------------------------------------------------------
void game::getMatrix( GLfloat * m, ofQuaternion quat ) {
float x2 = quat.x() * quat.x();
float y2 = quat.y() * quat.y();
float z2 = quat.z() * quat.z();
float xy = quat.x() * quat.y();
float xz = quat.x() * quat.z();
float yz = quat.y() * quat.z();
float wx = quat.w() * quat.x();
float wy = quat.w() * quat.y();
float wz = quat.w() * quat.z();
m[0] = 1.0f - 2.0f * (y2 + z2);
m[1] = 2.0f * (xy - wz);
m[2] = 2.0f * (xz + wy);
m[3] = 0.0f;
m[4] = 2.0f * (xy + wz);
m[5] = 1.0f - 2.0f * (x2 + z2);
m[6] = 2.0f * (yz - wx);
m[7] = 0.0f;
m[8] = 2.0f * (xz - wy);
m[9] = 2.0f * (yz + wx);
m[10] = 1.0f - 2.0f * (x2 + y2);
m[11] = 0.0f;
m[12] = 0.0f;
m[13] = 0.0f;
m[14] = 0.0f;
m[15] = 1.0f;
}
示例2: setRotation
//------------------------------------------------------------
void Hammer::setRotation(ofQuaternion rotation){
btTransform transform;
btRigidBody* rigidBody = body.getRigidBody();
rigidBody->getMotionState()->getWorldTransform( transform );
btQuaternion originRot;
originRot.setX(rotation.x());
originRot.setY(rotation.y());
originRot.setZ(rotation.z());
originRot.setW(rotation.w());
transform.setRotation(originRot);
rigidBody->getMotionState()->setWorldTransform( transform );
}
示例3: lerpQuat
ofQuaternion testApp::lerpQuat(float t, ofQuaternion qa, ofQuaternion qb)
{
ofQuaternion qm;
//dot product
float cosHalfTheta = qa.w() * qb.w() + qa.x() * qb.x() + qa.y() * qb.y() + qa.z() * qb.z();
if (abs(cosHalfTheta) >= 1.0)
{
return qa;
}
else
{
// Calculate temporary values.
float halfTheta = acos(cosHalfTheta);
float sinHalfTheta = sqrt(1.0 - cosHalfTheta*cosHalfTheta);
// if theta = 180 degrees then result is not fully defined
// we could rotate around any axis normal to qa or qb
if (fabs(sinHalfTheta) < 0.001){ // fabs is floating point absolute
qm.set(
(qa.x() * 0.5 + qb.x() * 0.5),
(qa.y() * 0.5 + qb.y() * 0.5),
(qa.z() * 0.5 + qb.z() * 0.5),
(qa.w() * 0.5 + qb.w() * 0.5)
);
return qm;
}
float ratioA = sin((1 - t) * halfTheta) / sinHalfTheta;
float ratioB = sin(t * halfTheta) / sinHalfTheta;
//calculate Quaternion
qm.set(
(qa.x() * ratioA + qb.x() * ratioB),
(qa.y() * ratioA + qb.y() * ratioB),
(qa.z() * ratioA + qb.z() * ratioB),
(qa.w() * ratioA + qb.w() * ratioB)
);
return qm;
}
}
示例4: create
//--------------------------------------------------------------
void ofxBulletCapsule::create( btDiscreteDynamicsWorld* a_world, ofVec3f a_loc, ofQuaternion a_rot, float a_mass, float a_radius, float a_height ) {
btTransform tr = ofGetBtTransformFromVec3f( a_loc );
tr.setRotation( btQuaternion(btVector3(a_rot.x(), a_rot.y(), a_rot.z()), a_rot.w()) );
create( a_world, tr, a_mass, a_radius, a_height );
}
示例5: ofxToString
string ofxToString(ofQuaternion q) {
return ofToString(q.x()) + "," + ofToString(q.y()) + "," + ofToString(q.z()) + "," + ofToString(q.w());
}