Skip to content

Commit

Permalink
Issue #573 Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
QuimMoya committed Oct 30, 2024
1 parent 4b9c40a commit 196217c
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/cpp/geometry/operations/curve-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,34 @@ inline IfcCurve Build3DArc3Pt(const glm::dvec3 &p1, const glm::dvec3 &p2, const
double v = 2 * (p1.x - p2.x) * (p1.y - p3.y) - 2 * (p1.x - p3.x) * (p1.y - p2.y);

double cenX = ((p1.y - p3.y) * f1 - (p1.y - p2.y) * f2) / v;
double cenYa = (f2 - 2 * cenX * (p1.x - p3.x)) / (2 * (p1.y - p3.y));
double cenYb = (f1 - 2 * cenX * (p1.x - p2.x)) / (2 * (p1.y - p2.y));
double den1 = (2 * (p1.y - p3.y));
double den2 = (2 * (p1.y - p2.y));
double cenYa = (f2 - 2 * cenX * (p1.x - p3.x)) / den1;
double cenYb = (f1 - 2 * cenX * (p1.x - p2.x)) / den2;
double cenY = cenYa;
if (std::isnan(cenY) || std::isinf(cenY))
if(glm::abs(den1) > glm::abs(den2))
{
cenY = cenYa;
}
else
{
cenY = cenYb;
}
if (std::isnan(cenY) || std::isinf(cenY))
{
if (!std::isnan(cenYa) && !std::isinf(cenYa))
{
cenY = cenYa;
}
else if (!std::isnan(cenYb) && !std::isinf(cenYb))
{
cenY = cenYb;
}
else
{
spdlog::error("3 Point Arc - Error: wrong points");
}
}

glm::dvec2 pCen;
pCen.x = cenX;
Expand Down

0 comments on commit 196217c

Please sign in to comment.