/// <summary> /// Finds the tangent of an angle. /// </summary> /// <param name="angle">Angle in degrees to take the tangent of.</param> /// <returns name="tan">Tangent of the angle.</returns> /// <search>tangent</search> public static double Tan(double angle) { if (!(Equals(CSMath.IEEERemainder(angle, 180), 0.0) || Equals(CSMath.IEEERemainder(angle, 180), 180.0)) && (Equals(CSMath.IEEERemainder(angle, 90), 0.0) || Equals(CSMath.IEEERemainder(angle, 90), 90.0))) return Double.NaN; return CSMath.Tan(angle * kDegreesToRadians); }
public static double Tan(double value) { if (!(Double.Equals(CSMath.IEEERemainder(value, 180), 0.0) || Double.Equals(CSMath.IEEERemainder(value, 180), 180.0)) && (Double.Equals(CSMath.IEEERemainder(value, 90), 0.0) || Double.Equals(CSMath.IEEERemainder(value, 90), 90.0))) { return(Double.NaN); } return(CSMath.Tan(value * kDegreesToRadians)); }
public static MatrixDouble CreateRotation(double radians, Point centerPoint) { MatrixDouble result; radians = (double)SM.IEEERemainder(radians, SM.PI * 2); double c, s; const double epsilon = 0.001f * (double)SM.PI / 180d; // 0.1% of a degree if ((radians > -epsilon) && (radians < epsilon)) { // Exact case for zero rotation. c = 1; s = 0; } else if ((radians > SM.PI / 2 - epsilon) && (radians < SM.PI / 2 + epsilon)) { // Exact case for 90 degree rotation. c = 0; s = 1; } else if ((radians < -SM.PI + epsilon) || (radians > SM.PI - epsilon)) { // Exact case for 180 degree rotation. c = -1; s = 0; } else if ((radians > -SM.PI / 2 - epsilon) && (radians < -SM.PI / 2 + epsilon)) { // Exact case for 270 degree rotation. c = 0; s = -1; } else { // Arbitrary rotation. c = (double)SM.Cos(radians); s = (double)SM.Sin(radians); } double x = centerPoint.X * (1 - c) + centerPoint.Y * s; double y = centerPoint.Y * (1 - c) - centerPoint.X * s; // [ c s ] // [ -s c ] // [ x y ] result.M11 = c; result.M12 = s; result.M21 = -s; result.M22 = c; result.M31 = x; result.M32 = y; return(result); }
public static Matrix3x2 CreateRotation(float radians, Vector2 centerPoint) { Matrix3x2 result; radians = (float)SM.IEEERemainder(radians, SM.PI * 2); float c, s; const float epsilon = 0.001f * (float)SM.PI / 180f; // 0.1% of a degree if (radians > -epsilon && radians < epsilon) { // Exact case for zero rotation. c = 1; s = 0; } else if (radians > SM.PI / 2 - epsilon && radians < SM.PI / 2 + epsilon) { // Exact case for 90 degree rotation. c = 0; s = 1; } else if (radians < -SM.PI + epsilon || radians > SM.PI - epsilon) { // Exact case for 180 degree rotation. c = -1; s = 0; } else if (radians > -SM.PI / 2 - epsilon && radians < -SM.PI / 2 + epsilon) { // Exact case for 270 degree rotation. c = 0; s = -1; } else { // Arbitrary rotation. c = (float)SM.Cos(radians); s = (float)SM.Sin(radians); } float x = centerPoint.X * (1 - c) + centerPoint.Y * s; float y = centerPoint.Y * (1 - c) - centerPoint.X * s; // [ c s ] // [ -s c ] // [ x y ] result.M11 = c; result.M12 = s; result.M21 = -s; result.M22 = c; result.M31 = x; result.M32 = y; return(result); }
public static double IEEERemainder(this double x, double y) { return(Math.IEEERemainder(x, y)); }
public static Half IEEERemainder(Half x, Half y) => (Half)M.IEEERemainder(x, y);
public static double IEEERemainder(double value1, double value2) { return(CSMath.IEEERemainder(value1, value2)); }
public static float IEEERemainder(float x, float y) { return((float)Math.IEEERemainder(x, y)); }
public static double IEEERemainder(double x, double y) => Math.IEEERemainder(x, y);
static double IFloatingPoint <double> .IEEERemainder(double left, double right) => Math.IEEERemainder(left, right);
/// <inheritdoc cref="IFloatingPoint{TSelf}.IEEERemainder(TSelf, TSelf)" /> public static double IEEERemainder(double left, double right) => Math.IEEERemainder(left, right);
/// <summary> /// Reduces a given angle to a value between π and -π. /// </summary> /// <param name="angle">The angle.</param> public static float WrapAngle(float angle) { return((float)Math.IEEERemainder((double)angle, 6.2831854820251465)); }
public static nfloat IEEERemainder(nfloat x, nfloat y) { return((nfloat)Math.IEEERemainder((double)x, (double)y)); }