/** * Quaternion helpers for globe dragging. * * A projection's rotation is three Euler angles, and interpolating or * accumulating those directly is what produces the "sticky globe": drag left * near the pole and the sphere slides sideways instead of following the cursor, * because a longitude step is worth a different amount of surface at every * latitude. Quaternions have no such preferred axis, so "turn the sphere by * whatever rotation carries the point I grabbed to the point I am now over" is * a single well-defined operation. * * The algorithm is Bostock and Davies' versor drag. Kept here rather than taken * from the `versor` package: it is forty lines, and this way globe rotation adds * nothing to the dependency tree. * * @module geo/Versor */ /** A unit quaternion, `[w, x, y, z]`. */ export type Quaternion = [number, number, number, number]; /** A point on the unit sphere in Cartesian coordinates. */ export type Cartesian = [number, number, number]; /** Projection rotation, `[lambda, phi, gamma]` in degrees. */ export type Rotation = [number, number, number]; /** The quaternion equivalent to a projection's `[lambda, phi, gamma]`. */ export declare function versor([lambda, phi, gamma]: Rotation): Quaternion; /** A lon/lat pair in degrees as a point on the unit sphere. */ export declare function cartesian([lon, lat]: [number, number]): Cartesian; /** The `[lambda, phi, gamma]` a projection would need to apply this quaternion. */ export declare function rotation(q: Quaternion): Rotation; /** * The shortest rotation carrying `v0` to `v1`: the great-circle arc between * them, taken about the axis perpendicular to both. * * Returns the identity when the two points coincide (or are exactly antipodal, * where the axis is undefined and any answer would be arbitrary). */ export declare function delta(v0: Cartesian, v1: Cartesian): Quaternion; /** * Interpolate between two orientations along the shortest arc, at constant * angular speed. * * This is what a camera move to a new sub-observer point has to use. Lerping * `[lambda, phi]` component-wise instead looks correct in a diagram and wrong on * screen: the two angles are not independent, so the sphere wobbles as one * outruns the other, a move across the antimeridian takes the long way round * unless the caller unwraps by hand, and a move over a pole swings out sideways * because longitude has to travel 180 degrees while latitude travels none. * * Quaternions double-cover rotations (`q` and `-q` are the same orientation), so * the sign is chosen to keep the arc under 180 degrees. Near-parallel inputs * fall back to a normalised lerp, where the great-circle formula divides by a * sine approaching zero. */ export declare function slerp(q0: Quaternion, q1: Quaternion, t: number): Quaternion; /** Compose two rotations: `q0` then `q1`. */ export declare function multiply(q0: Quaternion, q1: Quaternion): Quaternion; //# sourceMappingURL=Versor.d.ts.map