diff options
| author | Franklin Wei <me@fwei.tk> | 2019-02-03 17:51:06 -0500 |
|---|---|---|
| committer | Franklin Wei <me@fwei.tk> | 2019-02-03 17:51:06 -0500 |
| commit | 4d5b8732c97c73ce7cf04e6641a239ceb0447d8d (patch) | |
| tree | 5895cac7bcba52ab9f5481eee0dad066ad413326 /curve.h | |
| parent | 79a83c2cbee5adca798b8976b2a39ecd6ffd39af (diff) | |
| download | fieldviz-4d5b8732c97c73ce7cf04e6641a239ceb0447d8d.zip fieldviz-4d5b8732c97c73ce7cf04e6641a239ceb0447d8d.tar.gz fieldviz-4d5b8732c97c73ce7cf04e6641a239ceb0447d8d.tar.bz2 fieldviz-4d5b8732c97c73ce7cf04e6641a239ceb0447d8d.tar.xz | |
Add circular arc and spiral curves
Diffstat (limited to 'curve.h')
| -rw-r--r-- | curve.h | 36 |
1 files changed, 33 insertions, 3 deletions
@@ -1,5 +1,10 @@ +#ifndef CURVE_H +#define CURVE_H + #include <cmath> #include "vec3.h" +#include "quat.h" + using namespace std; class Curve { @@ -19,10 +24,35 @@ public: class Arc : Curve { private: vec3 center; - double radius; - double angle[2]; /* start and end angles */ + + /* these are relative to the center (direction will be determined + * by RHR of normal), and should be orthonormal */ + vec3 radius, normal; + + /* how many radians the arc extends for (can be greater than 2pi) */ + double angle; public: - LineSegment(vec3 a_, vec3 b_) : a(a_), b(b_) {}; + Arc(vec3 c_, vec3 r_, vec3 n_, double th) : center(c_), radius(r_), normal(n_), angle(th) {}; + + vec3 integrate(vec3 (*integrand)(vec3 s, vec3 ds), double delta); +}; + +class Spiral : Curve { +private: + vec3 origin; + + /* these are relative to the center (direction will be determined + * by RHR of normal), and should be orthonormal */ + vec3 radius, normal; + + /* how many radians the arc extends for (can be greater than 2pi) */ + double angle; + + /* space between turns (2pi) */ + double pitch; +public: + Spiral(vec3 c_, vec3 r_, vec3 n_, double th, double p) : origin(c_), radius(r_), normal(n_), angle(th), pitch(p) {}; vec3 integrate(vec3 (*integrand)(vec3 s, vec3 ds), double delta); }; +#endif |