mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:25:41 +00:00
Add trigonometric functions (implements #49)
This commit is contained in:
parent
d9277dbbf6
commit
28551f25e6
@ -9,6 +9,113 @@ namespace X10D;
|
||||
/// </summary>
|
||||
public static class DoubleExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the arccosine of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a cosine, which must be greater than or equal to -1, but less than or equal to 1.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The arccosine of <paramref name="value" />, θ, measured in radians; such that 0 ≤ θ ≤ π. If <paramref name="value" />
|
||||
/// is equal to <see cref="double.NaN" />, less than -1, or greater than 1, <see cref="double.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Acos(this double value)
|
||||
{
|
||||
return Math.Acos(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic arccosine of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a hyperbolic cosine, which must be greater than or equal to 1, but less than or equal to
|
||||
/// <see cref="double.PositiveInfinity" />.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The hyperbolic arccosine of <paramref name="value" />, θ, measured in radians; such that 0 ≤ θ ≤ ∞. If
|
||||
/// <paramref name="value" /> is less than 1 or equal to <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Acosh(this double value)
|
||||
{
|
||||
return Math.Acosh(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the arcsine of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a sine, which must be greater than or equal to -1, but less than or equal to 1.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The arccosine of <paramref name="value" />, θ, measured in radians; such that π/2 ≤ θ ≤ π/2. If
|
||||
/// <paramref name="value" /> is equal to <see cref="double.NaN" />, less than -1, or greater than 1,
|
||||
/// <see cref="double.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Asin(this double value)
|
||||
{
|
||||
return Math.Asin(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic arcsine of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a hyperbolic sine, which must be greater than or equal to 1, but less than or equal to
|
||||
/// <see cref="double.PositiveInfinity" />.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The hyperbolic arccosine of <paramref name="value" />, measured in radians. If <paramref name="value" /> is equal to
|
||||
/// <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Asinh(this double value)
|
||||
{
|
||||
return Math.Asinh(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the arctangent of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a tangent, which must be greater than or equal to -1, but less than or equal to 1.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The arctangent of <paramref name="value" />, θ, measured in radians; such that π/2 ≤ θ ≤ π/2. If
|
||||
/// <paramref name="value" /> is equal to <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Atan(this double value)
|
||||
{
|
||||
return Math.Atan(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic arctangent of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a hyperbolic tangent, which must be greater than or equal to 1, but less than or equal to
|
||||
/// <see cref="double.PositiveInfinity" />.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The hyperbolic arctangent of <paramref name="value" />, θ, measured in radians; such that -∞ < θ < -1, or 1 <
|
||||
/// θ < ∞. If <paramref name="value" /> is equal to <see cref="double.NaN" />, less than -1, or greater than 1,
|
||||
/// <see cref="double.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Atanh(this double value)
|
||||
{
|
||||
return Math.Atanh(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the complex square root of this double-precision floating-point number.
|
||||
/// </summary>
|
||||
@ -32,6 +139,39 @@ public static class DoubleExtensions
|
||||
return new Complex(absoluteSqrt, value >= 0 ? 0 : 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cosine of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, measured in radians.</param>
|
||||
/// <returns>
|
||||
/// The cosine of <paramref name="value" />. If <paramref name="value" /> is equal to <see cref="double.NaN" />,
|
||||
/// <see cref="double.NegativeInfinity" />, or <see cref="double.PositiveInfinity" />, this method returns
|
||||
/// <see cref="double.NaN" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Cos(this double value)
|
||||
{
|
||||
return Math.Cos(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic cosine of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, measured in radians.</param>
|
||||
/// <returns>
|
||||
/// The hyperbolic cosine of <paramref name="value" />. If <paramref name="value" /> is equal to
|
||||
/// <see cref="double.NegativeInfinity" /> or <see cref="double.PositiveInfinity" />,
|
||||
/// <see cref="double.PositiveInfinity" /> is returned. If <paramref name="value" /> is equal to
|
||||
/// <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Cosh(this double value)
|
||||
{
|
||||
return Math.Cosh(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the current angle in degrees to its equivalent represented in radians.
|
||||
/// </summary>
|
||||
@ -186,6 +326,38 @@ public static class DoubleExtensions
|
||||
return Math.Sign(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the sine of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, in radians.</param>
|
||||
/// <returns>
|
||||
/// The sine of <paramref name="value" />. If <paramref name="value" /> is equal to <see cref="double.NaN" />,
|
||||
/// <see cref="double.NegativeInfinity" />, or <see cref="double.PositiveInfinity" />, this method returns
|
||||
/// <see cref="double.NaN" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Sin(this double value)
|
||||
{
|
||||
return Math.Sin(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic sine of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, in radians.</param>
|
||||
/// <returns>
|
||||
/// The hyperbolic sine of <paramref name="value" />. If <paramref name="value" /> is equal to <see cref="double.NaN" />,
|
||||
/// <see cref="double.NegativeInfinity" />, or <see cref="double.PositiveInfinity" />, this method returns
|
||||
/// <see cref="double.NaN" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Sinh(this double value)
|
||||
{
|
||||
return Math.Sinh(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the square root of this double-precision floating-point number.
|
||||
/// </summary>
|
||||
@ -249,4 +421,37 @@ public static class DoubleExtensions
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the tangent of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, measured in radians.</param>
|
||||
/// <returns>
|
||||
/// The tangent of <paramref name="value" />. If <paramref name="value" /> is equal to <see cref="double.NaN" />,
|
||||
/// <see cref="double.NegativeInfinity" />, or <see cref="double.PositiveInfinity" />, this method returns
|
||||
/// <see cref="double.NaN" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Tan(this double value)
|
||||
{
|
||||
return Math.Tan(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic tangent of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, measured in radians.</param>
|
||||
/// <returns>
|
||||
/// The hyperbolic tangent of <paramref name="value" />. If <paramref name="value" /> is equal to
|
||||
/// <see cref="double.NegativeInfinity" />, this method returns -1. If <paramref name="value" /> is equal to
|
||||
/// <see cref="double.PositiveInfinity" />, this method returns 1. If <paramref name="value" /> is equal to
|
||||
/// <see cref="double.NaN" />, this method returns <see cref="double.NaN" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Tanh(this double value)
|
||||
{
|
||||
return Math.Tanh(value);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,113 @@ namespace X10D;
|
||||
/// </summary>
|
||||
public static class SingleExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the arccosine of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a cosine, which must be greater than or equal to -1, but less than or equal to 1.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The arccosine of <paramref name="value" />, θ, measured in radians; such that 0 ≤ θ ≤ π. If <paramref name="value" />
|
||||
/// is equal to <see cref="float.NaN" />, less than -1, or greater than 1, <see cref="float.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Acos(this float value)
|
||||
{
|
||||
return MathF.Acos(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic arccosine of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a hyperbolic cosine, which must be greater than or equal to 1, but less than or equal to
|
||||
/// <see cref="float.PositiveInfinity" />.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The hyperbolic arccosine of <paramref name="value" />, θ, measured in radians; such that 0 ≤ θ ≤ ∞. If
|
||||
/// <paramref name="value" /> is less than 1 or equal to <see cref="float.NaN" />, <see cref="float.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Acosh(this float value)
|
||||
{
|
||||
return MathF.Acosh(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the arcsine of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a sine, which must be greater than or equal to -1, but less than or equal to 1.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The arccosine of <paramref name="value" />, θ, measured in radians; such that π/2 ≤ θ ≤ π/2. If
|
||||
/// <paramref name="value" /> is equal to <see cref="float.NaN" />, less than -1, or greater than 1,
|
||||
/// <see cref="float.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Asin(this float value)
|
||||
{
|
||||
return MathF.Asin(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic arcsine of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a hyperbolic sine, which must be greater than or equal to 1, but less than or equal to
|
||||
/// <see cref="float.PositiveInfinity" />.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The hyperbolic arccosine of <paramref name="value" />, measured in radians. If <paramref name="value" /> is equal to
|
||||
/// <see cref="float.NaN" />, <see cref="float.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Asinh(this float value)
|
||||
{
|
||||
return MathF.Asinh(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the arctangent of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a tangent, which must be greater than or equal to -1, but less than or equal to 1.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The arctangent of <paramref name="value" />, θ, measured in radians; such that π/2 ≤ θ ≤ π/2. If
|
||||
/// <paramref name="value" /> is equal to <see cref="float.NaN" />, <see cref="float.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Atan(this float value)
|
||||
{
|
||||
return MathF.Atan(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic arctangent of the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value representing a hyperbolic tangent, which must be greater than or equal to 1, but less than or equal to
|
||||
/// <see cref="float.PositiveInfinity" />.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The hyperbolic arctangent of <paramref name="value" />, θ, measured in radians; such that -∞ < θ < -1, or 1 <
|
||||
/// θ < ∞. If <paramref name="value" /> is equal to <see cref="float.NaN" />, less than -1, or greater than 1,
|
||||
/// <see cref="float.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Atanh(this float value)
|
||||
{
|
||||
return MathF.Atanh(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the complex square root of this single-precision floating-point number.
|
||||
/// </summary>
|
||||
@ -32,6 +139,39 @@ public static class SingleExtensions
|
||||
return new Complex(absoluteSqrt, value >= 0 ? 0 : 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cosine of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, measured in radians.</param>
|
||||
/// <returns>
|
||||
/// The cosine of <paramref name="value" />. If <paramref name="value" /> is equal to <see cref="float.NaN" />,
|
||||
/// <see cref="float.NegativeInfinity" />, or <see cref="float.PositiveInfinity" />, this method returns
|
||||
/// <see cref="float.NaN" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Cos(this float value)
|
||||
{
|
||||
return MathF.Cos(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic cosine of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, measured in radians.</param>
|
||||
/// <returns>
|
||||
/// The hyperbolic cosine of <paramref name="value" />. If <paramref name="value" /> is equal to
|
||||
/// <see cref="float.NegativeInfinity" /> or <see cref="float.PositiveInfinity" />,
|
||||
/// <see cref="float.PositiveInfinity" /> is returned. If <paramref name="value" /> is equal to
|
||||
/// <see cref="float.NaN" />, <see cref="double.NaN" /> is returned.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Cosh(this float value)
|
||||
{
|
||||
return MathF.Cosh(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the current angle in degrees to its equivalent represented in radians.
|
||||
/// </summary>
|
||||
@ -185,6 +325,38 @@ public static class SingleExtensions
|
||||
return MathF.Sign(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the sine of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, measured in radians.</param>
|
||||
/// <returns>
|
||||
/// The sine of <paramref name="value" />. If <paramref name="value" /> is equal to <see cref="double.NaN" />,
|
||||
/// <see cref="double.NegativeInfinity" />, or <see cref="double.PositiveInfinity" />, this method returns
|
||||
/// <see cref="double.NaN" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Sin(this float value)
|
||||
{
|
||||
return MathF.Sin(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic sine of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, measured in radians.</param>
|
||||
/// <returns>
|
||||
/// The hyperbolic sine of <paramref name="value" />. If <paramref name="value" /> is equal to <see cref="float.NaN" />,
|
||||
/// <see cref="float.NegativeInfinity" />, or <see cref="float.PositiveInfinity" />, this method returns
|
||||
/// <see cref="float.NaN" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Sinh(this float value)
|
||||
{
|
||||
return MathF.Sinh(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the square root of this single-precision floating-point number.
|
||||
/// </summary>
|
||||
@ -248,4 +420,37 @@ public static class SingleExtensions
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the tangent of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, measured in radians.</param>
|
||||
/// <returns>
|
||||
/// The tangent of <paramref name="value" />. If <paramref name="value" /> is equal to <see cref="float.NaN" />,
|
||||
/// <see cref="float.NegativeInfinity" />, or <see cref="float.PositiveInfinity" />, this method returns
|
||||
/// <see cref="float.NaN" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Tan(this float value)
|
||||
{
|
||||
return MathF.Sin(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hyperbolic tangent of the specified angle.
|
||||
/// </summary>
|
||||
/// <param name="value">The angle, measured in radians.</param>
|
||||
/// <returns>
|
||||
/// The hyperbolic tangent of <paramref name="value" />. If <paramref name="value" /> is equal to
|
||||
/// <see cref="float.NegativeInfinity" />, this method returns -1. If <paramref name="value" /> is equal to
|
||||
/// <see cref="float.PositiveInfinity" />, this method returns 1. If <paramref name="value" /> is equal to
|
||||
/// <see cref="float.NaN" />, this method returns <see cref="float.NaN" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Tanh(this float value)
|
||||
{
|
||||
return MathF.Tanh(value);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user