I’ve an SCNScene with the earth represented by an SCNSphere of radius 1.
I wish to signify a geographic coordinate for a degree 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 this point I’ve the next however I am unsure if it is right:
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)
}