diff --git a/Code/Geometry/point.cpp b/Code/Geometry/point.cpp index 9bf1d61ed..dd0f6a3a6 100644 --- a/Code/Geometry/point.cpp +++ b/Code/Geometry/point.cpp @@ -7,120 +7,9 @@ #include "point.h" //#include -std::ostream & operator<<(std::ostream& target, const RDGeom::Point &pt){ - for (unsigned int di = 0; di < pt.dimension(); ++di) { - target << pt[di] << " "; - } - - return target; -} - -RDGeom::Point3D operator+ (const RDGeom::Point3D& p1, const RDGeom::Point3D& p2) { - RDGeom::Point3D res; - res.x = p1.x + p2.x; - res.y = p1.y + p2.y; - res.z = p1.z + p2.z; - return res; -} - -RDGeom::Point3D operator- (const RDGeom::Point3D& p1, const RDGeom::Point3D& p2) { - RDGeom::Point3D res; - res.x = p1.x - p2.x; - res.y = p1.y - p2.y; - res.z = p1.z - p2.z; - return res; -} - -RDGeom::Point3D operator* (const RDGeom::Point3D& p1, const double v) { - RDGeom::Point3D res; - res.x = p1.x * v; - res.y = p1.y * v; - res.z = p1.z * v; - return res; -} - -RDGeom::Point3D operator/ (const RDGeom::Point3D& p1, const double v) { - RDGeom::Point3D res; - res.x = p1.x / v; - res.y = p1.y / v; - res.z = p1.z / v; - return res; -} - -RDGeom::Point2D operator+ (const RDGeom::Point2D& p1, const RDGeom::Point2D& p2) { - RDGeom::Point2D res; - res.x = p1.x + p2.x; - res.y = p1.y + p2.y; - return res; -} - -RDGeom::Point2D operator- (const RDGeom::Point2D& p1, const RDGeom::Point2D& p2) { - RDGeom::Point2D res; - res.x = p1.x - p2.x; - res.y = p1.y - p2.y; - return res; -} - -RDGeom::Point2D operator* (const RDGeom::Point2D& p1, const double v) { - RDGeom::Point2D res; - res.x = p1.x * v; - res.y = p1.y * v; - return res; -} - -RDGeom::Point2D operator/ (const RDGeom::Point2D& p1, const double v) { - RDGeom::Point2D res; - res.x = p1.x / v; - res.y = p1.y / v; - return res; -} - - -RDGeom::PointND operator+ (const RDGeom::PointND& p1, const RDGeom::PointND& p2) { - unsigned int dim; - if(p1.dimension() #include -namespace RDGeom { - class Point3D; - class Point2D; - class Point; - class PointND; -} - - -std::ostream & operator<<(std::ostream& target, const RDGeom::Point &pt); - -RDGeom::Point3D operator+ (const RDGeom::Point3D& p1, const RDGeom::Point3D& p2); -RDGeom::Point3D operator- (const RDGeom::Point3D& p1, const RDGeom::Point3D& p2); -RDGeom::Point3D operator* (const RDGeom::Point3D& p1, const double v); -RDGeom::Point3D operator/ (const RDGeom::Point3D& p1, const double v); - -RDGeom::Point2D operator+ (const RDGeom::Point2D& p1, const RDGeom::Point2D& p2); -RDGeom::Point2D operator- (const RDGeom::Point2D& p1, const RDGeom::Point2D& p2); -RDGeom::Point2D operator* (const RDGeom::Point2D& p1, const double v); -RDGeom::Point2D operator/ (const RDGeom::Point2D& p1, const double v); - -RDGeom::PointND operator+ (const RDGeom::PointND& p1, const RDGeom::PointND& p2); -RDGeom::PointND operator- (const RDGeom::PointND& p1, const RDGeom::PointND& p2); -RDGeom::PointND operator* (const RDGeom::PointND& p1, const double v); -RDGeom::PointND operator/ (const RDGeom::PointND& p1, const double v); - namespace RDGeom { @@ -255,7 +230,7 @@ namespace RDGeom { } double l=res.length(); POSTCONDITION(l>0.0,"zero perpendicular"); - res = res/l; + res /= l; return res; } }; @@ -264,7 +239,8 @@ namespace RDGeom { // plane of the first three points (pt1, pt2, pt3) and the plane of the // last three points (pt2, pt3, pt4) // the computed angle is between 0 and PI - double computeDihedralAngle(Point3D pt1, Point3D pt2, Point3D pt3, Point3D pt4); + double computeDihedralAngle(const Point3D &pt1, const Point3D &pt2, + const Point3D &pt3, const Point3D &pt4); class Point2D : public Point { public: @@ -531,9 +507,22 @@ namespace RDGeom { typedef INT_POINT2D_MAP::iterator INT_POINT2D_MAP_I; typedef INT_POINT2D_MAP::const_iterator INT_POINT2D_MAP_CI; + std::ostream & operator<<(std::ostream& target, const RDGeom::Point &pt); + + RDGeom::Point3D operator+ (const RDGeom::Point3D& p1, const RDGeom::Point3D& p2); + RDGeom::Point3D operator- (const RDGeom::Point3D& p1, const RDGeom::Point3D& p2); + RDGeom::Point3D operator* (const RDGeom::Point3D& p1, double v); + RDGeom::Point3D operator/ (const RDGeom::Point3D& p1, double v); + + RDGeom::Point2D operator+ (const RDGeom::Point2D& p1, const RDGeom::Point2D& p2); + RDGeom::Point2D operator- (const RDGeom::Point2D& p1, const RDGeom::Point2D& p2); + RDGeom::Point2D operator* (const RDGeom::Point2D& p1, double v); + RDGeom::Point2D operator/ (const RDGeom::Point2D& p1, double v); + + RDGeom::PointND operator+ (const RDGeom::PointND& p1, const RDGeom::PointND& p2); + RDGeom::PointND operator- (const RDGeom::PointND& p1, const RDGeom::PointND& p2); + RDGeom::PointND operator* (const RDGeom::PointND& p1, double v); + RDGeom::PointND operator/ (const RDGeom::PointND& p1, double v); } - - - #endif