1) ciculation of a triangle:
- TechDraw12.png (9.87 KiB) Viewed 1731 times
- In the left triangle, if you run arround A-B-C the "circulation" is math. positive (counter clockwise)
- In the right triangle, if you run arround A-B-C the "circulation" is math. negative (clockwise)
I do not know (and could not find in dictionaries) the correct english word. Maybe a native speaker can tell me. In german I would say: Umlaufsinn.
2) How it works: (I hope I can explain it)
- TechDraw10.png (25.56 KiB) Viewed 1731 times
Left picture:
There are two lines (a and e) having both the direction from left to right (startponts l1p1 and l2p1, endpoints l1p2 and l2p2).
Using the lines b,c and d two triangles are created. The first one (a-b-c or l1p1-l1p2-l2p1) has positve "circulation". Also the second one (d-e-b or l1p2-l2p2-l2p1) has positve "circulation".
If you mirror the whole figure, both triangles become negative "circulation". Because both triangles always have the same "circulation" no swap has is necessary.
Right picture:
There are two lines (a and e) having different directions. Line 1 (bottom) from left to right, line2 (top) from right to left. We connect the same points (two have another position) creating the lines b,c and d. The first triangle (a-b-c or l1p1-l1p2-l2p1) has positve "circulation". The second triangle (d-e-b or l1p2-l2p2-l2p1) has negative "circulation". If you mirror the whole figure, both triangles change the sense of their circulation. Because the two triangles always have different "circulation" a swap is necessary.
3) Triangle area:
There are many ways to calculate the area of a triangle. The one I used is:
- TechDraw13.png (18.07 KiB) Viewed 1731 times
where 1,2,3 are the vertexes. If the "ciculation" of the triangle is math. negative, the formula returns a negative result.
(For mathematicians: changing the "circulation" means swaping two vertexes. In the matrix two lines are swaped, which switches the sign of the determinat)
In my last post I calculated the determinants manually, which leads to very short results, because the third column of the matrix is always 1.
In my Python example I used a 4x4 matrix because FreeCAD supports only 4x4 matrixes. There is only needed a 3x3 matrix. So if you update TechDraw in github (in future), you either can reduce the matrix to a 3x3 by deleting the 4th column and the 4th line, or use the the calculated determinats from the last post.
To your example:
uwestoehr wrote: ↑Fri May 21, 2021 11:32 pm
Another question. Take this example:
l1p1.x = 1, .y = 3
l1p2.x = 1, .y = 1
l2p1.x = 0.5, .y = 3
l2p2.x = 3, .y = 3.5
Where would you (as human being, not in a computer program) create the centerline ?
Seriously the algorithm works only in reasonable situations, e.g. if both lines are (nearly) parallel and have similar length. If the two lines form a X or a T (as in the example) the algorithm will produce nonsense. But the lines are selected by a (sensible) user.
If there are open questions, please ask.