From e9a94d1e786da39c45ffd31e2cf958207c3c7aca Mon Sep 17 00:00:00 2001 From: donovaly Date: Fri, 4 Jun 2021 00:55:50 +0200 Subject: [PATCH] [TD] comment the new centerline behavior add missing info to understand the new centerline behavior as introduced with commit d1476c64 --- src/Mod/TechDraw/App/Cosmetic.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Mod/TechDraw/App/Cosmetic.cpp b/src/Mod/TechDraw/App/Cosmetic.cpp index c803dab88d..10fc61f8ff 100644 --- a/src/Mod/TechDraw/App/Cosmetic.cpp +++ b/src/Mod/TechDraw/App/Cosmetic.cpp @@ -980,12 +980,16 @@ std::pair CenterLine::calcEndPoints(DrawViewPart bool CenterLine::Circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C) { + // the determinant of this matrix calculates the aread of a triangle, see + // https://en.wikipedia.org/wiki/Triangle#Using_coordinates + // a 3x3 matrix would also do the job, but FC supports only 4x4 matrixes Base::Matrix4D CircMatrix( A.x, A.y, 1, 0, B.x, B.y, 1, 0, C.x, C.y, 1, 0, 0, 0, 0, 1); + // the sign delivers the dicrection of travel along the triangle edges if (CircMatrix.determinant() > 0) return true; else @@ -1034,8 +1038,10 @@ std::pair CenterLine::calcEndPoints2Lines(DrawVi Base::Vector3d l2p2 = edges.back()->getEndPoint(); // The centerline is drawn using the midpoints of the two lines that connect l1p1-l2p1 and l1p2-l2p2. - // However, we don't know which point should be l1p1 to get a geometrically correct result. - // Thus we test this by a circulation test. + // However, we don't know which point should be l1p1 to get a geometrically correct result, see + // https://wiki.freecadweb.org/File:TD-CenterLineFlip.png for an illustration of the problem. + // Thus we test this by a circulation test, see this post for a brief explanation: + // https://forum.freecadweb.org/viewtopic.php?p=505733#p505615 if (Circulation(l1p1, l1p2, l2p1) != Circulation(l1p2, l2p2, l2p1)) { Base::Vector3d temp; // reverse line 1 temp = l1p1;