本文整理汇总了C++中SVector3::Normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ SVector3::Normalize方法的具体用法?C++ SVector3::Normalize怎么用?C++ SVector3::Normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVector3
的用法示例。
在下文中一共展示了SVector3::Normalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckSeparatingAxis
//---------------------------------------------------------------------------------------------------
//
// Private: CheckAxis
//
// Return true if the axis perpendicular to u = v2 - v1 is a separating axis (i.e., no overlap)
// Therefore, we project to this perpendicular axis
//
// Currently only works with 2D objects on the x-y plane
//
//
//---------------------------------------------------------------------------------------------------
bool CXDMVoxel::CheckSeparatingAxis( const CXDMVoxel & oVoxel, const CXDMVoxel & oTestVoxel,
const SVector3 &oV1, const SVector3 &oV2) const
{
SVector3 oDir = oV2 - oV1;
oDir.Normalize();
// rotate 90 degress y <- x, x <- -y
Float tmp = oDir.m_fY;
oDir.m_fY = oDir.m_fX;
oDir.m_fX = - tmp;
Float fMin = MAX_FLOAT;
Float fMax = MIN_FLOAT;
for ( int i = 0; i < 3; i ++ )
{
Float fAxisProjection = Dot( oTestVoxel.pVertex[i], oDir );
if ( fAxisProjection < fMin )
fMin = fAxisProjection;
if ( fAxisProjection > fMax )
fMax = fAxisProjection;
}
for ( int i = 0; i < 3; i ++ )
{
Float fVertex = Dot( oVoxel.pVertex[i], oDir );
if( fVertex <= fMax && fVertex >= fMin ) // if intersecting
{
return false;
}
}
return true;
}
示例2: GetAlignmentRotation
//--------------------------------------------------------------------------------------------------------
//
// GetAlignRotation
// -- Given *UNIT vector* oRef, oVec, return a matrix that rotates oVec -> oRef
//
//--------------------------------------------------------------------------------------------------------
SMatrix3x3 GetAlignmentRotation( const SVector3 &oVecDir, const SVector3 &oRefDir )
{
SVector3 oAxis = Cross( oVecDir, oRefDir );
Float fAngle = acos( Dot( oVecDir, oRefDir ) );
oAxis.Normalize();
SMatrix3x3 oRes;
oRes.BuildRotationAboutAxis( oAxis, fAngle );
return oRes;
}