You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// add one trajectory point of planet to scene
funcaddTrajectoryPoint(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
funcrotationStep(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)
varnewPosition=SCNVector3()self.M=self.n*self.timeself.E=methodHalleys()self.v=trueAnomaly()
// set new position to move
newPosition.x=self.orbit.x(angle:self.v)/scalenewPosition.y=position.ynewPosition.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}
Activity
johndpope commentedon Mar 9, 2018
https://github.com/UgolUgol/ARHome/blob/bd41f7e087ae05b33ce278a330b4ddd7202477d8/ARHOME112/Orbit.swift
orbits with eccentricity / elliptic curves