本文整理汇总了C#中Matrix4.Transpose方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4.Transpose方法的具体用法?C# Matrix4.Transpose怎么用?C# Matrix4.Transpose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4
的用法示例。
在下文中一共展示了Matrix4.Transpose方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyMatrixTransform
public static void ApplyMatrixTransform(TransformMatrix transformMat, matrix m)
{
var transform = transformMat.transform;
var values = m.Values;
var mat = new Matrix4(
(float)values[0], (float)values[1], (float)values[2], (float)values[3],
(float)values[4], (float)values[5], (float)values[6], (float)values[7],
(float)values[8], (float)values[9], (float)values[10], (float)values[11],
(float)values[12], (float)values[13], (float)values[14], (float)values[15]
);
mat.Transpose();
transformMat.matrix *= mat;
var translation = mat.ExtractTranslation();
transform.Translation += translation;
if (translation != Vector3.Zero)
transform.Flags |= (int)Transform.TransformFlags.HasTranslation;
var rotation = mat.ExtractRotation();
transform.Rotation *= rotation;
if (rotation != Quaternion.Identity)
transform.Flags |= (int)Transform.TransformFlags.HasRotation;
var scale = mat.ExtractScale();
transform.ScaleShear[0, 0] *= scale[0];
transform.ScaleShear[1, 1] *= scale[1];
transform.ScaleShear[2, 2] *= scale[2];
if (transform.ScaleShear != Matrix3.Identity)
transform.Flags |= (int)Transform.TransformFlags.HasScaleShear;
}
示例2: WorldToColor
public static Vector2 WorldToColor(Vector3 pt)
{
Matrix4 rotationMatrix = new Matrix4(
new Vector4(9.9984628826577793e-01f, 1.2635359098409581e-03f, -1.7487233004436643e-02f, 0),
new Vector4(-1.4779096108364480e-03f, 9.9992385683542895e-01f, -1.2251380107679535e-02f, 0),
new Vector4(1.7470421412464927e-02f, 1.2275341476520762e-02f, 9.9977202419716948e-01f, 0),
new Vector4(0, 0, 0, 1));
Vector3 translation = new Vector3(1.9985242312092553e-02f, -7.4423738761617583e-04f, -1.0916736334336222e-02f);
rotationMatrix.Transpose();
Matrix4 finalMatrix = rotationMatrix * Matrix4.CreateTranslation(-translation);
const double fx_rgb = 5.2921508098293293e+02f;
const double fy_rgb = 5.2556393630057437e+02f;
const double cx_rgb = 3.2894272028759258e+02f;
const double cy_rgb = 2.6748068171871557e+02f;
Vector3 transformedPos = Vector3.Transform(pt, finalMatrix);
float invZ = 1.0f / transformedPos.Z;
Vector2 result;
result.X = (float)Math.Round((transformedPos.X * fx_rgb * invZ) + cx_rgb);
result.Y = (float)Math.Round((transformedPos.Y * fy_rgb * invZ) + cy_rgb);
return result;
}
示例3: SetupProjection
internal void SetupProjection ()
{
if (Width <= 0 || Height <= 0)
return;
Matrix4 model = Matrix4.Mult (Matrix4.CreateRotationX (-xangle), Matrix4.CreateRotationZ (-yangle));
float aspect = (float)Width / Height;
if (aspect > 1) {
Matrix4 scale = Matrix4.Scale (aspect);
model = Matrix4.Mult (model, scale);
}
view = Matrix4.Mult (model, Matrix4.LookAt (0, -70, 5, 0, 10, 0, 0, 1, 0));
GL.Viewport (0, 0, Width, Height);
projection = Matrix4.CreatePerspectiveFieldOfView (OpenTK.MathHelper.DegreesToRadians (42.0f), aspect, 1.0f, 200.0f);
projection = Matrix4.Mult (view, projection);
normalMatrix = Matrix4.Invert (view);
normalMatrix.Transpose ();
}
示例4: SetupProjection
internal void SetupProjection (int width, int height)
{
Matrix4 model = Matrix4.Mult (Matrix4.CreateRotationX (-xAngle), Matrix4.CreateRotationZ (-yAngle));
float aspect = (float)width / height;
if (aspect > 1) {
Matrix4 scale = Matrix4.Scale (aspect);
model = Matrix4.Mult (model, scale);
}
view = Matrix4.Mult (model, Matrix4.LookAt (0, -70, 5, 0, 10, 0, 0, 1, 0));
GL.Viewport (0, 0, width, height);
projection = Matrix4.CreatePerspectiveFieldOfView (OpenTK.MathHelper.DegreesToRadians (42.0f), aspect, 1.0f, 200.0f);
projection = Matrix4.Mult (view, projection);
normalMatrix = Matrix4.Invert (view);
normalMatrix.Transpose ();
Width = width;
Height = height;
}
示例5: Matrix4_InvertTest
public void Matrix4_InvertTest()
{
Matrix4 a = new Matrix4(1, 2, 2, 2,
2, 2, 1, 1,
1, 2, 1, 0,
1, 2, 2, 1);
Matrix4 b = new Matrix4(-1, 1, -1, 1,
1, -0.5f, 1.5f, -1.5f,
-1, 0, -1, 2,
1, 0, 0, -1);
Assert.AreEqual(b, a.Invert());
Matrix4 ai = a.Invert();
Assert.AreEqual(b, ai);
// A(A-1) = (A-1)A = I
Assert.AreEqual(Matrix4.Identity, a * a.Invert());
Assert.AreEqual(Matrix4.Identity, a.Invert() * a);
// (AB)-1 = B-1A-1
Matrix4 c = new Matrix4(2, 3, 2, 2,
3, 3, 3, 3,
3, 2, 2, 3,
3, 2, 1, 2);
// TODO: Fail in release mode.
//Assert.AreEqual((a * c).Invert(), c.Invert() * a.Invert());
// (M-1)-1 = M
Assert.AreEqual(a, a.Invert().Invert());
// I-1 = I
Assert.AreEqual(Matrix4.Identity, Matrix4.Identity.Invert());
// (MT)-1 = (M-1)T
Assert.AreEqual(a.Transpose().Invert(), a.Invert().Transpose());
}
示例6: Matrix4_TransposeTest
public void Matrix4_TransposeTest()
{
Matrix4 a = new Matrix4(0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Assert.AreEqual(new Matrix4(0, 4, 8, 12,
1, 5, 9, 13,
2, 6, 10, 14,
3, 7, 11, 15), a.Transpose());
Matrix4 at = a.Transpose();
Assert.AreEqual(a.Transpose(), at);
// (ABC)T = CT*BT*CT
Matrix4 b = new Matrix4(16, 17, 18, 19,
20, 21, 22, 23,
24, 25, 26, 27,
28, 29, 30, 31);
Matrix4 c = new Matrix4(32, 33, 34, 35,
36, 37, 38, 39,
40, 41, 42, 43,
44, 45, 46, 47);
Assert.AreEqual((a * b * c).Transpose(),
c.Transpose() * b.Transpose() * a.Transpose());
}
示例7: UpdateViewMatrix
private void UpdateViewMatrix()
{
// Derivation:
// view = (orientation*translation)^-1
// => view = translation^-1 * orientation^-1
// => view = translation^-1 * orientation^T ; orientation is ONB
// where translation^-1 is simply the negated translation vector.
_view = GetOrientation();
_view *= Matrix4.CreateFromAxisAngle(_view.Row0.Xyz, _pitchAngle);
_view.Transpose();
_view = Matrix4.CreateTranslation(-_translation) * _view;
_dirty = false;
}
示例8: SetupProjection
internal void SetupProjection (int width, int height)
{
Matrix4 model = Matrix4.CreateTranslation (-(float)length/2f + .5f, (float)(-(length*0.5)/System.Math.Sqrt (3) + .5/System.Math.Sqrt (3)), (float)(-length/System.Math.Sqrt (6) + .5/System.Math.Sqrt (6)));
model = Matrix4.Mult (model, Matrix4.Mult (Matrix4.CreateRotationX (-XAngle), Matrix4.CreateRotationZ (-YAngle)));
model = Matrix4.Mult (model, Matrix4.Scale(5f/length));
float aspect = (float)width / height;
if (aspect > 1) {
Matrix4 scale = Matrix4.Scale (aspect);
model = Matrix4.Mult (model, scale);
}
view = Matrix4.Mult (model, Matrix4.LookAt (0, -10, .8f, 0, 10, -1.6f, 0, 1, 0));
projection = Matrix4.CreatePerspectiveFieldOfView (OpenTK.MathHelper.DegreesToRadians (42.0f), aspect, 1.0f, 200.0f);
projection = Matrix4.Mult (view, projection);
normalMatrix = Matrix4.Invert (view);
normalMatrix.Transpose ();
Width = width;
Height = height;
}
示例9: double_traspose
public static void double_traspose() {
var m = new Matrix4(_incremented);
m.Transpose();
m.Transpose();
Assert.Equal(_incremented, m);
}
示例10: form3Dto2D
private Vector3 form3Dto2D( Vector3 our3DPoint )
{
Matrix4 modelviewMatrix = new Matrix4();
Matrix4 projectionMatrix = new Matrix4();
int[] viewport = new int[ 4 ];
Vector3 pos = new Vector3( our3DPoint );
GL.GetFloat( GetPName.ModelviewMatrix, out modelviewMatrix );
GL.GetFloat( GetPName.ProjectionMatrix, out projectionMatrix );
GL.GetInteger( GetPName.Viewport, viewport );
projectionMatrix.Transpose();
pos = Vector3.Transform( pos, modelviewMatrix );
pos = Vector3.Transform( pos, projectionMatrix );
pos.X /= pos.Z;
pos.Y /= pos.Z;
pos.X = ( pos.X + 1 ) * ( viewport[ 0 ] + viewport[ 2 ] ) / 2;
pos.Y = ( pos.Y + 1 ) * ( viewport[ 1 ] + viewport[ 3 ] ) / 2;
pos.Y = ( ( viewport[ 0 ] + viewport[ 2 ] ) / 2 ) - pos.Y;
//pos.X = ( ( viewport[ 1 ] + viewport[ 3 ] ) / 2 ) + pos.X;
return new Vector3( pos.X, pos.Y, 1f );
}