Reference · The Sun, Moon and planets: pure parts
earthHidesfunction
Whether the Earth hides a satellite. The Earth is the unit sphere at the origin. True when the line from the camera to the satellite meets that sphere before it arrives. A graze at the limb is not hidden (the line only touches the sphere), and neither is a satellite in front of the Earth. This is not the test for a satellite behind the camera.
Import it
import { earthHides } from "@johnmorrisdotca/chikyu-earth/space";
Definition
function earthHides(camera: { x: number; y: number; z: number; }, satellite: { x: number; y: number; z: number; }): boolean
Parameters
| Name | Type | Description |
|---|---|---|
camera | { x: number; y: number; z: number; } | The camera, in the same units as the sphere (Earth radii). |
satellite | { x: number; y: number; z: number; } | The satellite, in those units. |
Returns
boolean
True when the globe is in the way.
Examples
import { earthHides } from "@johnmorrisdotca/chikyu-earth/space";
const camera = { x: 0, y: 0, z: 4 };
console.log(earthHides(camera, { x: 0, y: 0, z: 1.2 }));
console.log(earthHides(camera, { x: 0, y: 0, z: -1.2 }));false
trueWhat it prints (run when this page was built)