.. default-domain:: js .. highlight:: js .. module:: SpaceCenter :no-index: CelestialBody ============= .. class:: CelestialBody Represents a celestial body (such as a planet or moon). See :func:`SpaceCenter.getBodies`. .. method:: getName() The name of the body. :Property: Read-only, cannot be set :rtype: ``string`` .. method:: getSatellites() A list of celestial bodies that are in orbit around this celestial body. :Property: Read-only, cannot be set :rtype: ``Array`` of :class:`SpaceCenter.CelestialBody` .. method:: getOrbit() The orbit of the body. :Property: Read-only, cannot be set :rtype: :class:`SpaceCenter.Orbit` or ``null`` .. method:: getMass() The mass of the body, in kilograms. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: getGravitationalParameter() The `standard gravitational parameter `_ of the body in :math:`\mathrm{m^{3} \cdot s^{-2}}`. This is :math:`GM`, where :math:`G` is the gravitational constant and :math:`M` the mass of the body. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: getSurfaceGravity() The acceleration due to gravity at sea level (mean altitude) on the body, in :math:`\mathrm{m/s^{2}}`. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: getRotationalPeriod() The sidereal rotational period of the body, in seconds. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: getRotationalSpeed() The rotational speed of the body, in :math:`\mathrm{rad/s}`. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: getRotationAngle() The current rotation angle of the body, in radians. A value between 0 and :math:`2\pi`. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: getInitialRotation() The initial rotation angle of the body (at UT 0), in radians. A value between 0 and :math:`2\pi`. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: getEquatorialRadius() The equatorial radius of the body, in meters. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: surfaceHeight(latitude, longitude) The height of the surface relative to mean sea level, in meters, at the given position. When over water this is equal to 0. :param latitude: Latitude in degrees. :type latitude: ``number`` :param longitude: Longitude in degrees. :type longitude: ``number`` :rtype: ``number`` .. method:: bedrockHeight(latitude, longitude) The height of the surface relative to mean sea level, in meters, at the given position. When over water, this is the height of the sea-bed and is therefore negative value. :param latitude: Latitude in degrees. :type latitude: ``number`` :param longitude: Longitude in degrees. :type longitude: ``number`` :rtype: ``number`` .. method:: mslPosition(latitude, longitude, referenceFrame) The position at mean sea level at the given latitude and longitude, in the given reference frame. :param latitude: Latitude in degrees. :type latitude: ``number`` :param longitude: Longitude in degrees. :type longitude: ``number`` :param referenceFrame: Reference frame for the returned position vector. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: Position as a vector. :rtype: ``[number, number, number]`` .. method:: surfacePosition(latitude, longitude, referenceFrame) The position of the surface at the given latitude and longitude, in the given reference frame. When over water, this is the position of the surface of the water. :param latitude: Latitude in degrees. :type latitude: ``number`` :param longitude: Longitude in degrees. :type longitude: ``number`` :param referenceFrame: Reference frame for the returned position vector. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: Position as a vector. :rtype: ``[number, number, number]`` .. method:: bedrockPosition(latitude, longitude, referenceFrame) The position of the surface at the given latitude and longitude, in the given reference frame. When over water, this is the position at the bottom of the sea-bed. :param latitude: Latitude in degrees. :type latitude: ``number`` :param longitude: Longitude in degrees. :type longitude: ``number`` :param referenceFrame: Reference frame for the returned position vector. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: Position as a vector. :rtype: ``[number, number, number]`` .. method:: positionAtAltitude(latitude, longitude, altitude, referenceFrame) The position at the given latitude, longitude and altitude, in the given reference frame. :param latitude: Latitude in degrees. :type latitude: ``number`` :param longitude: Longitude in degrees. :type longitude: ``number`` :param altitude: Altitude in meters above sea level. :type altitude: ``number`` :param referenceFrame: Reference frame for the returned position vector. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: Position as a vector. :rtype: ``[number, number, number]`` .. method:: surfaceReferenceFrame(latitude, longitude[, altitude]) Create a reference frame fixed to the surface at the given latitude and longitude. * The origin is the given altitude above the surface, at the given latitude and longitude. * The axes rotate with the body. * The x-axis points out from the center of the body. * The y-axis points north. * The z-axis points east. :param latitude: Latitude in degrees. :type latitude: ``number`` :param longitude: Longitude in degrees. :type longitude: ``number`` :param altitude: Altitude of the origin above the surface, in meters. Defaults to ``0.0``. :type altitude: ``number`` :rtype: :class:`SpaceCenter.ReferenceFrame` .. note:: Each call returns a new frame, as for :meth:`SpaceCenter.ReferenceFrame.createRelative`. .. method:: mslNormal(latitude, longitude, referenceFrame) The normal to the sphere at mean sea level, at the given latitude and longitude, in the given reference frame. This points straight up, away from the center of the body, and takes no account of the shape of the terrain. :param latitude: Latitude in degrees. :type latitude: ``number`` :param longitude: Longitude in degrees. :type longitude: ``number`` :param referenceFrame: Reference frame for the returned normal vector. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: The normal as a unit vector. :rtype: ``[number, number, number]`` .. method:: surfaceNormal(latitude, longitude, referenceFrame) The normal to the surface at the given latitude and longitude, in the given reference frame. This describes the slope of the terrain, and is the normal of the surface of the water when over water. :param latitude: Latitude in degrees. :type latitude: ``number`` :param longitude: Longitude in degrees. :type longitude: ``number`` :param referenceFrame: Reference frame for the returned normal vector. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: The normal as a unit vector. :rtype: ``[number, number, number]`` .. method:: bedrockNormal(latitude, longitude, referenceFrame) The normal to the surface at the given latitude and longitude, in the given reference frame. This describes the slope of the terrain, and is the normal of the sea-bed when over water. :param latitude: Latitude in degrees. :type latitude: ``number`` :param longitude: Longitude in degrees. :type longitude: ``number`` :param referenceFrame: Reference frame for the returned normal vector. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: The normal as a unit vector. :rtype: ``[number, number, number]`` .. method:: altitudeAtPosition(position, referenceFrame) The altitude, in meters, of the given position in the given reference frame. :param position: Position as a vector. :type position: ``[number, number, number]`` :param referenceFrame: Reference frame for the position vector. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :rtype: ``number`` .. method:: latitudeAtPosition(position, referenceFrame) The latitude of the given position, in the given reference frame. :param position: Position as a vector. :type position: ``[number, number, number]`` :param referenceFrame: Reference frame for the position vector. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :rtype: ``number`` .. method:: longitudeAtPosition(position, referenceFrame) The longitude of the given position, in the given reference frame. :param position: Position as a vector. :type position: ``[number, number, number]`` :param referenceFrame: Reference frame for the position vector. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :rtype: ``number`` .. method:: getSphereOfInfluence() The radius of the sphere of influence of the body, in meters. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: getIsStar() Whether or not the body is a star. :Property: Read-only, cannot be set :rtype: ``boolean`` .. method:: getHasSolidSurface() Whether or not the body has a solid surface. :Property: Read-only, cannot be set :rtype: ``boolean`` .. method:: getHasAtmosphere() ``true`` if the body has an atmosphere. :Property: Read-only, cannot be set :rtype: ``boolean`` .. method:: getAtmosphereDepth() The depth of the atmosphere, in meters. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: getHasOcean() ``true`` if the body has an ocean. :Property: Read-only, cannot be set :rtype: ``boolean`` .. method:: getOceanDensity() The density of the body's ocean, in :math:`\mathrm{kg/m^{3}}`. Returns zero if the body has no ocean. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: atmosphericDensityAtPosition(position, referenceFrame) The atmospheric density at the given position, in :math:`\mathrm{kg/m^{3}}`, in the given reference frame. :param position: The position vector at which to measure the density. :type position: ``[number, number, number]`` :param referenceFrame: Reference frame that the position vector is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :rtype: ``number`` .. method:: getHasAtmosphericOxygen() ``true`` if there is oxygen in the atmosphere, required for air-breathing engines. :Property: Read-only, cannot be set :rtype: ``boolean`` .. method:: temperatureAt(position, referenceFrame) The temperature on the body at the given position, in the given reference frame. :param position: Position as a vector. :type position: ``[number, number, number]`` :param referenceFrame: The reference frame that the position is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :rtype: ``number`` .. note:: The atmospheric ephemeris is evaluated at the current universal time. .. method:: densityAt(altitude) Gets the air density, in :math:`\mathrm{kg/m^{3}}`, for the specified altitude above sea level, in meters. :param altitude: :type altitude: ``number`` :rtype: ``number`` .. note:: This is an approximation, because actual calculations, taking sun exposure into account to compute air temperature, require us to know the exact point on the body where the density is to be computed (knowing the altitude is not enough). However, the difference is small for high altitudes, so it makes very little difference for trajectory prediction. .. method:: pressureAt(altitude) Gets the static pressure, in Pascals, for the specified altitude above sea level, in meters. :param altitude: :type altitude: ``number`` :rtype: ``number`` .. note:: Below sea level on a body with an ocean, this includes the pressure of the water. .. method:: getBiomes() The biomes present on this body. :Property: Read-only, cannot be set :rtype: ``Set`` of ``string`` .. method:: biomeAt(latitude, longitude) The biome at the given latitude and longitude, in degrees. :param latitude: :type latitude: ``number`` :param longitude: :type longitude: ``number`` :rtype: ``string`` .. method:: getFlyingHighAltitudeThreshold() The altitude, in meters, above which a vessel is considered to be flying "high" when doing science. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: getSpaceHighAltitudeThreshold() The altitude, in meters, above which a vessel is considered to be in "high" space when doing science. :Property: Read-only, cannot be set :rtype: ``number`` .. method:: getReferenceFrame() The reference frame that is fixed relative to the celestial body. * The origin is at the center of the body. * The axes rotate with the body. * The x-axis points from the center of the body towards the intersection of the prime meridian and equator (the position at 0° longitude, 0° latitude). * The y-axis points from the center of the body towards the north pole. * The z-axis points from the center of the body towards the equator at 90°E longitude. :Property: Read-only, cannot be set :rtype: :class:`SpaceCenter.ReferenceFrame` .. figure:: /images/reference-frames/celestial-body.png :align: center Celestial body reference frame origin and axes. The equator is shown in blue, and the prime meridian in red. .. method:: getNonRotatingReferenceFrame() The reference frame that is fixed relative to this celestial body, and orientated in a fixed direction (it does not rotate with the body). * The origin is at the center of the body. * The axes do not rotate. * The x-axis points in an arbitrary direction through the equator. * The y-axis points from the center of the body towards the north pole. * The z-axis points in an arbitrary direction through the equator. :Property: Read-only, cannot be set :rtype: :class:`SpaceCenter.ReferenceFrame` .. method:: getOrbitalReferenceFrame() The reference frame that is fixed relative to this celestial body, but orientated with the body's orbital prograde/normal/radial directions. * The origin is at the center of the body. * The axes rotate with the orbital prograde/normal/radial directions. * The x-axis points in the orbital anti-radial direction. * The y-axis points in the orbital prograde direction. * The z-axis points in the orbital normal direction. :Property: Read-only, cannot be set :rtype: :class:`SpaceCenter.ReferenceFrame` .. method:: position(referenceFrame) The position of the center of the body, in the specified reference frame. :param referenceFrame: The reference frame that the returned position vector is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: The position as a vector. :rtype: ``[number, number, number]`` .. method:: velocity(referenceFrame) The linear velocity of the body, in the specified reference frame. :param referenceFrame: The reference frame that the returned velocity vector is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: The velocity as a vector. The vector points in the direction of travel, and its magnitude is the speed of the body in :math:`\mathrm{m/s}`. :rtype: ``[number, number, number]`` .. method:: rotation(referenceFrame) The rotation of the body, in the specified reference frame. :param referenceFrame: The reference frame that the returned rotation is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: The rotation as a quaternion of the form ``(x, y, z, w)``. :rtype: ``[number, number, number, number]`` .. method:: direction(referenceFrame) The direction in which the north pole of the celestial body is pointing, in the specified reference frame. :param referenceFrame: The reference frame that the returned direction is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: The direction as a unit vector. :rtype: ``[number, number, number]`` .. method:: angularVelocity(referenceFrame) The angular velocity of the body in the specified reference frame. :param referenceFrame: The reference frame the returned angular velocity is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :returns: The angular velocity as a vector. The magnitude of the vector is the rotational speed of the body, in :math:`\mathrm{rad/s}`. The direction of the vector indicates the axis of rotation, using the right-hand rule. :rtype: ``[number, number, number]``