diff --git a/.gitignore b/.gitignore index d5fc8a5e532e146eb2acd9ff88cb352eaecde503..ad64b2e38ab08b900213788d1e323475cd83d27e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .idea build *.o -doc/*.pdf +*.pdf diff --git a/src/field.c b/src/field.c new file mode 100644 index 0000000000000000000000000000000000000000..8bff07808808b201785e108cd9001895c5c6342a --- /dev/null +++ b/src/field.c @@ -0,0 +1,31 @@ +#include "physics.h" +#include <math.h> +#include <stdlib.h> + + +// Compute E*qP/norm(qP) +// Return false if norm(qP) < eps +bool compute_e(charge_t c, vec2 p, double eps, vec2 *e){ + return EXIT_SUCCESS; +} + +// Compute the normalized sum of Ei*qiP/norm(qiP) +// Return false if for some qiP, norm(qiP) < eps +bool compute_total_normalized_e(charge_t *charges, int num_charges, vec2 p, double eps, vec2 *e){ + return EXIT_SUCCESS; +} + +// Compute and then draw all the points belonging to a field line, +// starting from pos0. +// Returns false if pos0 is not a valid position +// (for example if pos0 is too close to a charge). +static bool draw_field_line(struct gfx_context_t *ctxt, charge_t *charges, int num_charges, double dx, vec2 pos0, double x0, double x1, double y0, double y1){ + return EXIT_SUCCESS; +} + +// Draw all the charges +// A circle with minus sign for negative charges +// A circle with a plus sign for positive charges +static void draw_charges(struct gfx_context_t *context, charge_t *charges, int num_charges, double x0, double x1, double y0, double y1){ + +} diff --git a/src/field.h b/src/field.h new file mode 100644 index 0000000000000000000000000000000000000000..8c1a1626c9dd9d50e6256c40d00a4721d997d2a5 --- /dev/null +++ b/src/field.h @@ -0,0 +1,33 @@ +#ifndef _PHYSIQUE_H_ +#define _PHYSIQUE_H_ +#include "../utils/vec2/vec2.h" +#include "../utils/gfx/gfx.h" +#include "../utils/utils.h" +#include <stdio.h> + +typedef struct charge_t +{ + double q; + vec2 pos; +} charge; + +// Compute E*qP/norm(qP) +// Return false if norm(qP) < eps +bool compute_e(charge_t c, vec2 p, double eps, vec2 *e); + +// Compute the normalized sum of Ei*qiP/norm(qiP) +// Return false if for some qiP, norm(qiP) < eps +bool compute_total_normalized_e(charge_t *charges, int num_charges, vec2 p, double eps, vec2 *e); + +// Compute and then draw all the points belonging to a field line, +// starting from pos0. +// Returns false if pos0 is not a valid position +// (for example if pos0 is too close to a charge). +static bool draw_field_line(struct gfx_context_t *ctxt, charge_t *charges, int num_charges, double dx, vec2 pos0, double x0, double x1, double y0, double y1); + +// Draw all the charges +// A circle with minus sign for negative charges +// A circle with a plus sign for positive charges +static void draw_charges(struct gfx_context_t *context, charge_t *charges, int num_charges, double x0, double x1, double y0, double y1); + +#endif