libnr builds, nothing else does (due to excessing C armoring)
njh
Index: src/libnr/nr-values.cpp =================================================================== RCS file: /cvsroot/inkscape/inkscape/src/libnr/nr-values.cpp,v retrieving revision 1.1 diff -d -u -r1.1 nr-values.cpp --- src/libnr/nr-values.cpp 15 Dec 2003 04:29:30 -0000 1.1 +++ src/libnr/nr-values.cpp 22 Dec 2003 02:44:18 -0000 @@ -10,5 +10,10 @@ */
#include "nr-values.h" +#include <math.h>
int vla; + +double NR::Point::L2() { + return hypot(pt[0], pt[1]); +} Index: src/libnr/nr-types.h =================================================================== RCS file: /cvsroot/inkscape/inkscape/src/libnr/nr-types.h,v retrieving revision 1.4 diff -d -u -r1.4 nr-types.h --- src/libnr/nr-types.h 18 Dec 2003 04:25:30 -0000 1.4 +++ src/libnr/nr-types.h 22 Dec 2003 02:44:18 -0000 @@ -20,6 +20,109 @@ double x, y; } NRPoint;
+namespace NR { + +enum dimT { X, Y }; + +class Point{ + public: + double pt[2]; + + Point() { + } + + Point(double x, double y) { + pt[X] = x; + pt[Y] = y; + } + + /** Return a point like this point but rotated -90 degrees. + (If the y axis grows downwards and the x axis grows to the + right, then this is 90 degrees counter-clockwise.) + **/ + Point ccw() const { + return Point(pt[Y], -pt[X]); + } + + /** Return a point like this point but rotated +90 degrees. + (If the y axis grows downwards and the x axis grows to the + right, then this is 90 degrees clockwise.) + **/ + Point cw() { + return Point(-pt[Y], pt[X]); + } + + double L2(); +/** Compute the L2 or euclidean norm of this vector */ + void Normalize(); + + operator NRPoint() { + NRPoint nrp; + nrp.x = pt[0]; + nrp.y = pt[1]; + return nrp; + } +}; + +inline Point +operator+(Point const &a, Point const &b) { + Point r; + for(int i = 0; i < 2; i++) { + r.pt[i] = a.pt[i] + b.pt[i]; + } + return r; +} + +inline Point +operator-(Point const &a, Point const &b) { + Point r; + for(int i = 0; i < 2; i++) { + r.pt[i] = a.pt[i] - b.pt[i]; + } + return r; +} + +inline Point +operator*(Point const &a, Point const &b) { + Point r; + for(int i = 0; i < 2; i++) + r.pt[i] = a.pt[i]*b.pt[i]; + return r; +} + +inline Point +operator*(double s, Point const &b) { + Point ret; + for(int i = 0; i < 2; i++) { + ret.pt[i] = s * b.pt[i]; + } + return ret; +} + +inline double +dot(Point const &a, Point const &b) { + double ret = 0; + for(int i = 0; i < 2; i++) { + ret += a.pt[i] * b.pt[i]; + } + return ret; +} + +inline double +cross(Point const &a, Point const &b) { + double ret = 0; + for(int i = 0; i < 2; i++) + ret = a.pt[i] * b.pt[1-i] - ret; + return ret; +} + +inline void Point::Normalize() { + double d = L2(); + if(d > 0.0001) // Why this number? + *this = (1/d)**this; +} +} + typedef struct _NRPointL { NRLong x, y; } NRPointL;
participants (1)
-
Nathan Hurst