Hello Dynamo users.
I’m stuck on my project on determining witch polygon corner is convex or concave. Tried already measuring vector angles, calculating point distances, but there is always an exception for that approach.
Did anyone faced similar problem. Example in screenshot. One good thing is, angle is always 90.
Thanks for answer.
Yes I tried like it. But the polygon outline is random. It can be more complicated and have “bays” then the result would be not true. I mean using middle point will not always work. Example:
Woulnd’t all corners where the line goes to the left always be concave (and vice versa)?
Assuming we are looking at a clockwise polycurve. Otherwise its just the other way around.
Left and right is a good idea, but no idea how to implement it, how to check if it left or right turn? . With vectors maybe it didin’t work because I’m not master of it. It was hard to determine witch angle is measured, exterior or interior angle, and it can be 90 and be convex or concave, or I get it wrong.
Hello,
if you project a circle at each corner and you get the length of the resulting curve on the surface of the polygon
then you compare to the lenght of 1/4 of the arc.
Since you’re working with planar geometry we can simplify things a bit and remove the computational difficult geometry calculations. Assuming you start with a polycurve:
Take the polycurve and explode it so you have a list of all curves
Shift that list by 1 unit (so the second curve in the list is now first, and the first curve in the list is now last) with a List.ShiftIndices node.
For the original curve list, get the tangent direction at the end
For the shifted list get the tangent direction at the start
Build a surface of the polycurve, and pull it’s normal
Use a Vector.AngleAboutAxis to get the angle from the original curves end tangent vectors (#3) and the shifted curves tangent start vectors about the normal.
Values over 180 are convex, less than 180 concave, and if 180 it’s colinear (and likely you want to combine the angles)