|
|
|
@ -51,7 +51,7 @@ OrbitTracker* create_orbit_tracker_with_min_time(int body_index, double min_time |
|
|
|
tracker->initial_angle = 0.0; |
|
|
|
tracker->initial_angle = 0.0; |
|
|
|
tracker->previous_angle = 0.0; |
|
|
|
tracker->previous_angle = 0.0; |
|
|
|
tracker->accumulated_rotation = 0.0; |
|
|
|
tracker->accumulated_rotation = 0.0; |
|
|
|
tracker->wrap_count = 0; |
|
|
|
tracker->initialized = false; |
|
|
|
tracker->orbit_completed = false; |
|
|
|
tracker->orbit_completed = false; |
|
|
|
tracker->time_at_completion = 0.0; |
|
|
|
tracker->time_at_completion = 0.0; |
|
|
|
tracker->min_time_seconds = min_time_seconds; |
|
|
|
tracker->min_time_seconds = min_time_seconds; |
|
|
|
@ -82,7 +82,7 @@ static void reset_tracker_fields(OrbitTracker* tracker) { |
|
|
|
tracker->initial_angle = 0.0; |
|
|
|
tracker->initial_angle = 0.0; |
|
|
|
tracker->previous_angle = 0.0; |
|
|
|
tracker->previous_angle = 0.0; |
|
|
|
tracker->accumulated_rotation = 0.0; |
|
|
|
tracker->accumulated_rotation = 0.0; |
|
|
|
tracker->wrap_count = 0; |
|
|
|
tracker->initialized = false; |
|
|
|
tracker->orbit_completed = false; |
|
|
|
tracker->orbit_completed = false; |
|
|
|
tracker->time_at_completion = 0.0; |
|
|
|
tracker->time_at_completion = 0.0; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -111,11 +111,11 @@ void update_orbit_tracker(OrbitTracker* tracker, CelestialBody* body, CelestialB |
|
|
|
current_angle = atan2(relative_pos.y, relative_pos.x); |
|
|
|
current_angle = atan2(relative_pos.y, relative_pos.x); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (tracker->wrap_count == 0) { |
|
|
|
if (!tracker->initialized) { |
|
|
|
tracker->initial_angle = current_angle; |
|
|
|
tracker->initial_angle = current_angle; |
|
|
|
tracker->previous_angle = current_angle; |
|
|
|
tracker->previous_angle = current_angle; |
|
|
|
tracker->accumulated_rotation = 0.0; |
|
|
|
tracker->accumulated_rotation = 0.0; |
|
|
|
tracker->wrap_count = 1; |
|
|
|
tracker->initialized = true; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -123,11 +123,9 @@ void update_orbit_tracker(OrbitTracker* tracker, CelestialBody* body, CelestialB |
|
|
|
|
|
|
|
|
|
|
|
if (angle_diff > M_PI) { |
|
|
|
if (angle_diff > M_PI) { |
|
|
|
angle_diff -= 2.0 * M_PI; |
|
|
|
angle_diff -= 2.0 * M_PI; |
|
|
|
tracker->wrap_count++; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (angle_diff < -M_PI) { |
|
|
|
if (angle_diff < -M_PI) { |
|
|
|
angle_diff += 2.0 * M_PI; |
|
|
|
angle_diff += 2.0 * M_PI; |
|
|
|
tracker->wrap_count++; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tracker->accumulated_rotation += angle_diff; |
|
|
|
tracker->accumulated_rotation += angle_diff; |
|
|
|
|