I’ve an SCNScene with the earth represented by an SCNSphere of radius 1.
I wish to characterize a geographic coordinate for some extent on the earth’s floor by a dot on sphere.
How can I convert a geographic coordinate to an SCNVector3 to place the dot on my sphere.
To date I’ve the next however I am undecided if it is appropriate:
func convertCoordinatesToVector(latitude: Double, longitude: Double, elevation: Double, radius: Double) -> SCNVector3 {
let latRad = latitude * .pi / 180.0
let longRad = longitude * .pi / 180.0
let x = cos(latRad) * cos(longRad) * Double(radius + elevation)
let y = sin(latRad) * Double(radius + elevation)
let z = cos(latRad) * sin(longRad) * Double(radius + elevation)
return SCNVector3(x, y, z)
}