本文整理汇总了C#中Axiom.Math.Quaternion.Inverse方法的典型用法代码示例。如果您正苦于以下问题:C# Quaternion.Inverse方法的具体用法?C# Quaternion.Inverse怎么用?C# Quaternion.Inverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Axiom.Math.Quaternion
的用法示例。
在下文中一共展示了Quaternion.Inverse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComposeInverse
/// <summary>
/// Creates an inverse translation Matrix
/// </summary>
/// <param name="translation"></param>
/// <param name="scale"></param>
/// <param name="orientation"></param>
/// <returns></returns>
public static Matrix4 ComposeInverse( Vector3 translation, Vector3 scale, Quaternion orientation )
{
// Invert the parameters
Vector3 invTranslate = -translation;
Vector3 invScale = new Vector3( 1f / scale.x, 1f / scale.y, 1f / scale.z );
Quaternion invRot = orientation.Inverse();
// Because we're inverting, order is translation, rotation, scale
// So make translation relative to scale & rotation
invTranslate *= invScale; // scale
invTranslate = invRot * invTranslate; // rotate
// Next, make a 3x3 rotation matrix and apply inverse scale
Matrix3 rot3x3, scale3x3;
rot3x3 = invRot.ToRotationMatrix();
scale3x3 = Matrix3.Zero;
scale3x3.m00 = invScale.x;
scale3x3.m11 = invScale.y;
scale3x3.m22 = invScale.z;
// Set up final matrix with scale, rotation and translation
Matrix4 result = scale3x3 * rot3x3;
result.Translation = invTranslate;
return result;
}
示例2: _generateCurvedIllusionPlaneVertexData
private void _generateCurvedIllusionPlaneVertexData( HardwareVertexBuffer vertexBuffer, int ySegments, int xSegments, float xSpace, float halfWidth, float ySpace, float halfHeight, Matrix4 xform, bool firstTime, bool normals, Quaternion orientation, float curvature, float uTiles, float vTiles, int numberOfTexCoordSets, ref Vector3 min, ref Vector3 max, ref float maxSquaredLength )
{
// Imagine a large sphere with the camera located near the top
// The lower the curvature, the larger the sphere
// Use the angle from viewer to the points on the plane
// Credit to Aftershock for the general approach
Real cameraPosition; // Camera position relative to sphere center
// Derive sphere radius
//Vector3 vertPos; // position relative to camera
//Real sphDist; // Distance from camera to sphere along box vertex vector
// Vector3 camToSph; // camera position to sphere
Real sphereRadius;// Sphere radius
// Actual values irrelevant, it's the relation between sphere radius and camera position that's important
Real sphRadius = 100.0f;
Real camDistance = 5.0f;
sphereRadius = sphRadius - curvature;
cameraPosition = sphereRadius - camDistance;
Vector3 vec;
Vector3 norm;
float sphereDistance;
unsafe
{
// lock the vertex buffer
IntPtr data = vertexBuffer.Lock( BufferLocking.Discard );
float* pData = (float*)data.ToPointer();
for ( int y = 0; y < ySegments + 1; ++y )
{
for ( int x = 0; x < xSegments + 1; ++x )
{
// centered on origin
vec.x = ( x * xSpace ) - halfWidth;
vec.y = ( y * ySpace ) - halfHeight;
vec.z = 0.0f;
// transform by orientation and distance
vec = xform * vec;
// assign to geometry
*pData++ = vec.x;
*pData++ = vec.y;
*pData++ = vec.z;
// build bounds as we go
if ( firstTime )
{
min = vec;
max = vec;
maxSquaredLength = vec.LengthSquared;
firstTime = false;
}
else
{
min.Floor( vec );
max.Ceil( vec );
maxSquaredLength = Utility.Max( maxSquaredLength, vec.LengthSquared );
}
if ( normals )
{
norm = Vector3.UnitZ;
norm = orientation * norm;
*pData++ = vec.x;
*pData++ = vec.y;
*pData++ = vec.z;
}
// generate texture coordinates, normalize position, modify by orientation to return +y up
vec = orientation.Inverse() * vec;
vec.Normalize();
// find distance to sphere
sphereDistance = Utility.Sqrt( cameraPosition * cameraPosition * ( vec.y * vec.y - 1.0f ) + sphereRadius * sphereRadius ) - cameraPosition * vec.y;
vec.x *= sphereDistance;
vec.z *= sphereDistance;
// use x and y on sphere as texture coordinates, tiled
float s = vec.x * ( 0.01f * uTiles );
float t = vec.z * ( 0.01f * vTiles );
for ( int i = 0; i < numberOfTexCoordSets; i++ )
{
*pData++ = s;
*pData++ = ( 1 - t );
}
} // x
} // y
// unlock the buffer
vertexBuffer.Unlock();
} // unsafe
}
示例3: MakeInverseTransform
/// <summary>
/// Internal method for building an inverse Matrix4 from orientation / scale / position.
/// </summary>
/// <remarks>
/// As makeTransform except it build the inverse given the same data as makeTransform, so
/// performing -translation, 1/scale, -rotate in that order.
/// </remarks>
protected void MakeInverseTransform( Vector3 position, Vector3 scale, Quaternion orientation, ref Matrix4 destMatrix )
{
// Invert the parameters
Vector3 invTranslate = -position;
Vector3 invScale = Vector3.Zero;
invScale.x = 1.0f / scale.x;
invScale.y = 1.0f / scale.y;
invScale.z = 1.0f / scale.z;
Quaternion invRot = orientation.Inverse();
// Because we're inverting, order is translation, rotation, scale
// So make translation relative to scale & rotation
invTranslate.x *= invScale.x; // scale
invTranslate.y *= invScale.y; // scale
invTranslate.z *= invScale.z; // scale
invTranslate = invRot * invTranslate; // rotate
// Next, make a 3x3 rotation matrix and apply inverse scale
Matrix3 rot3x3 = invRot.ToRotationMatrix();
Matrix3 scale3x3 = Matrix3.Zero;
scale3x3.m00 = invScale.x;
scale3x3.m11 = invScale.y;
scale3x3.m22 = invScale.z;
// Set up final matrix with scale & rotation
destMatrix = scale3x3 * rot3x3;
destMatrix.Translation = invTranslate;
}