コード例 #1
0
ファイル: Matrix4d.cs プロジェクト: lymanzhang/SpatialSlur
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        /// <param name="epsilon"></param>
        /// <returns></returns>
        public bool ApproxEquals(ref Matrix4d other, double epsilon = D.ZeroTolerance)
        {
            return
                (SlurMath.ApproxEquals(M00, other.M00, epsilon) &&
                 SlurMath.ApproxEquals(M01, other.M01, epsilon) &&
                 SlurMath.ApproxEquals(M02, other.M02, epsilon) &&
                 SlurMath.ApproxEquals(M03, other.M03, epsilon) &&

                 SlurMath.ApproxEquals(M10, other.M10, epsilon) &&
                 SlurMath.ApproxEquals(M11, other.M11, epsilon) &&
                 SlurMath.ApproxEquals(M12, other.M12, epsilon) &&
                 SlurMath.ApproxEquals(M13, other.M13, epsilon) &&

                 SlurMath.ApproxEquals(M20, other.M20, epsilon) &&
                 SlurMath.ApproxEquals(M21, other.M21, epsilon) &&
                 SlurMath.ApproxEquals(M22, other.M22, epsilon) &&
                 SlurMath.ApproxEquals(M23, other.M23, epsilon) &&

                 SlurMath.ApproxEquals(M30, other.M30, epsilon) &&
                 SlurMath.ApproxEquals(M31, other.M31, epsilon) &&
                 SlurMath.ApproxEquals(M32, other.M32, epsilon) &&
                 SlurMath.ApproxEquals(M33, other.M33, epsilon));
        }
コード例 #2
0
ファイル: Matrix4d.cs プロジェクト: lymanzhang/SpatialSlur
        /// <summary>
        /// Returns true on success
        /// </summary>
        public bool Invert(out Matrix4d result)
        {
            // inversion via cofactors
            // https://en.wikipedia.org/wiki/Minor_(linear_algebra)

            var d = Determinant;

            if (d > 0.0)
            {
                d = 1.0 / d;

                result.M00 = Minor00 * d;
                result.M01 = -Minor10 * d;
                result.M02 = Minor20 * d;
                result.M03 = -Minor30 * d;

                result.M10 = -Minor01 * d;
                result.M11 = Minor11 * d;
                result.M12 = -Minor21 * d;
                result.M13 = Minor31 * d;

                result.M20 = Minor02 * d;
                result.M21 = -Minor12 * d;
                result.M22 = Minor22 * d;
                result.M23 = -Minor32 * d;

                result.M30 = -Minor03 * d;
                result.M31 = Minor13 * d;
                result.M32 = -Minor23 * d;
                result.M33 = Minor33 * d;

                return(true);
            }

            result = Identity;
            return(false);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="random"></param>
        /// <param name="interval"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public static void NextMatrix4d(this Random random, Intervald interval, out Matrix4d result)
        {
            result = new Matrix4d(
                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble()),

                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble()),

                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble()),

                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble()),
                interval.Evaluate(random.NextDouble())
                );
        }
コード例 #4
0
ファイル: Matrix4d.cs プロジェクト: lymanzhang/SpatialSlur
 /// <summary>
 /// Applies this transformation to the given transformation in place.
 /// </summary>
 /// <param name="other"></param>
 public Matrix4d Apply(Matrix4d other)
 {
     return(Apply(ref other));
 }
コード例 #5
0
ファイル: Matrix4d.cs プロジェクト: lymanzhang/SpatialSlur
 /// <summary>
 ///
 /// </summary>
 /// <param name="m0"></param>
 /// <param name="m1"></param>
 /// <param name="t"></param>
 /// <returns></returns>
 public static Matrix4d Lerp(Matrix4d m0, Matrix4d m1, double t)
 {
     return(m0.LerpTo(m1, t));
 }
コード例 #6
0
ファイル: Matrix4d.cs プロジェクト: lymanzhang/SpatialSlur
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <param name="epsilon"></param>
 /// <returns></returns>
 public bool ApproxEquals(Matrix4d other, double epsilon = D.ZeroTolerance)
 {
     return(ApproxEquals(ref other, epsilon));
 }
コード例 #7
0
ファイル: Matrix4d.cs プロジェクト: lymanzhang/SpatialSlur
 /// <summary>
 /// Applies the transpose of this transformation to the given transformation.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public Matrix4d ApplyTranspose(Matrix4d other)
 {
     return(ApplyTranspose(ref other));
 }