-bool RS_Arc::createFrom3P(const Vector& p1, const Vector& p2,
- const Vector& p3) {
- if (p1.distanceTo(p2)>RS_TOLERANCE &&
- p2.distanceTo(p3)>RS_TOLERANCE &&
- p3.distanceTo(p1)>RS_TOLERANCE) {
-
- // middle points between 3 points:
- Vector mp1, mp2;
- Vector dir1, dir2;
- double a1, a2;
-
- // intersection of two middle lines
- mp1 = (p1 + p2)/2.0;
- a1 = p1.angleTo(p2) + M_PI/2.0;
- dir1.setPolar(100.0, a1);
- mp2 = (p2 + p3)/2.0;
- a2 = p2.angleTo(p3) + M_PI/2.0;
- dir2.setPolar(100.0, a2);
-
- RS_ConstructionLineData d1(mp1, mp1 + dir1);
- RS_ConstructionLineData d2(mp2, mp2 + dir2);
- RS_ConstructionLine midLine1(NULL, d1);
- RS_ConstructionLine midLine2(NULL, d2);
-
- VectorSolutions sol =
- RS_Information::getIntersection(&midLine1, &midLine2);
-
- data.center = sol.get(0);
- data.radius = data.center.distanceTo(p3);
- data.angle1 = data.center.angleTo(p1);
- data.angle2 = data.center.angleTo(p3);
- data.reversed = RS_Math::isAngleBetween(data.center.angleTo(p2),
- data.angle1, data.angle2, true);
-
- if (sol.get(0).valid && data.radius<1.0e14 &&
- data.radius>RS_TOLERANCE) {
- calculateEndpoints();
- calculateBorders();
- return true;
- } else {
- RS_DEBUG->print("RS_Arc::createFrom3P(): "
- "Cannot create an arc with inf radius.");
- return false;
- }
- } else {
- RS_DEBUG->print("RS_Arc::createFrom3P(): "
- "Cannot create an arc with radius 0.0.");
- return false;
- }
+bool RS_Arc::createFrom3P(const Vector & p1, const Vector & p2, const Vector & p3)
+{
+ if (p1.distanceTo(p2) > RS_TOLERANCE
+ && p2.distanceTo(p3) > RS_TOLERANCE
+ && p3.distanceTo(p1) > RS_TOLERANCE)
+ {
+ // middle points between 3 points:
+ Vector mp1, mp2;
+ Vector dir1, dir2;
+ double a1, a2;
+
+ // intersection of two middle lines
+ mp1 = (p1 + p2) / 2.0;
+ a1 = p1.angleTo(p2) + M_PI / 2.0;
+ dir1.setPolar(100.0, a1);
+ mp2 = (p2 + p3) / 2.0;
+ a2 = p2.angleTo(p3) + M_PI / 2.0;
+ dir2.setPolar(100.0, a2);
+
+ RS_ConstructionLineData d1(mp1, mp1 + dir1);
+ RS_ConstructionLineData d2(mp2, mp2 + dir2);
+ RS_ConstructionLine midLine1(NULL, d1);
+ RS_ConstructionLine midLine2(NULL, d2);
+
+ VectorSolutions sol =
+ RS_Information::getIntersection(&midLine1, &midLine2);
+
+ data.center = sol.get(0);
+ data.radius = data.center.distanceTo(p3);
+ data.angle1 = data.center.angleTo(p1);
+ data.angle2 = data.center.angleTo(p3);
+ data.reversed = RS_Math::isAngleBetween(data.center.angleTo(p2),
+ data.angle1, data.angle2, true);
+
+ if (sol.get(0).valid && data.radius < 1.0e14
+ && data.radius > RS_TOLERANCE)
+ {
+ calculateEndpoints();
+ calculateBorders();
+ return true;
+ }
+ else
+ {
+ RS_DEBUG->print("RS_Arc::createFrom3P(): "
+ "Cannot create an arc with inf radius.");
+ return false;
+ }
+ }
+ else
+ {
+ RS_DEBUG->print("RS_Arc::createFrom3P(): "
+ "Cannot create an arc with radius 0.0.");
+ return false;
+ }