本文整理汇总了C#中AForge.Math.Matrix4x4类的典型用法代码示例。如果您正苦于以下问题:C# Matrix4x4类的具体用法?C# Matrix4x4怎么用?C# Matrix4x4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Matrix4x4类属于AForge.Math命名空间,在下文中一共展示了Matrix4x4类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ToArrayTest
public void ToArrayTest( )
{
Matrix4x4 matrix = new Matrix4x4( );
matrix.V00 = 1;
matrix.V01 = 2;
matrix.V02 = 3;
matrix.V03 = 4;
matrix.V10 = 5;
matrix.V11 = 6;
matrix.V12 = 7;
matrix.V13 = 8;
matrix.V20 = 9;
matrix.V21 = 10;
matrix.V22 = 11;
matrix.V23 = 12;
matrix.V30 = 13;
matrix.V31 = 14;
matrix.V32 = 15;
matrix.V33 = 16;
float[] array = matrix.ToArray( );
for ( int i = 0; i < 16; i++ )
{
Assert.AreEqual<float>( array[i], (float) ( i + 1 ) );
}
}
开发者ID:Kenneth-Posey,项目名称:aforge-clone,代码行数:31,代码来源:Matrix4x4Test.cs
示例2: updateAngle
public void updateAngle(float y,float p,float r)
{
worldMatrix =
Matrix4x4.CreateTranslation(new Vector3(0, 0, 0)) *
Matrix4x4.CreateFromYawPitchRoll(y, p, r);
Recalculate();
}
开发者ID:forkbomb,项目名称:pikto,代码行数:7,代码来源:ViewPosit.cs
示例3: AddMatricesTest
public void AddMatricesTest( )
{
Matrix4x4 expectedResult = new Matrix4x4( );
expectedResult.V00 = 3;
expectedResult.V01 = 3;
expectedResult.V02 = 7;
expectedResult.V03 = 7;
expectedResult.V10 = 8;
expectedResult.V11 = 5;
expectedResult.V12 = 5;
expectedResult.V13 = 2;
expectedResult.V20 = 6;
expectedResult.V21 = 5;
expectedResult.V22 = 5;
expectedResult.V23 = 4;
expectedResult.V30 = 3;
expectedResult.V31 = 7;
expectedResult.V32 = 3;
expectedResult.V33 = 7;
Matrix4x4 result = a1 + a2;
Assert.AreEqual<bool>( true, ApproximateEquals( result, expectedResult ) );
}
开发者ID:rpwjanzen,项目名称:blinken,代码行数:28,代码来源:Matrix4x4Test.cs
示例4: setTransformatinMatrix
public void setTransformatinMatrix(Matrix4x4 m)
{
estimate00.Text = m.V00.ToString();
estimate10.Text = m.V01.ToString();
estimate20.Text = m.V01.ToString();
estimate30.Text = m.V03.ToString();
estimate01.Text = m.V10.ToString();
estimate11.Text = m.V11.ToString();
estimate21.Text = m.V12.ToString();
estimate31.Text = m.V13.ToString();
estimate02.Text = m.V20.ToString();
estimate12.Text = m.V21.ToString();
estimate22.Text = m.V22.ToString();
estimate32.Text = m.V23.ToString();
estimate03.Text = m.V30.ToString();
estimate13.Text = m.V31.ToString();
estimate23.Text = m.V32.ToString();
estimate33.Text = m.V33.ToString();
}
开发者ID:forkbomb,项目名称:pikto,代码行数:25,代码来源:FormInfoPosition.Designer.cs
示例5: SetMatrix
public void SetMatrix( Matrix4x4 matrix )
{
float[] array = matrix.ToArray( );
for ( int i = 0, k = 0; i < 4; i++ )
{
for ( int j = 0; j < 4; j++, k++ )
{
string textBoxName = string.Format( "i{0}_j{1}_Box", i, j );
if ( textBoxes.ContainsKey( textBoxName ) )
{
textBoxes[textBoxName].Text = FormatFloat( array[k] );
}
}
}
}
开发者ID:Kenneth-Posey,项目名称:aforge-clone,代码行数:17,代码来源:MatrixControl.cs
示例6: Compute
/// <summary>
/// Executes the transform calculations (T = Z*X).
/// </summary>
///
/// <returns>Transform matrix T.</returns>
///
/// <remarks>Calling this method also updates the Transform property.</remarks>
///
public void Compute(DenavitHartenbergParameters parameters)
{
// Calculate Z with Z = TranslationZ(d).RotationZ(theta)
Z = Matrix4x4.Multiply
(
Matrix4x4.CreateTranslation(new Vector3(0f, 0f, (float)parameters.Offset)),
Matrix4x4.CreateRotationZ((float)parameters.Theta)
);
// Calculate X with X = TranslationX(radius).RotationZ(alpha)
X = Matrix4x4.Multiply
(
Matrix4x4.CreateTranslation(new Vector3((float)parameters.Radius, 0f, 0f)),
Matrix4x4.CreateRotationX((float)parameters.Alpha)
);
// Calculate the transform with T=Z.X
Transform = Matrix4x4.Multiply(Z, X);
}
开发者ID:accord-net,项目名称:framework,代码行数:27,代码来源:DenavitHartenbergMatrix.cs
示例7: setTransformatinMatrix
public void setTransformatinMatrix(Matrix4x4 m)
{
est00.Text = m.V00.ToString();
est01.Text = m.V01.ToString();
est02.Text = m.V01.ToString();
est03.Text = m.V03.ToString();
est10.Text = m.V10.ToString();
est11.Text = m.V11.ToString();
est12.Text = m.V12.ToString();
est13.Text = m.V13.ToString();
est20.Text = m.V20.ToString();
est21.Text = m.V21.ToString();
est22.Text = m.V22.ToString();
est23.Text = m.V23.ToString();
est30.Text = m.V30.ToString();
est31.Text = m.V31.ToString();
est32.Text = m.V32.ToString();
est33.Text = m.V33.ToString();
}
开发者ID:forkbomb,项目名称:pikto,代码行数:22,代码来源:WpfInfoPosition.xaml.cs
示例8: ViewPosit
public ViewPosit(int w,int h)
{
sizeRect = 50;
wImg = w;
hImg = h;
center = new Point(w / 2, h / 2);
pktList = new System.Collections.Generic.List<Point>();
pktList.Add(new Point(center.X + sizeRect, center.Y + sizeRect));
pktList.Add(new Point(center.X - sizeRect, center.Y + sizeRect));
pktList.Add(new Point(center.X - sizeRect, center.Y - sizeRect));
pktList.Add(new Point(center.X + sizeRect, center.Y - sizeRect));
colorList = new System.Collections.Generic.List<Bgr>();
colorList.Add(new Bgr(255,0,0));
colorList.Add(new Bgr(0,255,0));
colorList.Add(new Bgr(0,0,255));
colorList.Add(new Bgr(255,0,255));
worldMatrix = Matrix4x4.Identity;
viewMatrix = Matrix4x4.CreateLookAt(new Vector3(0, 0, 5), new Vector3(0, 0, 0));
perspectiveMatrix = Matrix4x4.CreatePerspective(1, 1, 1, 1000);
}
开发者ID:forkbomb,项目名称:pikto,代码行数:22,代码来源:ViewPosit.cs
示例9: setMtx
public void setMtx(Matrix4x4 mtx)
{
m00.Text = mtx.V00.ToString();
m01.Text = mtx.V01.ToString();
m02.Text = mtx.V02.ToString();
m03.Text = mtx.V03.ToString();
m10.Text = mtx.V10.ToString();
m11.Text = mtx.V11.ToString();
m12.Text = mtx.V12.ToString();
m13.Text = mtx.V13.ToString();
m20.Text = mtx.V20.ToString();
m21.Text = mtx.V21.ToString();
m22.Text = mtx.V22.ToString();
m23.Text = mtx.V23.ToString();
m30.Text = mtx.V30.ToString();
m31.Text = mtx.V31.ToString();
m32.Text = mtx.V32.ToString();
m33.Text = mtx.V33.ToString();
}
开发者ID:forkbomb,项目名称:pikto,代码行数:22,代码来源:SimpleMatrix44.xaml.cs
示例10: WorldRendererControl
public WorldRendererControl( )
{
InitializeComponent( );
objectPoints = new Vector3[]
{
new Vector3( 0, 0, 0 ),
};
colors = new Color[]
{
Color.White,
};
lines = new int[0, 2];
// create default matrices
worldMatrix = Matrix4x4.Identity;
viewMatrix = Matrix4x4.CreateLookAt( new Vector3( 0, 0, 5 ), new Vector3( 0, 0, 0 ) );
perspectiveMatrix = Matrix4x4.CreatePerspective( 1, 1, 1, 1000 );
Recalculate( );
}
开发者ID:CanerPatir,项目名称:framework,代码行数:23,代码来源:WorldRendererControl.cs
示例11: Add
/// <summary>
/// Adds corresponding components of two matrices.
/// </summary>
///
/// <param name="matrix1">The matrix to add to.</param>
/// <param name="matrix2">The matrix to add to the first matrix.</param>
///
/// <returns>Returns a matrix which components are equal to sum of corresponding
/// components of the two specified matrices.</returns>
///
public static Matrix4x4 Add(Matrix4x4 matrix1, Matrix4x4 matrix2)
{
return matrix1 + matrix2;
}
开发者ID:CanerPatir,项目名称:framework,代码行数:14,代码来源:Matrix4x4.cs
示例12: Matrix4x4
/// <summary>
/// Adds corresponding components of two matrices.
/// </summary>
///
/// <param name="matrix1">The matrix to add to.</param>
/// <param name="matrix2">The matrix to add to the first matrix.</param>
///
/// <returns>Returns a matrix which components are equal to sum of corresponding
/// components of the two specified matrices.</returns>
///
public static Matrix4x4 operator +(Matrix4x4 matrix1, Matrix4x4 matrix2)
{
Matrix4x4 m = new Matrix4x4();
m.V00 = matrix1.V00 + matrix2.V00;
m.V01 = matrix1.V01 + matrix2.V01;
m.V02 = matrix1.V02 + matrix2.V02;
m.V03 = matrix1.V03 + matrix2.V03;
m.V10 = matrix1.V10 + matrix2.V10;
m.V11 = matrix1.V11 + matrix2.V11;
m.V12 = matrix1.V12 + matrix2.V12;
m.V13 = matrix1.V13 + matrix2.V13;
m.V20 = matrix1.V20 + matrix2.V20;
m.V21 = matrix1.V21 + matrix2.V21;
m.V22 = matrix1.V22 + matrix2.V22;
m.V23 = matrix1.V23 + matrix2.V23;
m.V30 = matrix1.V30 + matrix2.V30;
m.V31 = matrix1.V31 + matrix2.V31;
m.V32 = matrix1.V32 + matrix2.V32;
m.V33 = matrix1.V33 + matrix2.V33;
return m;
}
开发者ID:CanerPatir,项目名称:framework,代码行数:36,代码来源:Matrix4x4.cs
示例13: Multiply
/// <summary>
/// Multiplies two specified matrices.
/// </summary>
///
/// <param name="matrix1">Matrix to multiply.</param>
/// <param name="matrix2">Matrix to multiply by.</param>
///
/// <returns>Return new matrix, which the result of multiplication of the two specified matrices.</returns>
///
public static Matrix4x4 Multiply(Matrix4x4 matrix1, Matrix4x4 matrix2)
{
return matrix1 * matrix2;
}
开发者ID:CanerPatir,项目名称:framework,代码行数:13,代码来源:Matrix4x4.cs
示例14: MultiplyMatricesTest
public void MultiplyMatricesTest( )
{
Matrix4x4 expectedResult = new Matrix4x4( );
expectedResult.V00 = 23;
expectedResult.V01 = 29;
expectedResult.V02 = 21;
expectedResult.V03 = 27;
expectedResult.V10 = 27;
expectedResult.V11 = 21;
expectedResult.V12 = 29;
expectedResult.V13 = 23;
expectedResult.V20 = 24;
expectedResult.V21 = 27;
expectedResult.V22 = 23;
expectedResult.V23 = 26;
expectedResult.V30 = 26;
expectedResult.V31 = 23;
expectedResult.V32 = 27;
expectedResult.V33 = 24;
Matrix4x4 result = a1 * a2;
Assert.AreEqual<bool>( true, ApproximateEquals( result, expectedResult ) );
}
开发者ID:Kenneth-Posey,项目名称:aforge-clone,代码行数:28,代码来源:Matrix4x4Test.cs
示例15: PerformProjection
private AForge.Point[] PerformProjection( Vector3[] model, Matrix4x4 transformationMatrix, int viewSize )
{
AForge.Point[] projectedPoints = new AForge.Point[model.Length];
for ( int i = 0; i < model.Length; i++ )
{
Vector3 scenePoint = ( transformationMatrix * model[i].ToVector4( ) ).ToVector3( );
projectedPoints[i] = new AForge.Point(
(int) ( scenePoint.X / scenePoint.Z * viewSize ),
(int) ( scenePoint.Y / scenePoint.Z * viewSize ) );
}
return projectedPoints;
}
开发者ID:centrolutions,项目名称:AForge.NET,代码行数:15,代码来源:MainForm.cs
示例16: CreatePerspective
/// <summary>
/// Creates a perspective projection matrix.
/// </summary>
///
/// <param name="width">Width of the view volume at the near view plane.</param>
/// <param name="height">Height of the view volume at the near view plane.</param>
/// <param name="nearPlaneDistance">Distance to the near view plane.</param>
/// <param name="farPlaneDistance">Distance to the far view plane.</param>
///
/// <returns>Return a perspective projection matrix.</returns>
///
/// <exception cref="ArgumentOutOfRangeException">Both near and far view planes' distances must be greater than zero.</exception>
/// <exception cref="ArgumentException">Near plane must be closer than the far plane.</exception>
///
public static Matrix4x4 CreatePerspective(float width, float height, float nearPlaneDistance, float farPlaneDistance)
{
if (nearPlaneDistance <= 0)
throw new ArgumentOutOfRangeException("nearPlaneDistance ", "Near plane distance must be greater than zero.");
if (farPlaneDistance <= 0)
throw new ArgumentOutOfRangeException("farPlaneDistance", "Far view plane distance must be greater than zero.");
if (nearPlaneDistance >= farPlaneDistance)
throw new ArgumentException("Near plane must be closer than the far plane.", "farPlaneDistance");
Matrix4x4 m = new Matrix4x4();
m.V00 = 2.0f * nearPlaneDistance / width;
m.V11 = 2.0f * nearPlaneDistance / height;
m.V22 = farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
m.V32 = -1;
m.V23 = (nearPlaneDistance * farPlaneDistance) / (nearPlaneDistance - farPlaneDistance);
return m;
}
开发者ID:CanerPatir,项目名称:framework,代码行数:36,代码来源:Matrix4x4.cs
示例17: UpdateTransformationMatrix
// Calculate new world transformation matrix
private void UpdateTransformationMatrix( )
{
float rYaw = (float) ( yaw / 180 * Math.PI );
float rPitch = (float) ( pitch / 180 * Math.PI );
float rRoll = (float) ( roll / 180 * Math.PI );
transformationMatrix =
Matrix4x4.CreateTranslation( new Vector3( xObject, yObject, zObject ) ) *
Matrix4x4.CreateFromYawPitchRoll( rYaw, rPitch, rRoll );
worldRendererControl.WorldMatrix = transformationMatrix;
transformationMatrixControl.SetMatrix( transformationMatrix );
targetTransformationMatrixControl.SetMatrix( viewMatrix * transformationMatrix );
UpdateProjectedPoints( );
EstimatePose( );
}
开发者ID:Kenneth-Posey,项目名称:aforge-clone,代码行数:18,代码来源:MainForm.cs
示例18: UpdateViewMatrix
// Calculate new view transformation matrix
private void UpdateViewMatrix( )
{
viewMatrix = Matrix4x4.CreateLookAt(
new Vector3( xCamera, yCamera, zCamera ),
new Vector3( xLookAt, yLookAt, zLookAt ) );
worldRendererControl.ViewMatrix = viewMatrix;
viewMatrixControl.SetMatrix( viewMatrix );
targetTransformationMatrixControl.SetMatrix( viewMatrix * transformationMatrix );
UpdateProjectedPoints( );
EstimatePose( );
}
开发者ID:Kenneth-Posey,项目名称:aforge-clone,代码行数:14,代码来源:MainForm.cs
示例19: ApproximateEquals
private bool ApproximateEquals( Matrix4x4 matrix1, Matrix4x4 matrix2 )
{
// TODO: better algorithm should be put into the framework actually
return (
( System.Math.Abs( matrix1.V00 - matrix2.V00 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V01 - matrix2.V01 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V02 - matrix2.V02 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V03 - matrix2.V03 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V10 - matrix2.V10 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V11 - matrix2.V11 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V12 - matrix2.V12 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V13 - matrix2.V13 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V20 - matrix2.V20 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V21 - matrix2.V21 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V22 - matrix2.V22 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V23 - matrix2.V23 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V30 - matrix2.V30 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V31 - matrix2.V31 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V32 - matrix2.V32 ) <= Epsilon ) &&
( System.Math.Abs( matrix1.V33 - matrix2.V33 ) <= Epsilon )
);
}
开发者ID:Kenneth-Posey,项目名称:aforge-clone,代码行数:25,代码来源:Matrix4x4Test.cs
示例20: CompareMatrixWithArray
private void CompareMatrixWithArray( Matrix4x4 matrix, float[] array )
{
float[] matrixArray = matrix.ToArray( );
for ( int i = 0; i < 16; i++ )
{
Assert.AreEqual<float>( matrixArray[i], array[i] );
}
}
开发者ID:Kenneth-Posey,项目名称:aforge-clone,代码行数:9,代码来源:Matrix4x4Test.cs
注:本文中的AForge.Math.Matrix4x4类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论