-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
132 lines (110 loc) · 4.45 KB
/
Copy pathmodels.py
File metadata and controls
132 lines (110 loc) · 4.45 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import math
import numpy as np
from scipy.special import comb
class Point3D:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def distance_to(self, other):
return math.sqrt(
(self.x - other.x) ** 2 +
(self.y - other.y) ** 2 +
(self.z - other.z) ** 2
)
class Moon:
def __init__(self):
self.radius = 1737e3 # Ay yarıçapı (metre)
self.orbit_radius = 384400e3 # Ay'ın Dünya'ya ortalama uzaklığı
self.orbital_period = 27.32 * 24 * 3600 # Ay'ın yörünge periyodu (saniye)
self.current_angle = 0
def update_position(self, time):
# Ay'ın açısal hızı
angular_velocity = 2 * math.pi / self.orbital_period
self.current_angle = (angular_velocity * time) % (2 * math.pi)
def get_position(self):
x = self.orbit_radius * math.cos(self.current_angle)
y = self.orbit_radius * math.sin(self.current_angle)
z = 0 # Ay'ın yörüngesini basitleştirmek için düzlemsel kabul ediyoruz
return Point3D(x, y, z)
class BezierTrajectory:
def __init__(self, control_points):
self.control_points = control_points
def calculate_point(self, t):
n = len(self.control_points) - 1
point = Point3D(0, 0, 0)
for i in range(n + 1):
coef = comb(n, i) * (t ** i) * ((1 - t) ** (n - i))
point.x += coef * self.control_points[i].x
point.y += coef * self.control_points[i].y
point.z += coef * self.control_points[i].z
return point
class Rocket:
def __init__(self, max_fuel):
self.max_fuel = max_fuel
self.current_fuel = max_fuel
self.fuel_consumption_rate = 0.0001 # kg/m
self.refuel_consumption_rate = 0.1 # kg/kg transferred
self.speed = 10000 # m/s (36,000 km/h ortalama uzay aracı hızı)
def calculate_fuel_consumption(self, distance):
"""
Belirli bir mesafe için gereken yakıt miktarını hesaplar
Args:
distance: Kat edilecek mesafe (metre)
Returns:
float: Gereken yakıt miktarı
"""
return distance * self.fuel_consumption_rate
def calculate_trajectory(self, start_pos, end_pos, gravity_bodies):
# Ara kontrol noktaları oluştur
control_points = [start_pos]
# Yerçekimi etkisini hesaba katarak ara noktaları belirle
mid_point = Point3D(
(start_pos.x + end_pos.x) / 2,
(start_pos.y + end_pos.y) / 2,
(start_pos.z + end_pos.z) / 2
)
# Yerçekimi etkisiyle eğrilik ekle
for body in gravity_bodies:
body_pos = body.get_position()
gravity_factor = 1000000 # Yerçekimi etkisinin şiddeti
mid_point.x += (body_pos.x - mid_point.x) / gravity_factor
mid_point.y += (body_pos.y - mid_point.y) / gravity_factor
mid_point.z += (body_pos.z - mid_point.z) / gravity_factor
control_points.append(mid_point)
control_points.append(end_pos)
return BezierTrajectory(control_points)
def has_enough_fuel(self, required_fuel):
"""
Yeterli yakıt olup olmadığını kontrol eder
"""
return self.current_fuel >= required_fuel
def consume_fuel(self, amount):
"""
Yakıt tüketir
"""
if self.has_enough_fuel(amount):
self.current_fuel -= amount
return True
return False
def refuel(self):
"""
Yakıt deposunu doldurur
"""
self.current_fuel = self.max_fuel
class Satellite:
def __init__(self, id, orbit_radius, initial_angle, inclination, initial_fuel):
self.id = id
self.orbit_radius = orbit_radius
self.current_angle = initial_angle
self.inclination = inclination
self.fuel = initial_fuel
self.orbit_speed = math.sqrt(3.986e14 / orbit_radius) # Kepler'in 3. yasası
@property
def current_position(self):
x = self.orbit_radius * math.cos(self.current_angle)
y = self.orbit_radius * math.sin(self.current_angle) * math.cos(self.inclination)
z = self.orbit_radius * math.sin(self.current_angle) * math.sin(self.inclination)
return Point3D(x, y, z)
def update_position(self, time_step):
self.current_angle += self.orbit_speed * time_step