36 #ifndef __SBNW_MATH_GEOM_H_
37 #define __SBNW_MATH_GEOM_H_
42 #include "graphfab/layout/point.h"
55 const Real pi = 3.14159;
60 inline Point computeCubic(
const Point& alpha,
const Point& beta,
const Point& gamma,
const Point& delta,
Real t) {
61 return alpha*t*t*t + beta*t*t + gamma*t + delta;
64 inline Point new2ndPos(
const Point& first,
const Point& second,
const Real deg,
const Real dist,
const bool rel_dist) {
66 Real hnew, onew, anew;
68 o = second.y - first.y;
69 a = second.x - first.x;
70 h = sqrt(pow(a,2.) + pow(o,2.));
82 x = sign(o)*3.14159/2.;
84 onew = hnew * sin(x + deg2r(deg));
85 anew = hnew * cos(x + deg2r(deg));
87 if(second.x >= first.x)
88 return Point(first.x + anew, first.y + onew);
90 return Point(first.x - anew, first.y - onew);
94 Point calcCurveBackup(
const Point& src,
const Point& cent,
const Box& ext,
Real dist = 20);
98 Line2Desc(
const Point& start,
const Point& end);
100 Real getA()
const {
return A_; }
102 Real getB()
const {
return B_; }
104 Real getC()
const {
return C_; }
109 _GraphfabExport
friend std::ostream& operator<<(std::ostream& o,
const Line2Desc& c);
112 _GraphfabExport std::ostream& operator<<(std::ostream& o,
const Line2Desc& c);
114 class CubicBezier2Desc {
116 CubicBezier2Desc(
const Point& start,
const Point& c1,
const Point& c2,
const Point& end);
119 Point p(
Real t)
const;
122 Point getCP(
int n)
const;
125 Point P0_, P1_, P2_, P3_;
127 _GraphfabExport
friend std::ostream& operator<<(std::ostream& o,
const CubicBezier2Desc& c);
130 _GraphfabExport std::ostream& operator<<(std::ostream& o,
const CubicBezier2Desc& c);
133 class CubicBezierIntersection {
135 CubicBezierIntersection(
const Line2Desc& l,
const CubicBezier2Desc& c);
137 const std::vector<Real>& getIntersectionPoints()
const {
return r_; }
140 std::vector<Real> r_;
155 class LinearIntersection {
157 LinearIntersection(
const Point& pbegin,
const Point& pend,
const Point& qbegin,
const Point& qend);
159 const Point& p() {
return p_; }
160 bool exists() {
return v_; }
173 #endif // __cplusplus
SAGITTARIUS_REAL Real
Make Real visible to C. Consider letting Real lie in top namespace.
Definition: SagittariusCommon.h:136
Sign & magnitude for reals.
Definition: SagittariusCommon.cpp:38