diff options
| author | Franklin Wei <me@fwei.tk> | 2019-02-02 23:02:12 -0500 |
|---|---|---|
| committer | Franklin Wei <me@fwei.tk> | 2019-02-02 23:02:12 -0500 |
| commit | 79a83c2cbee5adca798b8976b2a39ecd6ffd39af (patch) | |
| tree | 379523f81d3e7dc02c62ca1505376b8d0bc6b30e /test.cpp | |
| download | fieldviz-79a83c2cbee5adca798b8976b2a39ecd6ffd39af.zip fieldviz-79a83c2cbee5adca798b8976b2a39ecd6ffd39af.tar.gz fieldviz-79a83c2cbee5adca798b8976b2a39ecd6ffd39af.tar.bz2 fieldviz-79a83c2cbee5adca798b8976b2a39ecd6ffd39af.tar.xz | |
initial commit
basic B field integrator
Diffstat (limited to 'test.cpp')
| -rw-r--r-- | test.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test.cpp b/test.cpp new file mode 100644 index 0000000..8d20829 --- /dev/null +++ b/test.cpp @@ -0,0 +1,36 @@ +#include <cmath> +#include <iostream> +#include "curve.h" + +vec3 integrand(vec3 s, vec3 ds) +{ + return ds; +} + +vec3 point; + +/* dl x r / (|r| ^ 2) */ +vec3 dB(vec3 s, vec3 ds) +{ + vec3 r = s - point; + + double r2 = r.magnitudeSquared(); + + vec3 rnorm = r / std::sqrt(r2); + + return ds.cross(rnorm) / r2; +} + +int main() +{ + LineSegment wire(vec3(0, -100, 0), vec3(0, 100, 0)); + + vec3 dx = .001; + + point = .01; + + double I = 1; + + for(int i = 0; i < 100; i++, point += dx) + std::cout << point[0] << " " << wire.integrate(dB, 1e-2)[2] << endl; +} |