diff --git a/planet/planet.c b/planet/planet.c index fcc1e5790ff9dc41f6ed71ee033530bf4ce77fbc..371fa869ef3ee5a4d547f14d375f0556efa50055 100755 --- a/planet/planet.c +++ b/planet/planet.c @@ -65,7 +65,7 @@ void show_system(struct gfx_context_t* ctxt, system_t* system) { // draw planets for (uint32_t i = 0; i < system->nb_planets; ++i) { const coordinates xy = vec2_to_coordinates_centered( - vec2_normalize(system->planets[i].pos), + vec2_mul(vec2_norm(system->planets[i].pos) / (PER_MARS * 1.25), vec2_normalize(system->planets[i].pos)), ctxt->width, ctxt->height); draw_full_circle(ctxt, xy.column, xy.row, 20, COLOR_BLUE); @@ -95,7 +95,6 @@ void update_system(system_t* system, double delta_t) { next_pos = vec2_add(next_pos, vec2_mul(delta_t * delta_t, a)); system->planets[i].prec_pos = system->planets[i].pos; system->planets[i].pos = next_pos; - printf("%lf %lf %lf\n", system->planets[i].pos.x, system->planets[i].pos.y, vec2_norm(a)); } } diff --git a/vec2/vec2.c b/vec2/vec2.c index b8991e65a424e11db7eb3a471edb33fd7bba75a3..60a972b8bb64be78a7a5775af2a4a96ce4229847 100755 --- a/vec2/vec2.c +++ b/vec2/vec2.c @@ -67,6 +67,7 @@ double vec2_norm(vec2 v) { /// @return The new normalized vector. vec2 vec2_normalize(vec2 v) { double norm = vec2_norm(v); + if (0 == norm) { return vec2_create_zero(); } return (vec2) {.x = v.x / norm, .y = v.y / norm}; }