Skip to content

Commit

Permalink
Fixed parabola calculation if vornonoi edge starts close to its locat…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
mlampert committed Oct 25, 2020
1 parent d563849 commit d40c18b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Mod/Path/App/VoronoiEdgePyImp.cpp
Expand Up @@ -397,7 +397,8 @@ PyObject* VoronoiEdgePy::toShape(PyObject *args)
{
double z0 = 0.0;
double z1 = DBL_MAX;
if (!PyArg_ParseTuple(args, "|dd", &z0, &z1)) {
int dbg = 0;
if (!PyArg_ParseTuple(args, "|ddp", &z0, &z1, &dbg)) {
throw Py::RuntimeError("no, one or two arguments of type double accepted");
}
if (z1 == DBL_MAX) {
Expand Down Expand Up @@ -545,7 +546,7 @@ PyObject* VoronoiEdgePy::toShape(PyObject *args)
double flenX;
double flenY;
// if one of the points is the location, we have to use the other to get sensible values
if (fabs(dist0) > 0.001) {
if (fabs(dist0) > fabs(dist1)) {
flenX = flenX0;
flenY = distanceBetween(loc, pt0x, e->dia->getScale());
} else {
Expand All @@ -554,6 +555,12 @@ PyObject* VoronoiEdgePy::toShape(PyObject *args)
}
// parabola: (x - p)^2 = 4*focal*(y - q) | (p,q) ... location of parabola
focal = (flenX * flenX) / (4 * fabs(flenY));
if (dbg) {
std::cerr << "segement" << segment << ", point" << point << std::endl;
std::cerr << " loc" << loc << ", axis" << axis << std::endl;
std::cerr << " dist0(" << dist0 << " : " << flenX0 << ", dist1(" << dist1 << " : " << flenX1 << ")" << std::endl;
std::cerr << " z(" << z0 << ", " << zx << ", " << z1 << ")" << std::endl;
}
// use new X values to set the parameters
dist0 = dist0 >= 0 ? flenX0 : -flenX0;
dist1 = dist1 >= 0 ? flenX1 : -flenX1;
Expand Down

0 comments on commit d40c18b

Please sign in to comment.