当前位置: 首页>>代码示例>>C#>>正文


C# Matrix3类代码示例

本文整理汇总了C#中Matrix3的典型用法代码示例。如果您正苦于以下问题:C# Matrix3类的具体用法?C# Matrix3怎么用?C# Matrix3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Matrix3类属于命名空间,在下文中一共展示了Matrix3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Distance

 public Distance(Vector3 centre,
     Vector3 scale,
     Matrix3 rotation,
     string distanceFunction,
     double distanceMinimum,
     double distanceScale,
     Vector3 distanceOffset,
     int distanceIterations,
     Vector3 distanceExtents,
     double stepSize)
 {
     _Material = new Material();
     _Position = new Vector3();
     _Scale = new Vector3();
     _Rotation = new Matrix3();
     _Position = centre;
     _Scale = scale;
     _Rotation = rotation;
     _DistanceFunction = distanceFunction;
     _DistanceMinimum = distanceMinimum;
     _DistanceScale = distanceScale;
     _DistanceOffset = distanceOffset;
     _DistanceIterations = distanceIterations;
     _DistanceExtents = distanceExtents;
     _StepSize = stepSize;
 }
开发者ID:dom767,项目名称:woofractal,代码行数:26,代码来源:Distance.cs

示例2: getEigenvalues

    // Reference : Oliver K. Smith: Eigenvalues of a symmetric 3 × 3 matrix. Commun. ACM 4(4): 168 (1961) 
	// find the eigenvalues of a 3x3 symmetric matrix
    //NOTE: I'm doing some post-processing on them to turn them into singular values
	Vector3 getEigenvalues(Matrix3 mat) {
		var m = (mat.trace()) / 3;
		var K = mat - (Matrix3.I()*m); // K = mat - I*tr(mat)
		var q = K.determinant() / 2;
		var tempForm = K*K;
	 
		var p = tempForm.sumCells() / 6;
	 
		// NB in Smith's paper he uses phi = (1/3)*arctan(sqrt(p*p*p - q*q)/q), which is equivalent to below:
		var phi = (1/3)*Mathf.Acos(q/Mathf.Sqrt(p*p*p));
	 
		if (Mathf.Abs(q) >= Mathf.Abs(Mathf.Sqrt(p*p*p))) {
			phi = 0;
		}
	 
		if (phi < 0) {
			phi = phi + Mathf.PI/3;
		}
	 
		var eig1 = m + 2*Mathf.Sqrt(p)*Mathf.Cos(phi);
		var eig2 = m - Mathf.Sqrt(p)*(Mathf.Cos(phi) + Mathf.Sqrt(3)*Mathf.Sin(phi));
		var eig3 = m - Mathf.Sqrt(p)*(Mathf.Cos(phi) - Mathf.Sqrt(3)*Mathf.Sin(phi));
	    // return a singular values vector
		return new Vector3(Mathf.Sqrt(Mathf.Abs(eig1)),
                           Mathf.Sqrt(Mathf.Abs(eig2)),
                           Mathf.Sqrt(Mathf.Abs(eig3)));
	}
开发者ID:guozanhua,项目名称:kinect-oculus-demo,代码行数:30,代码来源:ZigSteadyDetector.cs

示例3: WooState

        public WooState()
        {
            _Rotation = new Matrix3();
            _Rotation.MakeIdentity();
            int idx = 0;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 0;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;

            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 0;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 0;
            _MengerPattern[idx++] = 0;
            _MengerPattern[idx++] = 0;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 0;
            _MengerPattern[idx++] = 1;

            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 0;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;
            _MengerPattern[idx++] = 1;
        }
开发者ID:dom767,项目名称:woofractal,代码行数:35,代码来源:WooState.cs

示例4: RunTests

        public void RunTests()
        {
            Matrix3 a, b;
            DXMtx dxa, dxb;

            a = new Matrix3(3, 1, 2, 1, 1, 2, 2, 3, 1);
            b = new Matrix3(4, 2, 1, 3, 1, 2, 2, 1, 2);
            dxa = new DXMtx();
            dxb = new DXMtx();

            dxa.M11 = 3; dxa.M12 = 1; dxa.M13 = 2;
            dxa.M21 = 1; dxa.M22 = 1; dxa.M23 = 2;
            dxa.M31 = 2; dxa.M32 = 3; dxa.M33 = 1;
            dxb.M11 = 4; dxb.M12 = 2; dxb.M13 = 1;
            dxb.M21 = 3; dxb.M22 = 1; dxb.M23 = 2;
            dxb.M31 = 2; dxb.M32 = 1; dxb.M33 = 2;

            Roll = 45;
            Yaw = 10;
            Pitch = 30;

            TestAdd(a, b, dxa, dxb);
            TestSub(a, b, dxa, dxb);
            TestMul(a, b, dxa, dxb);
            TestTranspose(a, dxa);
            TestInvert(a, dxa);
            TestRotations();

            PrintResults(a, b);
        }
