JEphem site
tig API
Build classes

jephem.astro
Class Body

java.lang.Object
  |
  +--jephem.astro.Body
All Implemented Interfaces:
GeneralConstants, SolarSystemConstants, UnitsConstants

public class Body
extends java.lang.Object
implements GeneralConstants, UnitsConstants, SolarSystemConstants

An object of this class represents a heavenly body.
A Body characterized by :

  • its index, corresponding to a SolarSystemConstants constant - accessible via getIndex() ;
  • its coordinates, x0, x1, x2, v0, v1, v2, for its position and velocity - accessible via get/setX0() ... get/setV2(), get/setCoords(), get/setPositionCoords(), get/setVelocityCoords() ;
  • its frame, the reference frame in which its coordinates are expressed - accessible via get/setFrame();
  • its coordinateExpression, the expression mode of its coordinates (spherical / cartesian) - accessible via get/setCoordinateExpression();
  • The units used to express its coordinates : positionUnits and velocityUnits - accessible via get/setPositionUnits() and get/setVelocityUnits().


  • This class is also used to store the ComputationException which may occur during the computation of its coordinates.


  • For spherical coordinates, we have :
  • x0 = r,
  • x1 = q, belongs to [0, 2p[
  • x2 = j, belongs to [-p/2, p/2].


  • Methods of this class (like cartToSphere) assume that this order is respected.

    WARNING : internal coherence of data is not ensured. For example, a call to setFrame won't internally generate coordinate transformations.


    Field Summary
     
    Fields inherited from interface tig.GeneralConstants
    BLANK, FS, LS, NO_SPECIF, SPACE
     
    Fields inherited from interface jephem.astro.spacetime.UnitsConstants
    ANGULAR_SPEED_UNIT_ARCSEC_PER_DAY, ANGULAR_SPEED_UNIT_ARCSEC_PER_S, ANGULAR_SPEED_UNIT_DEG_PER_DAY, ANGULAR_SPEED_UNIT_DEG_PER_S, ANGULAR_SPEED_UNIT_RAD_PER_DAY, ANGULAR_UNIT_ARCSEC, ANGULAR_UNIT_DEG, ANGULAR_UNIT_RAD, BASE_ANGULAR_SPEED_UNIT, BASE_ANGULAR_UNIT, BASE_DISTANCE_UNIT, BASE_LINEAR_SPEED_UNIT, DEGREES_DECIMAL, DEGREES_DMS, DELTA_BETWEEN_BASES, DISTANCE_UNIT_AU, DISTANCE_UNIT_KM, DISTANCE_UNIT_M, LINEAR_SPEED_UNIT_AU_PER_D, LINEAR_SPEED_UNIT_KM_PER_D, LINEAR_SPEED_UNIT_KM_PER_HOUR, LINEAR_SPEED_UNIT_M_PER_S, TYPE_ANGULAR, TYPE_ANGULAR_SPEED, TYPE_DISTANCE, TYPE_LINEAR_SPEED, UNITGROUP_AU_AU_AU, UNITGROUP_AU_DEG_DEG, UNITGROUP_AU_RAD_RAD, UNITGROUP_AUD_AUD_AUD, UNITGROUP_KM_KM_KM
     
    Fields inherited from interface jephem.astro.solarsystem.SolarSystemConstants
    E0_1900, E0_1950, E0_2000, EARTH, JUPITER, KM_PER_AU, MARS, MERCURY, MOON, NB_BODIES, NEPTUNE, PLUTO, SATURN, SIDERAL_RATE, SUN, URANUS, VENUS
     
    Constructor Summary
    Body(int index)
              Constructor to use in general.
    Body(int index, int frame, int coordExpr, int[] posUnits, int[] velUnits, double x0, double x1, double x2, double v0, double v1, double v2)
              Complete constructor.
     
    Method Summary
     void cartToSphere(boolean velocities)
              Transformation of coordinates (positions and velocities), from cartesian to spherical.
     Body doClone()
              Returns a copy of this body.
     ComputationException getComputationException()
              Returns a computation exception, if one was thrown while computing the coordinates of this body.
     double getCoord(int iCoord)
              Returns the coordinate designated by 'iCoord' .
     int getCoordinateExpression()
              Returns the way body's coordinates are expressed (spherical, cartesian), using SpaceConstants constants for it.
     int getFrame()
              Returns the reference frame in which the body's coordinates are expressed, using SpaceConstants.FRAME_XXX constants.
     int getIndex()
              Returns the index of this body, using SolarSystemConstants constants.
     java.lang.String getName()
              Returns the English name of this body.
     Vector3 getPositionCoords()
              Returns a vector containing the position coordinates.
     int[] getPositionUnits()
              Returns the units used to express the positions, using constants of UnitsConstants.
     Vector3 getVelocityCoords()
              Returns a vector containing the position coordinates.
     int[] getVelocityUnits()
              Returns the units used to express the velocities, using constants of UnitsConstants.
     void setComputationException(ComputationException ce)
              To store a computation exception, if one is thrown while computing the coordinates of this body.
     void setCoord(int iCoord, double coord)
              Sets a coordinate using an index to designate the coordinate.
     void setCoordinateExpression(int coordExpr)
              Sets the way body's coordinates are expressed ; use SpaceConstants.
     void setFrame(int frame)
              Sets the reference frame in which the body's coordinates are expressed ;
    use SpaceConstants.FRAME_XXX constants.
     void setIndex(int index)
              Sets the index of this body, using SolarSystemConstants constants.
     void setPositionCoords(double x0, double x1, double x2)
              Sets the position coordinates from 3 doubles.
     void setPositionCoords(Vector3 pos)
              Sets the position coordinates from a vector.
     void setPositionUnits(int[] positionUnits)
              Sets the units used to express the positions, using constants of UnitsConstants.
     void setVelocityCoords(double x0, double x1, double x2)
              Sets the velocity coordinates from 3 doubles.
     void setVelocityCoords(Vector3 vel)
              Sets the velocity coordinates from a vector.
     void setVelocityUnits(int[] velocityUnits)
              sets the units used to express the velocities, using constants of UnitsConstants.
     void sphereToCart(boolean velocities)
              Transformation of coordinates (positions and velocities), from spherical to cartesian.
     java.lang.String toString()
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Constructor Detail

    Body

    public Body(int index)
    Constructor to use in general. Coordinates are initialized to 0.0 ; frame, coordinateExpression, positionUnits, velocityUnits are initialized to GeneralConstants.NO_SPECIF.

    Parameters:
    index - index of Body to create, using SolarSystemConstants constants.

    Body

    public Body(int index,
                int frame,
                int coordExpr,
                int[] posUnits,
                int[] velUnits,
                double x0,
                double x1,
                double x2,
                double v0,
                double v1,
                double v2)
    Complete constructor.

    Parameters:
    index - index of Body to create ; use SolarSystemConstants constants.
    frame - Coordinate system in which body coordinates must be expressed ; use SpaceConstants constants.
    coordExpr - Way coordinates must be expressed (cartesian, spherical) ; use SpaceConstants constants.
    posUnits - Units used for the positions (use UnitsConstants constants).
    velUnits - Units used for the velocities (use UnitsConstants constants).
    x0 - Value of the first position coordinate.
    x1 - Value of the second position coordinate.
    x2 - Value of the third position coordinate.
    v0 - Value of the first velocity coordinate.
    v1 - Value of the second velocity coordinate.
    v2 - Value of the third velocity coordinate.
    Throws:
    java.lang.IllegalArgumentException - if posUnits.lenght or velUnits.lenght != 3.
    Method Detail

    cartToSphere

    public void cartToSphere(boolean velocities)
    Transformation of coordinates (positions and velocities), from cartesian to spherical.

    Parameters:
    velocities - Indicates if the velocities should be also transformed.
    Throws:
    java.lang.IllegalArgumentException - If units have not been assigned before trying to transform

    doClone

    public Body doClone()
    Returns a copy of this body.


    getComputationException

    public ComputationException getComputationException()
    Returns a computation exception, if one was thrown while computing the coordinates of this body.


    getCoord

    public double getCoord(int iCoord)
    Returns the coordinate designated by 'iCoord' .
    WARNING : if parameter 'iCoord' not valid, just returns 0.

    Parameters:
    iCoord - : index of coordinate to get (0 : x0, ... , 5 : v2). SpaceConstants.COORD_XX constants can be used to express index.

    getCoordinateExpression

    public int getCoordinateExpression()
    Returns the way body's coordinates are expressed (spherical, cartesian), using SpaceConstants constants for it.


    getFrame

    public int getFrame()
    Returns the reference frame in which the body's coordinates are expressed, using SpaceConstants.FRAME_XXX constants.


    getIndex

    public int getIndex()
    Returns the index of this body, using SolarSystemConstants constants.


    getName

    public java.lang.String getName()
    Returns the English name of this body.
    Equivalent to SolarSystem.getBodyName(this.getIndex())


    getPositionCoords

    public Vector3 getPositionCoords()
    Returns a vector containing the position coordinates.


    getPositionUnits

    public int[] getPositionUnits()
    Returns the units used to express the positions, using constants of UnitsConstants.


    getVelocityCoords

    public Vector3 getVelocityCoords()
    Returns a vector containing the position coordinates.


    getVelocityUnits

    public int[] getVelocityUnits()
    Returns the units used to express the velocities, using constants of UnitsConstants.


    setComputationException

    public void setComputationException(ComputationException ce)
    To store a computation exception, if one is thrown while computing the coordinates of this body.


    setCoord

    public void setCoord(int iCoord,
                         double coord)
    Sets a coordinate using an index to designate the coordinate.

    Parameters:
    iCoord - : index of coordinate to get (0 : x0, ... , 5 : v2).

    setCoordinateExpression

    public void setCoordinateExpression(int coordExpr)
    Sets the way body's coordinates are expressed ; use SpaceConstants.SPHERICAL or CARTESIAN constants for it.


    setFrame

    public void setFrame(int frame)
    Sets the reference frame in which the body's coordinates are expressed ;
    use SpaceConstants.FRAME_XXX constants.


    setIndex

    public void setIndex(int index)
    Sets the index of this body, using SolarSystemConstants constants.


    setPositionCoords

    public void setPositionCoords(double x0,
                                  double x1,
                                  double x2)
    Sets the position coordinates from 3 doubles.


    setPositionCoords

    public void setPositionCoords(Vector3 pos)
    Sets the position coordinates from a vector.


    setPositionUnits

    public void setPositionUnits(int[] positionUnits)
    Sets the units used to express the positions, using constants of UnitsConstants.


    setVelocityCoords

    public void setVelocityCoords(double x0,
                                  double x1,
                                  double x2)
    Sets the velocity coordinates from 3 doubles.


    setVelocityCoords

    public void setVelocityCoords(Vector3 vel)
    Sets the velocity coordinates from a vector.


    setVelocityUnits

    public void setVelocityUnits(int[] velocityUnits)
    sets the units used to express the velocities, using constants of UnitsConstants.


    sphereToCart

    public void sphereToCart(boolean velocities)
                      throws AstroException
    Transformation of coordinates (positions and velocities), from spherical to cartesian.

    Parameters:
    velocities - Indicates if the velocities should be also transformed.
    Throws:
    java.lang.IllegalArgumentException - If units have not been assigned before trying to transform
    AstroException

    toString

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

    JEphem site
    tig API
    Build classes