本文整理汇总了C#中Matrix3x3类的典型用法代码示例。如果您正苦于以下问题:C# Matrix3x3类的具体用法?C# Matrix3x3怎么用?C# Matrix3x3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Matrix3x3类属于命名空间,在下文中一共展示了Matrix3x3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetTransformMatrix
/// <summary>
/// Set transform matrix
/// </summary>
/// <param name="transformMatrix">transform matrix</param>
public /*internal*/ virtual void SetTransformMatrix(Matrix3x3 transformMatrix)
{
if (transformMatrix != null)
{
CurrentTransformMatrix = transformMatrix;
// check if current transform is transformed
IsTransformed = transformMatrix.IsTransformed;
if (IsTransformed)
{
#region calculate inverted matrix
Matrix3x3 InvertedMatrix = transformMatrix.InvertedMatrix;
if (InvertedMatrix != null)
{
InvertedMatrixSx = InvertedMatrix.Sx;
InvertedMatrixSy = InvertedMatrix.Sy;
InvertedMatrixShy = InvertedMatrix.Shy;
InvertedMatrixShx = InvertedMatrix.Shx;
InvertedMatrixTx = InvertedMatrix.Tx;
InvertedMatrixTy = InvertedMatrix.Ty;
}
else
{
InvertedMatrixSx = 0.0;
InvertedMatrixSy = 0.0;
InvertedMatrixShy = 0.0;
InvertedMatrixShx = 0.0;
InvertedMatrixTx = 0.0;
InvertedMatrixTy = 0.0;
}
#endregion
}
}
}
示例2: GetSymInverse33
public Matrix3x3 GetSymInverse33(Matrix3x3 M)
{
float det = Vector3.Dot(Column1, Vector3.Cross(Column2, Column3));
if (det != 0.0f)
{
det = 1.0f / det;
}
float a11 = Column1.X, a12 = Column2.X, a13 = Column3.X;
float a22 = Column2.Y, a23 = Column3.Y;
float a33 = Column3.Z;
M.Column1.X = det * (a22 * a33 - a23 * a23);
M.Column1.Y = det * (a13 * a23 - a12 * a33);
M.Column1.Z = det * (a12 * a23 - a13 * a22);
M.Column2.X = M.Column1.Y;
M.Column2.Y = det * (a11 * a33 - a13 * a13);
M.Column2.Z = det * (a13 * a12 - a11 * a23);
M.Column3.X = M.Column1.Z;
M.Column3.Y = M.Column2.Z;
M.Column3.Z = det * (a11 * a22 - a12 * a12);
return M;
}
示例3: Test_Determinant
public void Test_Determinant()
{
var m = new Matrix3x3 (1, 2, 1,
1, 1, -1,
2, 1, 1);
Assert.AreEqual (-5, m.Determinant);
}
示例4: computeEulerFromMatrixXYZ
///<summary>
/// Receive a rotation matrix of type Matrix4
/// Return a Vector3Float containing the rotation around the 3 axis
///</summary>
public static Vecto3Float computeEulerFromMatrixXYZ(Matrix3x3 m)
{
Vecto3Float sol = new Vecto3Float();
if (m.matrix[0, 2] < 1f)
{
if (m.matrix[0, 2] > -1f)
{
sol.X = (float)Math.Atan2(-m.matrix[1, 2], m.matrix[2, 2]);
sol.Y = (float)Math.Asin(-(m.matrix[0, 2]));
sol.Z = (float)Math.Atan2(-m.matrix[0, 1], m.matrix[0, 0]);
}
else
{
sol.X = -(float)Math.Atan2(m.matrix[1, 0], m.matrix[1, 1]);
sol.Y = -(float)(Math.PI) / 2;
sol.Z = 0f;
}
}
else
{
sol.X = (float)Math.Atan2(m.matrix[1, 0], m.matrix[1, 1]);
sol.Y = (float)(Math.PI) / 2;
sol.Z = 0f;
}
return sol;
}
示例5: ConstructorValuesAreAccessibleByIndexer
public void ConstructorValuesAreAccessibleByIndexer()
{
Matrix3x3 matrix3x3;
matrix3x3 = new Matrix3x3();
for (int x = 0; x < matrix3x3.Columns; x++)
{
for (int y = 0; y < matrix3x3.Rows; y++)
{
Assert.Equal(0, matrix3x3[x, y], Epsilon);
}
}
double value = 33.33;
matrix3x3 = new Matrix3x3(value);
for (int x = 0; x < matrix3x3.Columns; x++)
{
for (int y = 0; y < matrix3x3.Rows; y++)
{
Assert.Equal(value, matrix3x3[x, y], Epsilon);
}
}
GenerateFilledMatrixWithValues(out matrix3x3);
for (int y = 0; y < matrix3x3.Rows; y++)
{
for (int x = 0; x < matrix3x3.Columns; x++)
{
Assert.Equal(y * matrix3x3.Columns + x, matrix3x3[x, y], Epsilon);
}
}
}
示例6: NoRotationJointDescriptor
public NoRotationJointDescriptor(Matrix3x3 anchorOrientationALocal, Matrix3x3 anchorOrientationBLocal, IRigidBody rigidBodyA = null, IRigidBody rigidBodyB = null, object userData = null) : this()
{
AnchorOrientationALocal = anchorOrientationALocal;
AnchorOrientationBLocal = anchorOrientationBLocal;
RigidBodyA = rigidBodyA;
RigidBodyB = rigidBodyB;
UserData = userData;
}
示例7: ConstantValuesAreCorrect
public void ConstantValuesAreCorrect()
{
Matrix3x3 matrix3x3 = new Matrix3x3();
Assert.Equal(3, matrix3x3.Columns);
Assert.Equal(3, matrix3x3.Rows);
Assert.Equal(Matrix3x3.ColumnCount, matrix3x3.Columns);
Assert.Equal(Matrix3x3.RowCount, matrix3x3.Rows);
}
示例8: ReadData
public override void ReadData(GrnBinaryReader reader, int directoryOffset)
{
reader.Seek((int)(this.Offset + directoryOffset), SeekOrigin.Begin);
this.ParentIndex = reader.ReadInt32();
this.Position = reader.ReadVector3D();
this.Rotation = reader.ReadQuaternion();
this.Scale = reader.ReadMatrix3x3();
if (this.GetReadDataLength() != this.GetWriteDataLength()) throw new Exception("bbb");
}
示例9: Matrix3x3
public static Matrix3x3 operator -(Matrix3x3 m1, Matrix3x3 m2)
{
Matrix3x3 kSum = new Matrix3x3();
for (int iRow = 0; iRow < 3; iRow++) {
for (int iCol = 0; iCol < 3; iCol++) {
kSum.m[iRow,iCol] = m1.m[iRow,iCol] - m2.m[iRow,iCol];
}
}
return kSum;
}
示例10: Rotate12
static void Rotate12(ref SymmetricMatrix3x3 vtav, ref Matrix3x3 v)
{
if (vtav.m12 == 0)
{
return;
}
float c, s;
Schur2.Rot12(ref vtav, out c, out s);
Givens.Rot12_post(ref v, c, s);
}
示例11: GetSymmetricSvd
static void GetSymmetricSvd(SymmetricMatrix3x3 a, out SymmetricMatrix3x3 vtav, out Matrix3x3 v, float tol, int max_sweeps)
{
vtav = a;
v = Matrix3x3.identity;
float delta = tol * vtav.FNorm;
for (int i = 0; i < max_sweeps && vtav.Off > delta; ++i)
{
Rotate01(ref vtav, ref v);
Rotate02(ref vtav, ref v);
Rotate12(ref vtav, ref v);
}
}
示例12: transpose
public static Matrix3x3 transpose(Matrix3x3 toTra)
{
Matrix3x3 result = new Matrix3x3();
for (int i = 0; i < DIMENSION; i++)
{
for (int j = 0; j < DIMENSION; j++)
{
result.matrix[j,i] = toTra.matrix[i,j];
}
}
return result;
}
示例13: Write
public void Write(Matrix3x3 m)
{
this.Write(m.A1);
this.Write(m.A2);
this.Write(m.A3);
this.Write(m.B1);
this.Write(m.B2);
this.Write(m.B3);
this.Write(m.C1);
this.Write(m.C2);
this.Write(m.C3);
}
示例14: Write
public void Write(Matrix3x3 value)
{
Write(value.m00);
Write(value.m01);
Write(value.m02);
Write(value.m10);
Write(value.m11);
Write(value.m12);
Write(value.m20);
Write(value.m21);
Write(value.m22);
}
示例15: Test_Equals
public void Test_Equals()
{
var delta = 0.00001f;
var a = new Matrix3x3 (1, 1, 1,
1, 1, 1,
1, 1, 1);
var b = new Matrix3x3 (1 + delta, 1 + delta, 1 + delta,
1 + delta, 1 + delta, 1 + delta,
1 + delta, 1 + delta, 1 + delta);
Assert.IsTrue (a.Equals (b)); // 誤差許容
Assert.IsFalse (a == b); // 厳密な比較
Assert.IsFalse (a.GetHashCode () == b.GetHashCode ()); // 厳密な比較に基づくハッシュ値
}