Class Angle

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Angle>, scala.Equals, scala.math.Ordered<Angle>, scala.Product

    public class Angle
    extends java.lang.Object
    implements java.io.Serializable, scala.math.Ordered<Angle>, scala.Product
    An wrapper for angle. Normally angle would be stored in double as radians, but this introduces rounding errors. This class stores value in microarc seconds to prevent rounding errors.

    Usage examples: //import provides implicit conversions for numbers import Angle._ //use implicit conversions to construct angle from number val angle = 10.degree + 0.5.arcSec //convert value to radian an print it println(11.toRadian)

    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Angle.AngleWrapperDouble
      used in implicit conversion to support `1.degree`, `1.arcMinute` etc
    • Constructor Summary

      Constructors 
      Constructor Description
      Angle​(long uas)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void assertDe​(double de)  
      static void assertRa​(double ra)  
      protected static long CIRCLE()  
      int compare​(Angle that)  
      static double D2H()
      multiply to convert degrees to arc hours
      static int D2M()
      multiply to convert degrees to arc minute
      static int D2Mas()
      multiply to convert degrees to mili arc seconds
      static double D2R()
      multiply to convert degrees to radians
      static int D2S()
      multiply to convert degrees to arc second
      static long D2Uas()
      multiply to convert degrees to micro arc seconds
      static char DEGREE_SIGN()
      round circle which marks degrees
      static java.lang.String deToString​(double de2)
      convert DE to string in format '1d 2m' minutes and seconds are auto added as needed
      static double distance​(double ra1, double de1, double ra2, double de2)
      calculate great circle distance of two points, coordinates are given in radians
      static Angle.AngleWrapperDouble double2angle​(double d)  
      static double H2D()
      multiply to convert arc hour to degrees
      static int H2Mas()
      multiply to convert hours to mili arc seconds
      static double H2R()
      multiply to convert hours to radians
      static long H2Uas()
      multiply to convert hours to micro arc seconds
      static int HMin2Mas()
      multiply to convert time minutes to mili arc seconds
      static long HMin2Uas()
      multiply to convert time minutes to micro arc seconds
      static int HSec2Mas()
      multiply to convert time seconds to mili arc seconds
      static long HSec2Uas()
      multiply to convert time seconds to micro arc seconds
      static Angle.AngleWrapperDouble int2angle​(int d)  
      static Angle.AngleWrapperDouble long2angle​(long d)  
      static double M2D()
      multiply to convert arc minute to toDegree
      static int M2Mas()
      multiply to convert minutes to mili arc seconds
      static double M2R()
      multiply to convert minutes to radians
      static long M2Uas()
      multiply to convert minutes to micro arc seconds
      static double Mas2R()
      multiply to convert milli arc seconds to radians
      static Angle max​(Angle a1, Angle a2)
      returns maximal angle from two options
      static Angle min​(Angle a1, Angle a2)
      returns minimal angle from two options
      Angle normalizedRa()
      returns Angle with value normalized between 0 to 2*PI
      static double normalizeRa​(double ra2)
      normalize RA into 0 - 2 * PI range
      static Angle parseDe​(java.lang.String de)
      Tries to parse Angle from string.
      static Angle parseDe​(java.lang.String deSign, java.lang.String deDegree, java.lang.String deMin, java.lang.String deSec)
      Parse Declination from four values.
      static Angle parseRa​(java.lang.String ra)
      Tries to parse Angle from string.
      static Angle parseRa​(java.lang.String raHour, java.lang.String raMin, java.lang.String raSec)
      parse Right ascencion from triple values raHour raMin, raSec This method uses big decimal, so there are no rounding errors
      static scala.Tuple2<Angle,​Angle> parseRaDe​(java.lang.String str)
      Parses pair of RA and De coordinates.
      static double R2D()
      multiply to convert radians to degrees
      static double R2H()
      multiply to convert radians to hours
      static double R2M()
      multiply to convert radians to minutes
      static double R2Mas()
      multiply to convert radians to mili arc seconds
      static double R2S()
      multiply to convert radians to arc seconds
      static double R2Uas()
      multiply to convert radians to micro arc seconds
      static Angle randomDe()
      returns random angle with value between -PI/2 and + PI/2
      static Angle randomRa()
      returns random angle with value between 0 and 2*PI
      static java.lang.String raToString​(double ra)
      convert RA to string in format '1h 2m' minutes and seconds are auto added as needed
      static double S2D()
      multiply to convert arc second to toDegree
      static int S2Mas()
      multiply to convert Seconds to mili arc seconds
      static double S2R()
      multiply to convert arc seconds to radians
      static long S2Uas()
      multiply to convert Seconds to micro arc seconds
      scala.collection.immutable.Seq<Angle> to​(Angle maxVal, Angle increment)
      Returns sequence of angles with given max value and increment
      double toArcSec()
      returns angle value in arc seconds
      double toDegree()
      returns angle value in degrees
      double toMas()
      returns angle value in mili arc seconds
      double toRadian()
      returns angle value in radians
      java.lang.String toString()  
      long uas()  
      static double Uas2D()
      multiply to convert UAS to degrees
      static double Uas2M()
      multiply to convert UAS to minutes
      static double Uas2R()
      multiply to convert micro arc seconds to radians
      static double Uas2S()
      multiply to convert UAS to Seconds
      scala.collection.immutable.Seq<Angle> until​(Angle maxVal, Angle increment)
      Returns sequence of angles with given max value and increment
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface scala.Equals

        canEqual, equals
      • Methods inherited from interface scala.math.Ordered

        $greater, $greater$eq, $less, $less$eq, compareTo
      • Methods inherited from interface scala.Product

        productArity, productElement, productElementName, productElementNames, productIterator, productPrefix
    • Constructor Detail

      • Angle

        public Angle​(long uas)
    • Method Detail

      • CIRCLE

        protected static long CIRCLE()
      • randomRa

        public static Angle randomRa()
        returns random angle with value between 0 and 2*PI
      • randomDe

        public static Angle randomDe()
        returns random angle with value between -PI/2 and + PI/2
      • max

        public static Angle max​(Angle a1,
                                Angle a2)
        returns maximal angle from two options
      • min

        public static Angle min​(Angle a1,
                                Angle a2)
        returns minimal angle from two options
      • parseDe

        public static Angle parseDe​(java.lang.String deSign,
                                    java.lang.String deDegree,
                                    java.lang.String deMin,
                                    java.lang.String deSec)
        Parse Declination from four values. It uses BigDecimal, so there are no rounding errors

        Parameters:
        deSign - signum (ie + or -)
        deDegree - declination in degrees
        deMin - remaining part in arc minutes
        deSec - remaining part in arc seconds
        Returns:
        declination in Micro Arc Seconds
      • parseDe

        public static Angle parseDe​(java.lang.String de)
        Tries to parse Angle from string. It knows common formats used for Declination
        Parameters:
        de - (undocumented)
        Returns:
        (undocumented)
      • parseRa

        public static Angle parseRa​(java.lang.String raHour,
                                    java.lang.String raMin,
                                    java.lang.String raSec)
        parse Right ascencion from triple values raHour raMin, raSec This method uses big decimal, so there are no rounding errors

        Parameters:
        raHour - ra hours value as String
        raMin - ra minutes value as String
        raSec - ra seconds value as String
        Returns:
        result in micro arc seconds
      • parseRa

        public static Angle parseRa​(java.lang.String ra)
        Tries to parse Angle from string. It knows common formats used for Right ascencion (including hours)
        Parameters:
        ra - (undocumented)
        Returns:
        (undocumented)
      • parseRaDe

        public static scala.Tuple2<Angle,​Angle> parseRaDe​(java.lang.String str)
        Parses pair of RA and De coordinates. This method should handle formats used in vizier. An example: The following writings are allowed:
         20 54 05.689 +37 01 17.38
         10:12:45.3-45:17:50
         15h17m-11d10m
         15h17+89d15
         275d11m15.6954s+17d59m59.876s
         12.34567h-17.87654d
         350.123456d-17.33333d <=> 350.123456 -17.33333
         
        Parameters:
        str - (undocumented)
        Returns:
        (undocumented)
      • normalizeRa

        public static double normalizeRa​(double ra2)
        normalize RA into 0 - 2 * PI range
        Parameters:
        ra2 - (undocumented)
        Returns:
        (undocumented)
      • assertRa

        public static void assertRa​(double ra)
      • assertDe

        public static void assertDe​(double de)
      • raToString

        public static java.lang.String raToString​(double ra)
        convert RA to string in format '1h 2m' minutes and seconds are auto added as needed

        Parameters:
        ra - in radians
        Returns:
        ra in string form
      • deToString

        public static java.lang.String deToString​(double de2)
        convert DE to string in format '1d 2m' minutes and seconds are auto added as needed

        Parameters:
        de2 - in radians
        Returns:
        de in string form
      • distance

        public static double distance​(double ra1,
                                      double de1,
                                      double ra2,
                                      double de2)
        calculate great circle distance of two points, coordinates are given in radians

        Parameters:
        ra1 - (undocumented)
        de1 - (undocumented)
        ra2 - (undocumented)
        de2 - (undocumented)
        Returns:
        distance of two points in radians
      • D2R

        public static double D2R()
        multiply to convert degrees to radians
      • R2D

        public static double R2D()
        multiply to convert radians to degrees
      • D2H

        public static double D2H()
        multiply to convert degrees to arc hours
      • H2D

        public static double H2D()
        multiply to convert arc hour to degrees
      • D2M

        public static int D2M()
        multiply to convert degrees to arc minute
      • M2D

        public static double M2D()
        multiply to convert arc minute to toDegree
      • D2S

        public static int D2S()
        multiply to convert degrees to arc second
      • S2D

        public static double S2D()
        multiply to convert arc second to toDegree
      • H2R

        public static double H2R()
        multiply to convert hours to radians
      • R2H

        public static double R2H()
        multiply to convert radians to hours
      • R2M

        public static double R2M()
        multiply to convert radians to minutes
      • M2R

        public static double M2R()
        multiply to convert minutes to radians
      • Mas2R

        public static double Mas2R()
        multiply to convert milli arc seconds to radians
      • Uas2R

        public static double Uas2R()
        multiply to convert micro arc seconds to radians
      • R2Mas

        public static double R2Mas()
        multiply to convert radians to mili arc seconds
      • R2Uas

        public static double R2Uas()
        multiply to convert radians to micro arc seconds
      • H2Mas

        public static int H2Mas()
        multiply to convert hours to mili arc seconds
      • HMin2Mas

        public static int HMin2Mas()
        multiply to convert time minutes to mili arc seconds
      • HSec2Mas

        public static int HSec2Mas()
        multiply to convert time seconds to mili arc seconds
      • H2Uas

        public static long H2Uas()
        multiply to convert hours to micro arc seconds
      • HMin2Uas

        public static long HMin2Uas()
        multiply to convert time minutes to micro arc seconds
      • HSec2Uas

        public static long HSec2Uas()
        multiply to convert time seconds to micro arc seconds
      • D2Mas

        public static int D2Mas()
        multiply to convert degrees to mili arc seconds
      • M2Mas

        public static int M2Mas()
        multiply to convert minutes to mili arc seconds
      • S2Mas

        public static int S2Mas()
        multiply to convert Seconds to mili arc seconds
      • D2Uas

        public static long D2Uas()
        multiply to convert degrees to micro arc seconds
      • M2Uas

        public static long M2Uas()
        multiply to convert minutes to micro arc seconds
      • S2Uas

        public static long S2Uas()
        multiply to convert Seconds to micro arc seconds
      • Uas2D

        public static double Uas2D()
        multiply to convert UAS to degrees
      • Uas2M

        public static double Uas2M()
        multiply to convert UAS to minutes
      • Uas2S

        public static double Uas2S()
        multiply to convert UAS to Seconds
      • S2R

        public static double S2R()
        multiply to convert arc seconds to radians
      • R2S

        public static double R2S()
        multiply to convert radians to arc seconds
      • DEGREE_SIGN

        public static char DEGREE_SIGN()
        round circle which marks degrees
      • uas

        public long uas()
      • compare

        public int compare​(Angle that)
        Specified by:
        compare in interface scala.math.Ordered<Angle>
      • toRadian

        public double toRadian()
        returns angle value in radians
      • toDegree

        public double toDegree()
        returns angle value in degrees
      • toMas

        public double toMas()
        returns angle value in mili arc seconds
      • toArcSec

        public double toArcSec()
        returns angle value in arc seconds
      • normalizedRa

        public Angle normalizedRa()
        returns Angle with value normalized between 0 to 2*PI
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • to

        public scala.collection.immutable.Seq<Angle> to​(Angle maxVal,
                                                        Angle increment)
        Returns sequence of angles with given max value and increment
      • until

        public scala.collection.immutable.Seq<Angle> until​(Angle maxVal,
                                                           Angle increment)
        Returns sequence of angles with given max value and increment