开发者ID:Innabus,项目名称:Innabus,代码行数:30,代码来源:Mtx3Regression.cs

示例5: Fractal

 public Fractal(Vector3 centre,
     Vector3 scale,
     Matrix3 rotation,
     double distanceMinimum,
     double distanceScale,
     Vector3 distanceOffset,
     int distanceIterations,
     Vector3 distanceExtents,
     double stepSize,
     List<FractalIteration> fractalIterations,
     int fractalIterationCount,
     int colourIterationCount,
     int deMode)
 {
     _Material = new Material();
     _Position = new Vector3();
     _Scale = new Vector3();
     _Rotation = new Matrix3();
     _Position = centre;
     _Scale = scale;
     _Rotation = rotation;
     _DistanceMinimum = distanceMinimum;
     _DistanceScale = distanceScale;
     _DistanceOffset = distanceOffset;
     _DistanceIterations = distanceIterations;
     _DistanceExtents = distanceExtents;
     _StepSize = stepSize;
     _FractalIterations = fractalIterations;
     _FractalIterationCount = fractalIterationCount;
     _ColourIterationCount = colourIterationCount;
     _DEMode = deMode;
 }
开发者ID:dom767,项目名称:woofractal,代码行数:32,代码来源:Fractal.cs

示例6: AdditionTest_Success

        public void AdditionTest_Success()
        {
            Matrix3 a = new Matrix3(new double[,]
            {
                {1.0, 2.0, 3.0},
                {4.0, 5.0, 6.0},
                {7.0, 8.0, 9.0}
            });

            Matrix3 b = new Matrix3(new double[,]
            {
                {1.0, 2.0, 3.0},
                {4.0, 5.0, 6.0},
                {7.0, 8.0, 9.0}
            });

            Matrix3 result = a + b;

            Matrix3 expected = new Matrix3(new double[,]
            {
                {2.0, 4.0, 6.0},
                {8.0, 10.0, 12.0},
                {14.0, 16.0, 18.0}
            });

            Assert.AreEqual(expected, result);
        }
开发者ID:patricknboyd,项目名称:VectorMath,代码行数:27,代码来源:Matrix3_Test.cs

示例7: TransformNormalize

 public void TransformNormalize(Matrix3 m)
 {
     float[] result = m.VectorMultiply (new float[] { X, Y, Z, W });
     X = result [0] / result [3];
     Y = result [1] / result [3];
     Z = result [2];
     W = 1;
 }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:8,代码来源:Point3.cs

示例8: ProjectOnto

 public void ProjectOnto(ref Matrix3 transform, ref Vector2 axisNormal, out Vector2 projection)
 {
     Vector2 halfWidth, halfHeight;
     CalculateExtents(ref transform, out halfWidth, out halfHeight);
     halfWidth -= transform.Origin; halfHeight -= transform.Origin;
     projection.X = Vector2.Dot(halfWidth, axisNormal);
     projection.Y = Vector2.Dot(halfHeight, axisNormal);
 }
开发者ID:Raidenthequick,项目名称:delta,代码行数:8,代码来源:Box.cs

示例9: SurfacePoint

 public SurfacePoint(Vector3 position, Triangle face, Vector3 barycentricCoords, float surfaceOffset, Matrix3 orientationMatrix)
 {
     Position = position;
     Face = face;
     BarycentricCoords = barycentricCoords;
     SurfaceOffset = surfaceOffset;
     Psi = 0;
     OriginalMatrix = orientationMatrix;
 }
开发者ID:dtegunov,项目名称:membranorama,代码行数:9,代码来源:SurfacePoint.cs

示例10: Cylinder

 public Cylinder(Vector3 centre, Vector3 scale, Matrix3 rotation)
 {
     _Material = new Material();
     _Position = new Vector3();
     _Scale = new Vector3();
     _Rotation = new Matrix3();
     _Position = centre;
     _Scale = scale;
     _Rotation = rotation;
 }
开发者ID:dom767,项目名称:woofractal,代码行数:10,代码来源:Cylinder.cs

示例11: CalculateAABB

        public override void CalculateAABB(ref Matrix3 transform, out AABB aabb)
        {
            Vector2 halfWidth, halfHeight;
            CalculateExtents(ref transform, out halfWidth, out halfHeight);

            Vector2 halfWidthOther, halfHeightOther;
            CalculateOtherExtents(ref transform, out halfWidthOther, out halfHeightOther);
   
            aabb.Min = Vector2.Min(halfWidth, halfWidthOther) + Vector2.Min(halfHeight, halfHeightOther) - transform.Origin;
            aabb.Max = Vector2.Max(halfWidth, halfWidthOther) + Vector2.Max(halfHeight, halfHeightOther) - transform.Origin;
        }
