Reference · Stars: names, positions, distance and colour
starDistancefunction
A star's distance with its uncertainty, from the parallax and its error. Sirius is 8.5 light-years, to within 0.05; Betelgeuse's distance is a published paper's (168 parsecs, 548 light-years), so it is anywhere from 480 to 640 light-years. Rigel is rougher: from 590 to 1,480 light-years.
Import it
import { starDistance } from "@johnmorrisdotca/hoshi-stars";
Definition
function starDistance(star: Pick<Star, "parallaxMas" | "parallaxErrorMas">): StarDistance | undefined
Parameters
| Name | Type | Description |
|---|---|---|
star | Pick<Star, "parallaxMas" | "parallaxErrorMas"> | A star, or anything with a parallax in milliarcseconds and its error (a nearby star from |
Returns
StarDistance | undefined
The distance, its error and its range in light-years, or undefined where there is no parallax (or a non-positive one).
Examples
import { starByName, starDistance } from "@johnmorrisdotca/hoshi-stars";
const sirius = starDistance(starByName("Sirius")!)!;
console.log(sirius.lightYears.toFixed(2), sirius.lightYearsError?.toFixed(2), sirius.lightYearsRange?.map((ly) => ly.toFixed(2)));8.55 0.05 [ '8.50', '8.60' ]What it prints (run when this page was built)