Skip to content
Snippets Groups Projects
Commit d7b34e78 authored by Boris Stefanovic's avatar Boris Stefanovic
Browse files

save

parent 5d3d4b0b
Branches
No related tags found
No related merge requests found
......@@ -7,6 +7,9 @@ TESTS:= draw_tests field_tests
all: main
exec: main
./main
main: main.o $(OBJFILES)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -lSDL2
......
......@@ -41,11 +41,7 @@ bool is_in_screen(coordinates_t pos) {
bool draw_field_line_point(struct gfx_context_t *ctxt, charge_t *charges, int num_charges, double x0, double x1, double y0, double y1, vec2 pos, vec2 *pos_next, double delta) {
vec2 e;
compute_total_normalized_e(charges, num_charges, pos, 0.01, &e);
double norm_e = vec2_norm(e);
// TODO: "Problème ici" ?
pos_next->x = pos.x + delta * (e.x / norm_e);
pos_next->y = pos.y + delta * (e.y / norm_e);
*pos_next = vec2_add(pos, vec2_mul(delta, vec2_normalize(e)));
if (pos_next->x <= 0 || pos_next->x >= 1 || pos_next->y <= 0 || pos_next->y >= 1)
return false;
......@@ -61,6 +57,7 @@ bool draw_field_line_point(struct gfx_context_t *ctxt, charge_t *charges, int nu
return !is_in_screen(coordinate_pos);
}
bool line_reach_charge(vec2 pos, charge_t *charges, int num_charges, double dx) {
for (int j = 0; j < num_charges; ++j) {
if (vec2_norm(vec2_sub(pos, charges[j].pos)) < dx / HEI) {
......@@ -103,6 +100,7 @@ static bool draw_field_line(struct gfx_context_t *ctxt, charge_t *charges, int n
return !stop_positive || !stop_negative;
}
/// Draw all the charges
/// A circle with minus sign for negative charges
/// A circle with a plus sign for positive charges
......@@ -129,6 +127,7 @@ static void draw_charges(struct gfx_context_t *context, charge_t *charges, int n
}
}
void draw_everything(
struct gfx_context_t *ctxt,
charge_t *charges,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment