Skip to content

Commit

Permalink
fix: fixes node position calculation for earth graph
Browse files Browse the repository at this point in the history
Co-authored-by: Rassl <[email protected]>
  • Loading branch information
Расул and Rassl committed Oct 2, 2023
1 parent 61be9e4 commit 7a3e04a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/transformers/earthGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ export const getPointAbove = (point: Vector3, radius: number) => {
}

export const getPositionFromLngLat = (lng: number, lat: number, radius: number) => {
const latRad = (lat * Math.PI) / 180
const lonRad = (lng * Math.PI) / 180
const phi = (lat * Math.PI) / 180
const theta = ((lng - 180) * Math.PI) / 180

// Calculate the Cartesian coordinates
const x = radius * Math.cos(latRad) * Math.cos(lonRad)
const y = radius * Math.sin(latRad)
const z = radius * Math.cos(latRad) * Math.sin(lonRad)
const x = -radius * Math.cos(phi) * Math.cos(theta)
const y = radius * Math.sin(phi)
const z = radius * Math.cos(phi) * Math.sin(theta)

return new Vector3(x, y, z)
}
Expand Down

0 comments on commit 7a3e04a

Please sign in to comment.