201 def on_ellipse sx sy e_angle 202 e_angle 203 r1 sqrt sx sy 204 the

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
201 def on_ellipse(sx, sy, e, h, e_angle):
202 #e_angle = 0
203 r1 = sqrt(sx**2 + sy**2)
204 theta = get_angle(sx, sy)
205 for shift in [0, pi]:
206 u = (cos(e_angle + shift), sin(e_angle + shift))
207 v = (cos(e_angle+pi/2+ shift), sin(e_angle+pi/2+ shift))
208
209 su = sx * u[0] + sy * u[1]
210 sv = sx * v[0] + sy * v[1]
211
212 r_p = (h**2 / mu) * (1/(1+e))
213 r_a = (h**2 / mu) * (1/(1-e))
214
215 # semi-major axis
216 a = (r_a + r_p)/2
217 # semi-minor axis
218 b = a * sqrt(1 - e**2)
219
220
221 #r = h**2/mu /(1+e*cos(theta-e_angle-shift))
222 #print r1 - r
223
224 if abs(su**2/a**2 + sv**2/b**2 - 1) < EPS:
225 return True
226 return False