Exemplo n.º 1
0
        public static Vector GetCorrespondingVector(Vector vector, Matrix matrix, AxisConstraint axisConstraint)
        {
            if (matrix.HasInverse)
            {
                if (axisConstraint != null)
                {
                    vector = axisConstraint.GetConstrainedVector(vector);
                }
                Matrix matrix1 = matrix;
                matrix1.Invert();
                return(vector * matrix1);
            }
            Vector vector1 = matrix.Transform(new Vector(1.0, 0.0));
            double length1 = vector1.Length;
            Vector vector2 = matrix.Transform(new Vector(0.0, 1.0));
            double length2 = vector2.Length;

            if (FloatingPointArithmetic.IsVerySmall(length1) && FloatingPointArithmetic.IsVerySmall(length2))
            {
                return(new Vector(0.0, 0.0));
            }
            Vector vector3 = length1 > length2 ? vector1 : vector2;

            vector3.Normalize();
            double num1 = vector * vector3;
            double num2 = length1 * length1 + length2 * length2;

            return(new Vector(length1 * num1 / num2, length2 * num1 / num2));
        }
Exemplo n.º 2
0
 private bool IsMatrixValidForTransform(Matrix matrix)
 {
     if (FloatingPointArithmetic.IsFiniteDouble(matrix.M11) && FloatingPointArithmetic.IsFiniteDouble(matrix.M12) && (FloatingPointArithmetic.IsFiniteDouble(matrix.M21) && FloatingPointArithmetic.IsFiniteDouble(matrix.M22)) && FloatingPointArithmetic.IsFiniteDouble(matrix.OffsetX))
     {
         return(FloatingPointArithmetic.IsFiniteDouble(matrix.OffsetY));
     }
     return(false);
 }
Exemplo n.º 3
0
 private double PrepareLength(double length)
 {
     if (!FloatingPointArithmetic.IsFiniteDouble(length))
     {
         return(0.0);
     }
     return(Math.Max(length, 0.0));
 }
Exemplo n.º 4
0
 private double PreparePosition(double pos)
 {
     if (!FloatingPointArithmetic.IsFiniteDouble(pos))
     {
         return(0.0);
     }
     return(pos);
 }