Exemplo n.º 1
0
        /// <summary>
        /// Creates a 2D rotation matrix with the specified angle in radians.
        /// </summary>
        /// <returns>2D Rotation Matrix</returns>
        public static M22f Rotation(float angleInRadians)
        {
            float cos = Fun.Cos(angleInRadians);
            float sin = Fun.Sin(angleInRadians);

            return(new M22f(cos, -sin,
                            sin, cos));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a 2D rotation matrix with the specified angle in radians.
        /// </summary>
        /// <returns>2D Rotation Matrix</returns>
        public static M2__x2t__ Rotation(__ft__ angleInRadians)
        {
            __ft__ cos = Fun.Cos(angleInRadians);
            __ft__ sin = Fun.Sin(angleInRadians);

            return(new M2__x2t__(cos, -sin,
                                 sin, cos));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates new rotational matrix for "float value"-radians around Z-Axis.
        /// </summary>
        /// <returns>Rotational matrix.</returns>
        public static M44f RotationZ(float angleRadians)
        {
            float cos = Fun.Cos(angleRadians);
            float sin = Fun.Sin(angleRadians);

            return(new M44f(cos, -sin, 0, 0,
                            sin, cos, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates new rotational matrix for "double value"-radians around Z-Axis.
        /// </summary>
        /// <returns>Rotational matrix.</returns>
        public static M44d RotationZ(double angleRadians)
        {
            double cos = Fun.Cos(angleRadians);
            double sin = Fun.Sin(angleRadians);

            return(new M44d(cos, -sin, 0, 0,
                            sin, cos, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates new rotational matrix for "__ft__ value"-radians around Z-Axis.
        /// </summary>
        /// <returns>Rotational matrix.</returns>
        public static M4__x4t__ RotationZ(__ft__ angleRadians)
        {
            __ft__ cos = Fun.Cos(angleRadians);
            __ft__ sin = Fun.Sin(angleRadians);

            return(new M4__x4t__(cos, -sin, 0, 0,
                                 sin, cos, 0, 0,
                                 0, 0, 1, 0,
                                 0, 0, 0, 1));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create from Rodrigues axis-angle vactor
        /// </summary>
        public static __rot3t__ FromAngleAxis(__v3t__ angleAxis)
        {
            __ft__ theta2 = angleAxis.LengthSquared;

            if (theta2 > Constant <__ft__> .PositiveTinyValue)
            {
                var theta     = Fun.Sqrt(theta2);
                var thetaHalf = theta / 2;
                var k         = Fun.Sin(thetaHalf) / theta;
                return(new __rot3t__(Fun.Cos(thetaHalf), k * angleAxis));
            }
            else
            {
                return(new __rot3t__(1, 0, 0, 0));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Return an IEnumerable of points on the circle's circumference, optionally repeating the first point as the last.
        /// </summary>
        /// <param name="tesselation">number of distinct points to generate. the actual number of points returned depends on the <para>duplicateClosePoint</para> parameter. must be 3 or larger.</param>
        /// <param name="duplicateClosePoint">if true, the first point is repeated as the last</param>
        /// <returns>IEnumerable of points on the circle's circumference. if diplicateClosePoint is true, <para>tesselation</para>+1 points are returned.</returns>
        public IEnumerable <V3d> Points(int tesselation, bool duplicateClosePoint = false)
        {
            if (tesselation < 3)
            {
                throw new ArgumentOutOfRangeException("tesselation", "tesselation must be at least 3.");
            }

            var off = 0;

            if (duplicateClosePoint)
            {
                off = 1;
            }
            for (int i = 0; i < tesselation + off; i++)
            {
                var angle = ((double)i) / tesselation * Constant.PiTimesTwo;
                yield return(Center + AxisU * Fun.Cos(angle) + AxisV * Fun.Sin(angle));
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// One real root of the equation: x^3 + c2 x^2 + c1 x + c0 = 0.
        /// </summary>
        public static double OneRealRootOfNormed(
            double c2, double c1, double c0
            )
        {
            // ------ eliminate quadric term (x = y - c2/3): x^3 + p x + q = 0
            double d   = c2 * c2;
            double p3  = 1 / 3.0 * /* p */ (-1 / 3.0 * d + c1);
            double q2  = 1 / 2.0 * /* q */ ((2 / 27.0 * d - 1 / 3.0 * c1) * c2 + c0);
            double p3c = p3 * p3 * p3;

            d = q2 * q2 + p3c;
            if (d < 0) // -------------- casus irreducibilis: three real roots
            {
                return(2 * Fun.Sqrt(-p3) * Fun.Cos(1 / 3.0
                                                   * Fun.Acos(-q2 / Fun.Sqrt(-p3c))) - 1 / 3.0 * c2);
            }
            d = Fun.Sqrt(d);  // one triple root or a single and a double root
            return(Fun.Cbrt(d - q2) - Fun.Cbrt(d + q2) - 1 / 3.0 * c2);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Return real roots of the equation: x^3 + p x + q = 0
        /// Double and triple solutions are returned as replicated values.
        /// Imaginary and non existing solutions are returned as NaNs.
        /// </summary>
        public static Triple <double> RealRootsOfDepressed(
            double p, double q)
        {
            double p3 = 1 / 3.0 * p, q2 = 1 / 2.0 * q;
            double p3c = p3 * p3 * p3, d = q2 * q2 + p3c;

            if (d < 0) // ---------- casus irreducibilis: three real solutions
            {
                double phi = 1 / 3.0 * Fun.Acos(-q2 / Fun.Sqrt(-p3c));
                double t   = 2 * Fun.Sqrt(-p3);
                double r0  = t * Fun.Cos(phi);
                double r1  = -t *Fun.Cos(phi + Constant.Pi / 3.0);

                double r2 = -t *Fun.Cos(phi - Constant.Pi / 3.0);

                return(Triple.CreateAscending(r0, r1, r2));
            }
            d = Fun.Sqrt(d);  // one triple root or a single and a double root
            double s0 = Fun.Cbrt(d - q2) - Fun.Cbrt(d + q2);
            double s1 = -0.5 * s0;

            return(s0 < s1?Triple.Create(s0, s1, s1)
                       : Triple.Create(s1, s1, s0));
        }
Exemplo n.º 10
0
 public __vt__ GetPoint(double alpha)
 {
     return(Center + Axis0 * Fun.Cos(alpha) + Axis1 * Fun.Sin(alpha));
 }
Exemplo n.º 11
0
 public __vt__ GetVector(double alpha)
 {
     return(Axis0 * Fun.Cos(alpha) + Axis1 * Fun.Sin(alpha));
 }