Skip to content

Documentation / @interstellar-tools/equations / galactocentricPosition

Function: galactocentricPosition() ​

ts
function galactocentricPosition(
  direction: GalacticDirectionInterface,
  distance: DistanceInterface,
  options?: GalactocentricPositionOptionsInterface
): PositionInterface;

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

The position around the Milky Way's centre of something seen from the Sun: turns a direction in galactic coordinates and a distance, as GALAXIES in @interstellar-tools/constants gives them, into x, y, z in the 'galactocentric' frame.

The frame is Astropy's Galactocentric: x points from the Sun towards the centre, y in the direction the Sun moves around it (galactic longitude 90°), and z to the galaxy's north pole. From the Sun's position in galactic coordinates,

X=dcos⁡bcos⁡l−R0,Y=dcos⁡bsin⁡l,Z=dsin⁡b

the plane is tilted by θ=arcsin⁡(z⊙/R0), because the Sun is z⊙ above it:

x=Xcos⁡θ+Zsin⁡θ,y=Y,z=−Xsin⁡θ+Zcos⁡θ

Notes

  • The centre is where Astropy puts it: at R0 towards galactic longitude and latitude 0°, the IAU's galactic centre, 4.3′ (10.5 pc) from Sagittarius A*.
  • It matches Astropy's transform from right ascension and declination to about 2 parts in a million of the distance, the size of the difference between the IAU's galactic coordinates and Astropy's centre.
  • The Sun itself, at distance 0, is at (−R02−z⊙2,0,z⊙).

Parameters ​

ParameterTypeDescription
directionGalacticDirectionInterfaceThe direction from the Sun: galactic longitude l and latitude b, in degrees.
distanceDistanceInterfaceThe distance from the Sun.
options?GalactocentricPositionOptionsInterfaceThe unit of the result, and the Sun's place, if not the defaults.

Returns ​

PositionInterface

The position in the 'galactocentric' frame, in options.unit or the unit of distance.

Throws ​

If an angle or a distance isn't finite, b is outside −90° to 90°, distance is negative, or the Sun's height isn't less than its distance from the centre.

Example ​

ts
import { GALAXIES } from '@interstellar-tools/constants';
import { galactocentricPosition } from '@interstellar-tools/equations';

const andromeda = GALAXIES.find((galaxy) => galaxy.id === 'andromeda')!;
const position = galactocentricPosition(
  andromeda.direction!,
  andromeda.distance,
  { unit: 'kpc' }
);

console.log(position.x.value, position.y.value, position.z.value); // ≈ -375.31 605.50 -278.87

See ​

https://docs.astropy.org/en/stable/coordinates/galactocentric.html Astropy: the Galactocentric frame