Created
December 22, 2024 13:08
-
-
Save kikuchan/3a0127b8eb19bcf49ad0a271d64b2ef0 to your computer and use it in GitHub Desktop.
maplibre-gl-js: light position calculation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lightPosition(lat: number, lng: number) { | |
const sin = (d: number) => Math.sin(d * Math.PI / 180); | |
const cos = (d: number) => Math.cos(d * Math.PI / 180); | |
const acos = (v: number) => Math.acos(v) * 180 / Math.PI; | |
const b = acos(cos(lat) * cos(lng)); | |
const a = acos(sin(lat) / sin(b)); | |
return [-1, a, b] as [number, number, number]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment