本文整理汇总了C++中Matrix3::FromAxisAngle方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3::FromAxisAngle方法的具体用法?C++ Matrix3::FromAxisAngle怎么用?C++ Matrix3::FromAxisAngle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix3
的用法示例。
在下文中一共展示了Matrix3::FromAxisAngle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ComputeAlignAxisMatrix
void rms::ComputeAlignAxisMatrix( const Vector3<Real> & vInitial,
const Vector3<Real> & vAlignWith, Matrix3<Real> & matrix )
{
// compute cosine of angle between vectors
Real axisDot = vAlignWith.Dot( vInitial );
// compute rotation axis
Vector3<Real> axisCross( vInitial.Cross( vAlignWith ) );
// apply rotation if necessary
if (axisCross.SquaredLength() > Wml::Math<Real>::EPSILON) {
// compute normalized axis and angle, then create rotation around axis
axisCross.Normalize();
Real fAngle = Math<Real>::ACos( axisDot / vAlignWith.Length() );
matrix.FromAxisAngle( axisCross, fAngle );
} else if (axisDot < (Real)0) {
// find some perpendicular vectors
Wml::Vector3<Real> vPerp1, vPerp2;
ComputePerpVectors( vInitial, vPerp1, vPerp2 );
matrix.FromAxisAngle( vPerp1, (Real)180 * Math<Real>::DEG_TO_RAD );
} else {
matrix = Matrix3<Real>::IDENTITY;
}
}
示例2: ComputeAlignZAxisMatrix
void rms::ComputeAlignZAxisMatrix( const Vector3<Real> & vAlignWith,
Matrix3<Real> & matrix, bool bInvert )
{
// compute cosine of angle between vectors
Real axisDot = vAlignWith.Dot( Vector3<Real>::UNIT_Z );
// compute rotation axis
Vector3<Real> axisCross( Vector3<Real>::UNIT_Z.Cross( vAlignWith ) );
Real fInverter = (bInvert) ? (Real)-1 : (Real)1;
// apply rotation if necessary
if (axisCross.SquaredLength() > Wml::Math<Real>::EPSILON) {
// compute normalized axis and angle, then create rotation around axis
axisCross.Normalize();
Real fAngle = Math<Real>::ACos( axisDot / vAlignWith.Length() );
matrix.FromAxisAngle( axisCross, fAngle * fInverter );
} else if (axisDot < (Real)0) {
matrix.FromAxisAngle( Vector3<Real>::UNIT_X, (Real)180 * Math<Real>::DEG_TO_RAD * fInverter );
} else {
matrix = Matrix3<Real>::IDENTITY;
}
}
示例3: MinimalBoxForAngles
//----------------------------------------------------------------------------
static void MinimalBoxForAngles (int iQuantity, const Vector3* akPoint,
Real afAngle[3], Box3& rkBox)
{
Real fCos0 = Math::Cos(afAngle[0]);
Real fSin0 = Math::Sin(afAngle[0]);
Real fCos1 = Math::Cos(afAngle[1]);
Real fSin1 = Math::Sin(afAngle[1]);
Vector3 kAxis(fCos0*fSin1,fSin0*fSin1,fCos1);
Matrix3 kRot;
kRot.FromAxisAngle(kAxis,afAngle[2]);
Vector3 kMin = akPoint[0]*kRot, kMax = kMin;
for (int i = 1; i < iQuantity; i++)
{
Vector3 kTest = akPoint[i]*kRot;
if ( kTest.x < kMin.x )
kMin.x = kTest.x;
else if ( kTest.x > kMax.x )
kMax.x = kTest.x;
if ( kTest.y < kMin.y )
kMin.y = kTest.y;
else if ( kTest.y > kMax.y )
kMax.y = kTest.y;
if ( kTest.z < kMin.z )
kMin.z = kTest.z;
else if ( kTest.z > kMax.z )
kMax.z = kTest.z;
}
Vector3 kMid = 0.5f*(kMax + kMin);
Vector3 kRng = 0.5f*(kMax - kMin);
rkBox.Center() = kRot*kMid;
rkBox.Axis(0) = kRot.GetColumn(0);
rkBox.Axis(1) = kRot.GetColumn(1);
rkBox.Axis(2) = kRot.GetColumn(2);
rkBox.Extent(0) = kRng.x;
rkBox.Extent(1) = kRng.y;
rkBox.Extent(2) = kRng.z;
}
示例4: Volume
//----------------------------------------------------------------------------
static Real Volume (const Real* afAngle, void* pvUserData)
{
int iQuantity = ((PointArray*)pvUserData)->m_iQuantity;
const Vector3* akPoint = ((PointArray*)pvUserData)->m_akPoint;
Real fCos0 = Math::Cos(afAngle[0]);
Real fSin0 = Math::Sin(afAngle[0]);
Real fCos1 = Math::Cos(afAngle[1]);
Real fSin1 = Math::Sin(afAngle[1]);
Vector3 kAxis(fCos0*fSin1,fSin0*fSin1,fCos1);
Matrix3 kRot;
kRot.FromAxisAngle(kAxis,afAngle[2]);
Vector3 kMin = akPoint[0]*kRot, kMax = kMin;
for (int i = 1; i < iQuantity; i++)
{
Vector3 kTest = akPoint[i]*kRot;
if ( kTest.x < kMin.x )
kMin.x = kTest.x;
else if ( kTest.x > kMax.x )
kMax.x = kTest.x;
if ( kTest.y < kMin.y )
kMin.y = kTest.y;
else if ( kTest.y > kMax.y )
kMax.y = kTest.y;
if ( kTest.z < kMin.z )
kMin.z = kTest.z;
else if ( kTest.z > kMax.z )
kMax.z = kTest.z;
}
Real fVolume = (kMax.x-kMin.x)*(kMax.y-kMin.y)*(kMax.z-kMin.z);
return fVolume;
}
示例5: DefWindowProc
//---------------------------------------------------------------------------
long FAR PASCAL
WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static Vector3 s_kEye;
static QuadricSurface::ConvexPolyhedron s_kPoly;
static int s_iSteps = 0;
static Matrix3 s_kRot;
Matrix3 kIncr;
switch ( message )
{
case WM_CREATE:
{
CreatePoly(s_kPoly);
QuadricSurface::TessellateSphere(s_iSteps,s_kPoly);
// initial camera orientation and eye point
s_kRot.FromAxisAngle(Vector3::UNIT_Z,0.0f);
s_kEye = 2.0f*s_kRot.GetColumn(2);
return 0;
}
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hDC = BeginPaint(hWnd,&ps);
DrawPolyhedron(hDC,s_kEye,s_kRot,s_kPoly);
EndPaint(hWnd,&ps);
return 0;
}
case WM_KEYDOWN:
{
switch ( wParam )
{
case VK_LEFT:
{
// rotate camera about its 'up' vector
kIncr.FromAxisAngle(s_kRot.GetColumn(1),0.1f);
s_kRot = kIncr*s_kRot;
s_kEye = 2.0f*s_kRot.GetColumn(2);
InvalidateRect(hWnd,NULL,TRUE);
break;
}
case VK_RIGHT:
{
// rotate camera about its 'up' vector
kIncr.FromAxisAngle(s_kRot.GetColumn(1),-0.1f);
s_kRot = kIncr*s_kRot;
s_kEye = 2.0f*s_kRot.GetColumn(2);
InvalidateRect(hWnd,NULL,TRUE);
break;
}
case VK_UP:
{
// rotate camera about its 'right' vector
kIncr.FromAxisAngle(s_kRot.GetColumn(0),-0.1f);
s_kRot = kIncr*s_kRot;
s_kEye = 2.0f*s_kRot.GetColumn(2);
InvalidateRect(hWnd,NULL,TRUE);
break;
}
case VK_DOWN:
{
// rotate camera about its 'right' vector
kIncr.FromAxisAngle(s_kRot.GetColumn(0),0.1f);
s_kRot = kIncr*s_kRot;
s_kEye = 2.0f*s_kRot.GetColumn(2);
InvalidateRect(hWnd,NULL,TRUE);
break;
}
}
return 0;
}
case WM_CHAR:
{
switch ( wParam )
{
case '+':
case '=':
{
s_iSteps++;
QuadricSurface::DeletePolyhedron(s_kPoly);
CreatePoly(s_kPoly);
QuadricSurface::TessellateSphere(s_iSteps,s_kPoly);
InvalidateRect(hWnd,NULL,TRUE);
break;
}
case '-':
case '_':
{
if ( s_iSteps >= 1 )
{
s_iSteps--;
QuadricSurface::DeletePolyhedron(s_kPoly);
CreatePoly(s_kPoly);
QuadricSurface::TessellateSphere(s_iSteps,s_kPoly);
InvalidateRect(hWnd,NULL,TRUE);
}
break;
//.........这里部分代码省略.........