Skip to content

Commit

Permalink
fix: fixes node position calculation for earth graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Расул authored and Расул committed Oct 1, 2023
1 parent 61be9e4 commit a61b8a2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/transformers/earthGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ 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)

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

0 comments on commit a61b8a2

Please sign in to comment.