-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrLine.h
106 lines (89 loc) · 2.63 KB
/
rLine.h
1
#ifndef rLinehh#define rLinehh//#include <iostream.h>#include <math.h>#include "rPoint.h"#include "rVector.h"using std::ostream;class rLineSegment;/* * Class declaration^ */class rLine { public: rVector q; // The equation for a rLine is x = q + tn rVector n; rVector junk; public: rLine () : q (), n(), junk () {} rLine (rVector); rLine (rPoint,rVector); rLine (rVector,rVector); rLine (rLine &); rLine (double ,double ,double ,double ,double ,double ); rLine& operator=(rLine p); operator rVector (); operator rPoint (); void set (rVector &); void set (rPoint &,rVector &); void set (rVector &,rVector &); void set_with_normal (rVector &,rVector &); void set (rLine&); void set (double ,double ,double ,double ,double ,double ); void scale (double i) { n.scale (i);} void normalize () { n.normalize (); } rLine operator*(double); /* scale */ int operator==(rLine p) {return (n == p.n) && (q == p.q); } void form_rLine (rVector A,rVector B) { n = B-A; q = A; //(rPoint)A; } rVector solve (double param) { return (rVector)(q + param*n); } int intersect (rVector v,double &t) { rVector tv; tv = (v-q)/n; //tv /= n; if (tv.x == tv.y == tv.z) { t = tv.z; return 1; } else return 0; } int projected_intersect (rVector v,double &t) { rVector tv; tv = v; tv -= (rVector &)q; tv /= n; if (tv.x == tv.y == tv.z) { t = tv.z; return 1; } else return 0; } double sub_det (rVector ,int ); double sub_det (rVector ,rVector ,int ); double intersect_param (rVector ,rVector ,int ); double intersect_param (rVector ,rVector ,double ,int ); double second_param (rVector ,rVector ,double ,int ); double rev_sub_det (rVector ,int ); double rev_sub_det (rVector ,rVector ,int ); double rev_intersect_param (rVector ,rVector ,int ); double rev_intersect_param (rVector ,rVector ,double ,int ); double rev_second_param (rVector ,rVector ,double ,int ); int intersect (rLine ,rVector &); int intersect (rVector ,rVector &); int near_intersect (rLine ,rVector &,rVector &); int near_intersect (rVector ,rVector &,rVector &); int projected_intersect (rLine ,rVector &); int projected_intersect (rVector ,rVector &); friend ostream& operator<<(ostream& , rLine& ); void *alloc () { return ((void *) new rLine ()); } void assign (void *trg,void *src) { *(rLine *)trg = *(rLine*)src; }/* virtual void dout (void *obj) { cerr <<*((rLine *)obj); }*/};#endif