Download node_modules/d3-geo/src/cartesian.js from NKessler/Horizon: direct link, hf CLI and curl.
- Browser
- Download file 932 Bytes
-
https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-geo/src/cartesian.js
- Command line
-
hf download hf://NKessler/Horizon/node_modules/d3-geo/src/cartesian.js
-
curl -L -o cartesian.js https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-geo/src/cartesian.js
932 Bytes
| import {asin, atan2, cos, sin, sqrt} from "./math.js"; | |
| export function spherical(cartesian) { | |
| return [atan2(cartesian[1], cartesian[0]), asin(cartesian[2])]; | |
| } | |
| export function cartesian(spherical) { | |
| var lambda = spherical[0], phi = spherical[1], cosPhi = cos(phi); | |
| return [cosPhi * cos(lambda), cosPhi * sin(lambda), sin(phi)]; | |
| } | |
| export function cartesianDot(a, b) { | |
| return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; | |
| } | |
| export function cartesianCross(a, b) { | |
| return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]; | |
| } | |
| // TODO return a | |
| export function cartesianAddInPlace(a, b) { | |
| a[0] += b[0], a[1] += b[1], a[2] += b[2]; | |
| } | |
| export function cartesianScale(vector, k) { | |
| return [vector[0] * k, vector[1] * k, vector[2] * k]; | |
| } | |
| // TODO return d | |
| export function cartesianNormalizeInPlace(d) { | |
| var l = sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); | |
| d[0] /= l, d[1] /= l, d[2] /= l; | |
| } | |