Class ExtendedMath

java.lang.Object
org.shredzone.commons.suncalc.util.ExtendedMath

public final class ExtendedMath extends Object
Contains constants and mathematical operations that are not available in Math.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Arc-Seconds per Radian.
    static final double
    Mean radius of the earth, in kilometers.
    static final double
    PI * 2
    static final double
    Refraction at the horizon, in radians.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    apparentRefraction(double ha)
    Calculates the atmospheric refraction of an object at the given apparent altitude.
    static double
    dms(int d, int m, double s)
    Converts dms to double.
    static Matrix
    Creates a rotational Matrix for converting equatorial to ecliptical coordinates.
    static Vector
    equatorialToHorizontal(double tau, double dec, double dist, double lat)
    Converts equatorial coordinates to horizontal coordinates.
    static double
    frac(double a)
    Returns the decimal part of a value.
    static boolean
    isZero(double d)
    Performs a safe check if the given double is actually zero (0.0).
    static double
    parallax(double elevation, double distance)
    Returns the parallax for objects at the horizon.
    static double
    readjustMax(double time, double frame, int depth, Function<Double,Double> f)
    Locates the true maximum within the given time frame.
    static double
    readjustMin(double time, double frame, int depth, Function<Double,Double> f)
    Locates the true minimum within the given time frame.
    static double
    refraction(double h)
    Calculates the atmospheric refraction of an object at the given altitude.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • frac

      public static double frac(double a)
      Returns the decimal part of a value.
      Parameters:
      a - Value
      Returns:
      Fraction of that value. It has the same sign as the input value.
    • isZero

      public static boolean isZero(double d)
      Performs a safe check if the given double is actually zero (0.0).

      Note that "almost zero" returns false, so this method should not be used for comparing calculation results to zero.

      Parameters:
      d - double to check for zero.
      Returns:
      true if the value was zero, or negative zero.
    • equatorialToHorizontal

      public static Vector equatorialToHorizontal(double tau, double dec, double dist, double lat)
      Converts equatorial coordinates to horizontal coordinates.
      Parameters:
      tau - Hour angle (radians)
      dec - Declination (radians)
      dist - Distance of the object
      lat - Latitude of the observer (radians)
      Returns:
      Vector containing the horizontal coordinates
    • equatorialToEcliptical

      Creates a rotational Matrix for converting equatorial to ecliptical coordinates.
      Parameters:
      t - JulianDate to use
      Returns:
      Matrix for converting equatorial to ecliptical coordinates
    • parallax

      public static double parallax(double elevation, double distance)
      Returns the parallax for objects at the horizon.
      Parameters:
      elevation - Observer's elevation, in meters above sea level. Must not be negative.
      distance - Distance of the object, in kilometers.
      Returns:
      parallax, in radians
    • apparentRefraction

      public static double apparentRefraction(double ha)
      Calculates the atmospheric refraction of an object at the given apparent altitude.

      The result is only valid for positive altitude angles. If negative, 0.0 is returned.

      Assumes an atmospheric pressure of 1010 hPa and a temperature of 10 °C.

      Parameters:
      ha - Apparent altitude, in radians.
      Returns:
      Refraction at this altitude
      See Also:
    • refraction

      public static double refraction(double h)
      Calculates the atmospheric refraction of an object at the given altitude.

      The result is only valid for positive altitude angles. If negative, 0.0 is returned.

      Assumes an atmospheric pressure of 1010 hPa and a temperature of 10 °C.

      Parameters:
      h - True altitude, in radians.
      Returns:
      Refraction at this altitude
      See Also:
    • dms

      public static double dms(int d, int m, double s)
      Converts dms to double.
      Parameters:
      d - Degrees. Sign is used for result.
      m - Minutes. Sign is ignored.
      s - Seconds and fractions. Sign is ignored.
      Returns:
      angle, in degrees
    • readjustMax

      public static double readjustMax(double time, double frame, int depth, Function<Double,Double> f)
      Locates the true maximum within the given time frame.
      Parameters:
      time - Base time
      frame - Time frame, which is added to and subtracted from the base time for the interval
      depth - Maximum recursion depth. For each recursion, the function is invoked once.
      f - Function to be used for calculation
      Returns:
      time of the true maximum
    • readjustMin

      public static double readjustMin(double time, double frame, int depth, Function<Double,Double> f)
      Locates the true minimum within the given time frame.
      Parameters:
      time - Base time
      frame - Time frame, which is added to and subtracted from the base time for the interval
      depth - Maximum recursion depth. For each recursion, the function is invoked once.
      f - Function to be used for calculation
      Returns:
      time of the true minimum