1555
Shape::CmpToVert (NR::Point ax, NR::Point bx,bool as,bool bs)
1555
Shape::CmpToVert (Geom::Point ax, Geom::Point bx,bool as,bool bs)
2054
2054
// other=depends on your fill rule
2055
2055
// if the polygon is uncrossed, it's all the same, usually
2057
Shape::PtWinding (const NR::Point px) const
2057
Shape::PtWinding (const Geom::Point px) const
2059
2059
int lr = 0, ll = 0, rr = 0;
2061
2061
for (int i = 0; i < numberOfEdges(); i++)
2063
NR::Point const adir = getEdge(i).dx;
2063
Geom::Point const adir = getEdge(i).dx;
2065
NR::Point const ast = getPoint(getEdge(i).st).x;
2066
NR::Point const aen = getPoint(getEdge(i).en).x;
2065
Geom::Point const ast = getPoint(getEdge(i).st).x;
2066
Geom::Point const aen = getPoint(getEdge(i).en).x;
2068
2068
//int const nWeight = eData[i].weight;
2069
2069
int const nWeight = 1;
2094
2094
if (aen[1] >= px[1]) continue;
2097
NR::Point const diff = px - ast;
2097
Geom::Point const diff = px - ast;
2098
2098
double const cote = cross(diff, adir);
2099
2099
if (cote == 0) continue;
2100
2100
if (cote < 0) {
2190
2190
* \return Minimum distance from p to any of the points or edges of s.
2193
double distance(Shape const *s, NR::Point const &p)
2193
double distance(Shape const *s, Geom::Point const &p)
2195
2195
if ( s->hasPoints() == false) {
2201
2201
** us the distance squared; we can leave the square root
2202
2202
** until the end.
2204
double bdot = NR::dot(p - s->getPoint(0).x, p - s->getPoint(0).x);
2204
double bdot = Geom::dot(p - s->getPoint(0).x, p - s->getPoint(0).x);
2206
2206
for (int i = 0; i < s->numberOfPoints(); i++) {
2207
NR::Point const offset( p - s->getPoint(i).x );
2208
double ndot = NR::dot(offset, offset);
2207
Geom::Point const offset( p - s->getPoint(i).x );
2208
double ndot = Geom::dot(offset, offset);
2209
2209
if ( ndot < bdot ) {
2214
2214
for (int i = 0; i < s->numberOfEdges(); i++) {
2215
2215
if ( s->getEdge(i).st >= 0 && s->getEdge(i).en >= 0 ) {
2216
2216
/* The edge has start and end points */
2217
NR::Point const st(s->getPoint(s->getEdge(i).st).x); // edge start
2218
NR::Point const en(s->getPoint(s->getEdge(i).en).x); // edge end
2217
Geom::Point const st(s->getPoint(s->getEdge(i).st).x); // edge start
2218
Geom::Point const en(s->getPoint(s->getEdge(i).en).x); // edge end
2220
NR::Point const d(p - st); // vector between p and edge start
2221
NR::Point const e(en - st); // vector of the edge
2222
double const el = NR::dot(e, e); // edge length
2220
Geom::Point const d(p - st); // vector between p and edge start
2221
Geom::Point const e(en - st); // vector of the edge
2222
double const el = Geom::dot(e, e); // edge length
2224
2224
/* Update bdot if appropriate */
2225
2225
if ( el > 0.001 ) {
2226
double const npr = NR::dot(d, e);
2226
double const npr = Geom::dot(d, e);
2227
2227
if ( npr > 0 && npr < el ) {
2228
2228
double const nl = fabs( NR::cross(d, e) );
2229
2229
double ndot = nl * nl / el;
2252
2252
* \param max_l2 L2 distance.
2255
bool distanceLessThanOrEqual(Shape const *s, NR::Point const &p, double const max_l2)
2255
bool distanceLessThanOrEqual(Shape const *s, Geom::Point const &p, double const max_l2)
2257
2257
if ( s->hasPoints() == false ) {
2271
2271
double const max_l1 = max_l2 * M_SQRT2;
2272
2272
for (int i = 0; i < s->numberOfPoints(); i++) {
2273
NR::Point const offset( p - s->getPoint(i).x );
2273
Geom::Point const offset( p - s->getPoint(i).x );
2274
2274
double const l1 = NR::L1(offset);
2275
if ( (l1 <= max_l2) || ((l1 <= max_l1) && (NR::L2(offset) <= max_l2)) ) {
2275
if ( (l1 <= max_l2) || ((l1 <= max_l1) && (Geom::L2(offset) <= max_l2)) ) {
2280
2280
for (int i = 0; i < s->numberOfEdges(); i++) {
2281
2281
if ( s->getEdge(i).st >= 0 && s->getEdge(i).en >= 0 ) {
2282
NR::Point const st(s->getPoint(s->getEdge(i).st).x);
2283
NR::Point const en(s->getPoint(s->getEdge(i).en).x);
2284
NR::Point const d(p - st);
2285
NR::Point const e(en - st);
2286
double const el = NR::L2(e);
2282
Geom::Point const st(s->getPoint(s->getEdge(i).st).x);
2283
Geom::Point const en(s->getPoint(s->getEdge(i).en).x);
2284
Geom::Point const d(p - st);
2285
Geom::Point const e(en - st);
2286
double const el = Geom::L2(e);
2287
2287
if ( el > 0.001 ) {
2288
NR::Point const e_unit(e / el);
2289
double const npr = NR::dot(d, e_unit);
2288
Geom::Point const e_unit(e / el);
2289
double const npr = Geom::dot(d, e_unit);
2290
2290
if ( npr > 0 && npr < el ) {
2291
2291
double const nl = fabs(NR::cross(d, e_unit));
2292
2292
if ( nl <= max_l2 ) {