Browse Source

display local position and velocity for children of bodies

main
cinnaboot 6 months ago
parent
commit
642a6e2573
  1. 15
      src/renderer.cpp

15
src/renderer.cpp

@ -548,6 +548,7 @@ void render_body_info_ui(SimulationState* sim, RenderState* render_state) {
strcat(info_text, "\n");
strcat(info_text, temp_buffer);
if (body->parent_index <= 0) {
// Position
snprintf(temp_buffer, sizeof(temp_buffer), "Position: (%.2e, %.2e, %.2e)",
body->position.x, body->position.y, body->position.z);
@ -559,6 +560,20 @@ void render_body_info_ui(SimulationState* sim, RenderState* render_state) {
snprintf(temp_buffer, sizeof(temp_buffer), "Velocity: %.2f m/s", vel_mag);
strcat(info_text, "\n");
strcat(info_text, temp_buffer);
} else {
// Position (Local)
snprintf(temp_buffer, sizeof(temp_buffer), "local_position: (%.2e, %.2e, %.2e)",
body->local_position.x, body->local_position.y, body->local_position.z);
strcat(info_text, "\n");
strcat(info_text, temp_buffer);
// Velocity (Local)
double parent_vel_mag = vec3_magnitude(sim->bodies[body->parent_index].velocity);
double vel_mag = vec3_magnitude(body->velocity) - parent_vel_mag;
snprintf(temp_buffer, sizeof(temp_buffer), "local_velocity: %.2f m/s", vel_mag);
strcat(info_text, "\n");
strcat(info_text, temp_buffer);
}
// Orbital elements
snprintf(temp_buffer, sizeof(temp_buffer), "Eccentricity: %.3f", body->eccentricity);

Loading…
Cancel
Save