Skip to content

Documentation / @interstellar-tools/equations / galactocentricToGalactic

Function: galactocentricToGalactic() ​

ts
function galactocentricToGalactic(
  position: PositionInterface,
  options?: GalactocentricToGalacticOptionsInterface
): GalacticDirectionAndDistanceInterface;

Defined in: galactic/galactocentric-to-galactic.ts:90

The direction and distance from the Sun of a galactocentric position: the inverse of galactocentricPosition. It untilts the plane by θ=arcsin⁡(z⊙/R0), moves the origin back to the Sun, and reads off the galactic longitude, latitude and distance:

X=xcos⁡θ−zsin⁡θ+R0,Y=y,Z=xsin⁡θ+zcos⁡θd=X2+Y2+Z2,l=atan2(Y,X),b=atan2(Z,X2+Y2)

Notes

  • Use the same sunDistance and sunHeight as the position was made with.
  • At the Sun itself, distance 0, the direction means nothing.

Parameters ​

ParameterTypeDescription
positionPositionInterfaceA position in the 'galactocentric' frame.
options?GalactocentricToGalacticOptionsInterfaceThe unit of the distance, and the Sun's place, if not the defaults.

Returns ​

GalacticDirectionAndDistanceInterface

The direction from the Sun, l from 0° up to 360°, and the distance.

Throws ​

If the position isn't in the 'galactocentric' frame, a coordinate isn't finite, or the Sun's height isn't less than its distance from the centre.

Example ​

ts
// The origin, the Milky Way's centre: R0 from the Sun, towards l = b = 0
const { direction, distance } = galactocentricToGalactic({
  frame: 'galactocentric',
  x: { value: 0, unit: 'pc' },
  y: { value: 0, unit: 'pc' },
  z: { value: 0, unit: 'pc' }
}); // direction { l: 0, b: 0 }, distance { value: 8275.9, unit: 'pc' }

See ​

galactocentricPosition, its inverse.