diff --git a/src/Mod/Part/App/Geom2d/Circle2dPy.xml b/src/Mod/Part/App/Geom2d/Circle2dPy.xml
index 1ed23ef0e7..eef278fcdc 100644
--- a/src/Mod/Part/App/Geom2d/Circle2dPy.xml
+++ b/src/Mod/Part/App/Geom2d/Circle2dPy.xml
@@ -31,6 +31,11 @@ Part.Geom2d.Circle2d(Point1,Point2,Point3)
Creates a circle defined by three non-linear points
+
+
+ Get the circle center defined by three points
+
+
The radius of the circle.
diff --git a/src/Mod/Part/App/Geom2d/Circle2dPyImp.cpp b/src/Mod/Part/App/Geom2d/Circle2dPyImp.cpp
index 2e655695eb..7cfe844075 100644
--- a/src/Mod/Part/App/Geom2d/Circle2dPyImp.cpp
+++ b/src/Mod/Part/App/Geom2d/Circle2dPyImp.cpp
@@ -143,6 +143,24 @@ int Circle2dPy::PyInit(PyObject* args, PyObject* kwds)
return -1;
}
+PyObject* Circle2dPy::getCircleCenter(PyObject *args)
+{
+ PyObject* p1;
+ PyObject* p2;
+ PyObject* p3;
+ if (!PyArg_ParseTuple(args, "O!O!O!", Base::Vector2dPy::type_object(), &p1
+ , Base::Vector2dPy::type_object(), &p2
+ , Base::Vector2dPy::type_object(), &p3))
+ return nullptr;
+
+ Base::Vector2d v1 = Py::toVector2d(p1);
+ Base::Vector2d v2 = Py::toVector2d(p2);
+ Base::Vector2d v3 = Py::toVector2d(p3);
+
+ Base::Vector2d cnt = Geom2dCircle::getCircleCenter(v1, v2, v3);
+ return Py::new_reference_to(Base::Vector2dPy::create(cnt));
+}
+
Py::Float Circle2dPy::getRadius(void) const
{
Handle(Geom2d_Circle) circle = Handle(Geom2d_Circle)::DownCast(getGeom2dCirclePtr()->handle());
diff --git a/src/Mod/Part/App/Geometry2d.cpp b/src/Mod/Part/App/Geometry2d.cpp
index 3b482709bc..c2238baba1 100644
--- a/src/Mod/Part/App/Geometry2d.cpp
+++ b/src/Mod/Part/App/Geometry2d.cpp
@@ -932,7 +932,8 @@ Base::Vector2d Geom2dCircle::getCircleCenter (const Base::Vector2d &p1, const Ba
double vv = v*v;
double ww = w*w;
- if (abs(uu * vv * ww) < Precision::Confusion())
+ double eps2 = Precision::SquareConfusion();
+ if (uu < eps2 || vv < eps2 || ww < eps2)
THROWM(Base::ValueError,"Two points are coincident");
double uv = -(u*v);
@@ -945,7 +946,7 @@ Base::Vector2d Geom2dCircle::getCircleCenter (const Base::Vector2d &p1, const Ba
double wx = w0 + w1 + w2;
- if( abs(wx) < Precision::Confusion())
+ if (abs(wx) < Precision::Confusion())
THROWM(Base::ValueError,"Points are collinear");
double x = (w0*p1.x + w1*p2.x + w2*p3.x)/wx;