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

FIX: rewrite compute_total_normalized_e(...)

parent 2c62c72e
Branches
No related tags found
No related merge requests found
......@@ -21,9 +21,17 @@ 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) {
return EXIT_SUCCESS;
*e = vec2_create_zero();
vec2 ei = vec2_create_zero();
for (int i = 0; i < num_charges; ++i) {
if (!compute_e(charges[i], p, eps, &ei)) return false;
*e = vec2_add(*e, ei);
}
*e = vec2_normalize(*e);
return true;
}
// Compute and then draw all the points belonging to a field line,
// starting from pos0.
// Returns false if pos0 is not a valid position
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment