-bool RS_Circle::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);
-
- if (sol.get(0).valid && data.radius<1.0e14 && data.radius>RS_TOLERANCE) {
- return true;
- } else {
- RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFrom3P(): "
- "Cannot create a circle with inf radius.");
- return false;
- }
- } else {
- RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFrom3P(): "
- "Cannot create a circle with radius 0.0.");
- return false;
- }
-}
-
-
-
-VectorSolutions RS_Circle::getRefPoints() {
- Vector v1(data.radius, 0.0);
- Vector v2(0.0, data.radius);
-
- VectorSolutions ret(data.center,
- data.center+v1, data.center+v2,
- data.center-v1, data.center-v2);
- return ret;
+bool RS_Circle::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);
+
+ if (sol.get(0).valid && data.radius < 1.0e14 && data.radius > RS_TOLERANCE)
+ return true;
+ else
+ {
+ RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFrom3P(): "
+ "Cannot create a circle with inf radius.");
+ return false;
+ }
+ }
+ else
+ {
+ RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Circle::createFrom3P(): "
+ "Cannot create a circle with radius 0.0.");
+ return false;
+ }