开发者ID:Raidenthequick,项目名称:delta,代码行数:11,代码来源:Box.cs

示例12: Constructor_FromFlatArray_Empty_Success

        public void Constructor_FromFlatArray_Empty_Success()
        {
            double[] empty = new double[0];

            Matrix3 mat = new Matrix3(empty);

            Assert.AreEqual(0.0, mat[0, 0], Epsilon);
            Assert.AreEqual(0.0, mat[1, 0], Epsilon);
            Assert.AreEqual(0.0, mat[1, 2], Epsilon);
            Assert.AreEqual(0.0, mat[2, 2], Epsilon);
        }
开发者ID:patricknboyd,项目名称:VectorMath,代码行数:11,代码来源:Matrix3_Test.cs

示例13: FreeLookAt

        public virtual void FreeLookAt(Vector3 targetAbsRef, Vector3 upRelRef)
        {

            //Vector v1 = new Vector3(0, 0, -1);
            //Vector moveV = _staticModel.Position - vector;
            //Vector v2 = moveV.RotateBy(_staticModel.Orientation.W, 0, 1, 0);

            /*Vector forward = lookAt.Normalized();
            Vector right = Vector::Cross(up.Normalized(), forward);
            Vector up = Vector::Cross(forward, right);*/
            Vector3 forward ;
            if (_mainModel.IsChild)
            {
                //Normalizing target and transforming it to local system
                forward = Geometric.Quaternion_Rotate(_mainModel.ParentModel.Orientation.Inverted(), targetAbsRef.Normalized()) - _mainModel.ParentModel.Position;
            }
            else
            {
                //Normalizing target.. local system is the same as world system
                forward = targetAbsRef.Normalized();
            }
            //Normalizing upVector (we are assuming it is expressed in local system)
            Vector3 eye = _mainModel.PositionRelative.Normalized();
            Vector3 up = upRelRef.Normalized();

            //Insert manual imprecision to avoid singularity
            if( Vector3.Dot(forward,up) == 1 )
            {
                forward.X += 0.001f;
                forward.Y += 0.001f;
                forward.Z += 0.001f;
            }

            //float angle = (float)Math.Acos( Vector3.DotProduct(current,targetAbsRef) );
            //Vector3 rotAxis = Vector3.CrossProduct(current, forward).Normalize();
            //Vector3 right = Vector3.CrossProduct(forward, up);

            Matrix4 lookAt_result = Matrix4.LookAt( eye.X, eye.Y, eye.Z, forward.X, forward.Y, forward.Z, up.X, up.Y, up.Z );
            Matrix3 targetRelOrientation_matrix = new Matrix3(lookAt_result);
            Quaternion targetRelOrientation_quaternion = Quaternion.FromMatrix(targetRelOrientation_matrix);

            /*
            Quaternion targetRelOrientation_quaternion = new Quaternion();
            targetRelOrientation_quaternion.W = (float)Math.Sqrt((double)(1.0f + right.X + up.Y + forward.Z)) * 0.5f;
            float w4_recip = 1.0f / (4.0f * targetRelOrientation_quaternion.W);
            targetRelOrientation_quaternion.X = (forward.Y - up.Z) * w4_recip;
            targetRelOrientation_quaternion.Y = (right.Z - forward.X) * w4_recip;
            targetRelOrientation_quaternion.Z = (up.X - right.Y) * w4_recip;
            */

            _mainModel.OrientationRelative = Quaternion.Slerp(_mainModel.OrientationRelative, targetRelOrientation_quaternion, Game.DeltaTime * 0.001f);

        }
开发者ID:fakkoweb,项目名称:AsTKoids,代码行数:53,代码来源:Orientable.cs

示例14: OutsideBox

 public static Func<Vector3, bool> OutsideBox(double length, double width, double height, Vector3 center, Matrix3 orientation)
 {
     if (!orientation.IsOrthoganol) throw new ArgumentException(nameof(orientation) + "must be orthoganol.");
     return pos =>
     {
         Vector3 r = (pos - center).Rotate(orientation.InverseMatrix());
         if (Math.Abs(r.X) > length) return true;
         if (Math.Abs(r.Y) > width) return true;
         if (Math.Abs(r.Z) > height) return true;
         return false;
     };
 }
开发者ID:domisterwoozy,项目名称:LabBox,代码行数:12,代码来源:ClampFunctions.cs

示例15: GetMatrices

        public override List<Matrix3> GetMatrices()
        {
            Debug.Assert(Controls.Count == 9);
            var m = Controls;
            Matrix3 mat = new Matrix3(
                m[0], m[1], m[2],
                m[3], m[4], m[5],
                m[6], m[7], m[8]
            );

            return new List<Matrix3> { mat };
        }
开发者ID:Norbyte,项目名称:lslib,代码行数:12,代码来源:DaConstant32f.cs


注:本文中的Matrix3类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。