Exemplo n.º 1
0
        private static double K(int l, int m)
        {
            var lpm = Functions.Factorial(l + Functions.Abs(m));
            var lmm = Functions.Factorial(l - Functions.Abs(m));

            return(Functions.Sqrt(((2 * l + 1) * lmm) / (4 * Constants.Pi * lpm)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the square root of a specified complex number.
        /// </summary>
        /// <param name="value">A complex number.</param>
        /// <returns>The square root of value.</returns>
        public static Complex Sqrt(Complex value)
        {
            double magnitude = Functions.Sqrt(value.A * value.A + value.B * value.B);

            return(new Complex(
                       Functions.Sqrt((magnitude + value.A) / 2.0),
                       (value.B < 0 ? -1.0 : 1.0) * Functions.Sqrt((magnitude - value.A) / 2.0)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the refraction of a vector off a surface that has the specified normal, and refractive index.
        /// </summary>
        /// <param name="vector">The source vector.</param>
        /// <param name="normal">Normal of the surface.</param>
        /// <param name="index">The refractive index, destination index over source index.</param>
        /// <returns>The refracted vector.</returns>
        /// <remarks>Refract only gives the direction of a refraction off a surface, it does not determine
        /// whether the original vector was close enough to the surface to hit it.</remarks>
        public static Vector2f Refract(Vector2h vector, Vector2h normal, float index)
        {
            var cos1     = Dot(vector, normal);
            var radicand = 1 - (index * index) * (1 - (cos1 * cos1));

            if (radicand < 0)
            {
                return(Vector2f.Zero);
            }
            return((index * vector) + ((Functions.Sqrt(radicand) - index * cos1) * normal));
        }
Exemplo n.º 4
0
        public static PolarCoordinate CartesianToPolar(Vector2sb value)
        {
            double theta = Functions.Atan2(value.Y, value.X);

            if (theta < 0)
            {
                theta += 2 * Constants.Pi;
            }
            return(new PolarCoordinate(
                       theta,
                       (double)Functions.Sqrt(value.X * value.X + value.Y * value.Y)));
        }
Exemplo n.º 5
0
 public static float Absolute(Vector2sb value)
 {
     return(Functions.Sqrt(AbsoluteSquared(value)));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Computes the absolute value (or modulus or magnitude) of a vector and returns the result.
 /// </summary>
 /// <param name="value">A vector.</param>
 /// <returns>The absolute value of value.</returns>
 public static double Absolute(Vector8l value)
 {
     return(Functions.Sqrt(AbsoluteSquared(value)));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Computes the absolute value (or modulus or magnitude) of a complex number and returns the result.
 /// </summary>
 /// <param name="value">A complex number.</param>
 /// <returns>The absolute value of value.</returns>
 public static double Absolute(Complex value)
 {
     return(Functions.Sqrt(value.A * value.A + value.B * value.B));
 }