Reference · Rockets, variants, parts and the fit check
tiltTurnfunction
The turn (degrees round, degrees up or down) for a reading, measured from rest (how the device was held when tilting began). angle is the screen's orientation (0, 90, 180 or 270), so leaning a phone held sideways still turns the view the way it looks. Null for an empty reading.
Import it
import { tiltTurn } from "@johnmorrisdotca/uchusen-rockets";
Definition
function tiltTurn(reading: Reading, rest: Reading, angle?: number): { azimuth: number; polar: number; } | null
Parameters
| Name | Type | Description |
|---|---|---|
reading | Reading | The current reading. |
rest | Reading | The reading when tilting began. |
angle (optional) | number | The screen's orientation: 0, 90, 180 or 270. Defaults to 0. |
Returns
{ azimuth: number; polar: number; } | null
The turn in degrees round (azimuth) and up or down (polar), or null for an empty reading.
Examples
import { tiltTurn } from "@johnmorrisdotca/uchusen-rockets";
console.log(tiltTurn({ beta: 30, gamma: 10 }, { beta: 20, gamma: 0 }), tiltTurn({ beta: null, gamma: null }, { beta: 0, gamma: 0 }));{ azimuth: 6, polar: -3 } nullWhat it prints (run when this page was built)