Exemple #1
0
        /// <summary>
        /// Returns the tangent of the specified complex number.
        /// </summary>
        /// <param name="value">A complex number.</param>
        /// <returns>The tangent of value.</returns>
        public static Complex Tan(Complex value)
        {
            double sa  = Functions.Sin(value.A);
            double ca  = Functions.Cos(value.A);
            double shb = Functions.Sinh(value.B);
            double cha = Functions.Cosh(value.B);

            return((new Complex(sa * cha, ca * shb)) / (new Complex(ca * cha, -sa * shb)));
        }
Exemple #2
0
        /// <summary>
        /// Creates a matrix that rotates around the z-axis.
        /// </summary>
        /// <param name="angle">Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.</param>
        /// <returns>The created rotation matrix.</returns>
        public static Matrix2x2f RotationZ(float angle)
        {
            var cos = Functions.Cos(angle);
            var sin = Functions.Sin(angle);

            return(new Matrix2x2f(
                       cos, sin,
                       -sin, cos
                       ));
        }
Exemple #3
0
        /// <summary>
        /// Creates a matrix that rotates around the z-axis.
        /// </summary>
        /// <param name="angle">Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.</param>
        /// <returns>The created rotation matrix.</returns>
        public static Matrix2x2d RotationZ(double angle)
        {
            var cos = Functions.Cos(angle);
            var sin = Functions.Sin(angle);

            return(new Matrix2x2d(
                       cos, sin,
                       -sin, cos
                       ));
        }
Exemple #4
0
        /// <summary>
        /// Creates a matrix that rotates around the y-axis.
        /// </summary>
        /// <param name="angle">Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.</param>
        /// <returns>The created rotation matrix.</returns>
        public static Matrix3x3d RotationY(double angle)
        {
            var cos = Functions.Cos(angle);
            var sin = Functions.Sin(angle);

            return(new Matrix3x3d(
                       cos, 0, -sin,
                       0, 1, 0,
                       sin, 0, cos
                       ));
        }
Exemple #5
0
        /// <summary>
        /// Creates a matrix that rotates around the x-axis.
        /// </summary>
        /// <param name="angle">Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.</param>
        /// <returns>The created rotation matrix.</returns>
        public static Matrix3x3f RotationX(float angle)
        {
            var cos = Functions.Cos(angle);
            var sin = Functions.Sin(angle);

            return(new Matrix3x3f(
                       1, 0, 0,
                       0, cos, sin,
                       0, -sin, cos
                       ));
        }
Exemple #6
0
        /// <summary>
        /// Interpolates between two unit complex numbers, using spherical linear interpolation.
        /// </summary>
        /// <param name="start">Start complex number.</param>
        /// <param name="end">End complex number.</param>
        /// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end"/>.</param>
        /// <returns>The spherical linear interpolation of the two complex numbers.</returns>
        ///  <remarks>
        /// Passing <paramref name="amount"/> a value of 0 will cause <paramref name="start"/> to be returned; a value of 1 will cause <paramref name="end"/> to be returned.
        /// </remarks>
        public Complex Slerp(Complex start, Complex end, double amount)
        {
            double cosTheta = Dot(start, end);

            //Cannot use slerp, use lerp instead
            if (Functions.Abs(cosTheta) - 1.0 < double.Epsilon)
            {
                return(Lerp(start, end, amount));
            }

            double theta    = Functions.Acos(cosTheta);
            double sinTheta = Functions.Sin(theta);
            double t0       = Functions.Sin((1.0 - amount) * theta) / sinTheta;
            double t1       = Functions.Sin(amount * theta) / sinTheta;

            return(t0 * start + t1 * end);
        }
Exemple #7
0
 /// <summary>
 /// Creates a complex number from a point's polar coordinates.
 /// </summary>
 /// <param name="coordinate">The polar coordinate</param>
 public static Complex FromPolarCoordinates(Geometry.PolarCoordinate coordinate)
 {
     return(new Complex(
                Functions.Cos(coordinate.Theta) * coordinate.Rho,
                Functions.Sin(coordinate.Theta) * coordinate.Rho));
 }
Exemple #8
0
 /// <summary>
 /// Creates a complex number from a point's polar coordinates.
 /// </summary>
 /// <param name="magnitude">The magnitude, which is the distance from the origin (the intersection of
 /// the x-axis and the y-axis) to the number.</param>
 /// <param name="phase">The phase, which is the angle from the line to the horizontal axis, measured
 /// in radians.</param>
 public static Complex FromPolarCoordinates(double magnitude, double phase)
 {
     return(new Complex(Functions.Cos(phase) * magnitude, Functions.Sin(phase) * magnitude));
 }
Exemple #9
0
 /// <summary>
 /// Returns the sine of the specified complex number.
 /// </summary>
 /// <param name="value">A complex number.</param>
 /// <returns>The sine of value.</returns>
 public static Complex Sin(Complex value)
 {
     return(new Complex(Functions.Sin(value.A) * Functions.Cosh(value.B), Functions.Cos(value.A) * Functions.Sinh(value.B)));
 }
Exemple #10
0
        /// <summary>
        /// Returns e raised to the power specified by a complex number.
        /// </summary>
        /// <param name="value">A complex number that specifies a power.</param>
        /// <returns>The number e raised to the power value.</returns>
        public static Complex Exp(Complex value)
        {
            double e = Functions.Exp(value.A);

            return(new Complex(e * Functions.Cos(value.B), e * Functions.Sin(value.B)));
        }