| 26 | } |
| 27 | |
| 28 | void EdgeSegment::distanceToPerpendicularDistance(SignedDistance &distance, Point2 origin, double param) const { |
| 29 | if (param < 0) { |
| 30 | Vector2 dir = direction(0).normalize(); |
| 31 | Vector2 aq = origin-point(0); |
| 32 | double ts = dotProduct(aq, dir); |
| 33 | if (ts < 0) { |
| 34 | double perpendicularDistance = crossProduct(aq, dir); |
| 35 | if (fabs(perpendicularDistance) <= fabs(distance.distance)) { |
| 36 | distance.distance = perpendicularDistance; |
| 37 | distance.dot = 0; |
| 38 | } |
| 39 | } |
| 40 | } else if (param > 1) { |
| 41 | Vector2 dir = direction(1).normalize(); |
| 42 | Vector2 bq = origin-point(1); |
| 43 | double ts = dotProduct(bq, dir); |
| 44 | if (ts > 0) { |
| 45 | double perpendicularDistance = crossProduct(bq, dir); |
| 46 | if (fabs(perpendicularDistance) <= fabs(distance.distance)) { |
| 47 | distance.distance = perpendicularDistance; |
| 48 | distance.dot = 0; |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | LinearSegment::LinearSegment(Point2 p0, Point2 p1, EdgeColor edgeColor) : EdgeSegment(edgeColor) { |
| 55 | p[0] = p0; |
no test coverage detected