Пример #1
0
 public static Matrix CreateProjectionMatrix(VectorR3 n)
 {
     return(new Matrix(
                new Vector(1 - n.X * n.X, -n.X * n.Y, -n.X * n.Z),
                new Vector(-n.Y * n.X, 1 - n.Y * n.Y, -n.Y * n.Z),
                new Vector(-n.Z * n.X, -n.Z * n.Y, 1 - n.Z * n.Z)));
 }
Пример #2
0
 public static Matrix CreateReflection(VectorR3 n)
 {
     return(new Matrix(
                new Vector(1 - 2 * n.X * n.X, -2 * n.X * n.Y, -2 * n.X * n.Z),
                new Vector(-2 * n.Y * n.X, 1 - 2 * n.Y * n.Y, -2 * n.Y * n.Z),
                new Vector(-2 * n.Z * n.X, -2 * n.Z * n.Y, 1 - 2 * n.Z * n.Z)
                ));
 }
Пример #3
0
        private static Matrix CreateRotationMatrixAboutVectorRads(double rads, VectorR3 about)
        {
            var cosineOfAngle     = Cos(rads);
            var differenceFromOne = 1 - cosineOfAngle;
            var sineOfAngle       = Sin(rads);

            return(new Matrix(
                       new Vector(
                           about.X * about.X * differenceFromOne + cosineOfAngle,
                           about.X * about.Y * differenceFromOne - about.Z * sineOfAngle,
                           about.X * about.Z * differenceFromOne + about.Y * sineOfAngle),
                       new Vector(
                           about.X * about.Y * differenceFromOne + about.Z * sineOfAngle,
                           about.Y * about.Y * differenceFromOne + cosineOfAngle,
                           about.Y * about.Z * differenceFromOne - about.X * sineOfAngle),
                       new Vector(
                           about.X * about.Z * differenceFromOne - about.Y * sineOfAngle,
                           about.Z * about.Y * differenceFromOne + about.X * sineOfAngle,
                           about.Z * about.Z * differenceFromOne + cosineOfAngle)));
        }
Пример #4
0
 public static Matrix CreateRotationMatrixAboutVectorDegs(double deg, VectorR3 about)
 {
     return(CreateRotationMatrixAboutVectorRads(deg * PI / 180, about));
 }