Open johndpope opened 6 years ago
orbits with eccentricity / elliptic curves
// add one trajectory point of planet to scene
func addTrajectoryPoint(position: SCNVector3){
// check planet finished one full rotation cycle
if(self.time == 0.0){
self.orbit.isTrajFinish = true
}
// if one cycle is not finished
// add point to scene
if(!self.orbit.isTrajFinish){
self.orbit.updateTrajectory(planetPosition: self.position)
}
}
// make one rotation step on V angle
func rotationStep(position: SCNVector3, scale: Float!){
// rotation time moment
self.time = (self.time + self.dt) <= self.T ? self.time + self.dt : 0.0
// find the angle E(t) solving kelper eq with Halleys method
// after it find true anomaly v(E, t)
var newPosition = SCNVector3()
self.M = self.n * self.time
self.E = methodHalleys()
self.v = trueAnomaly()
// set new position to move
newPosition.x = self.orbit.x(angle: self.v) / scale
newPosition.y = position.y
newPosition.z = self.orbit.z(angle: self.v) / scale
// speed calculation
speedAtPoint(r: self.orbit.r(angle: self.v))
// move to new position
self.position = newPosition
}
https://github.com/Stellarium/stellarium/blob/ff2e4e253a57ee0da3b5279fe91904a2d160cb13/src/core/modules/GridLinesMgr.cpp