I have the following problem. I start with a perimeter describing as a set of ordered points that define an object. I want to create an “inner” perimeter, by translating each point of inward of a specific distance (see Example Figure: Red: outer perimeter, Green: inner perimeter; Blue: normal vector of outer perimeter’s points). Briefly, in order to do that I take any two adjacent points of the outer perimeter (A and B) and find the normal vector to this segment. The normal vector is then used to translate a point of a specific distance in the direction pointed by the normal vector.
The problem is that there are two possible directions and I have a hard time to ensure to univocally point in the “inward” direction. What I do is to calculate the angle between the normal vector and the x-axis. However, the solution I got (see Code attached) gives me angles between 0 and 180 degree. It works, although it is not an elegant solution. However, the big problem is that if first normal vector found points outward, all remaining points are translated outward.
Perhaps, if I could get angle values from 0 to 360, I could solve the problem and understand the orientation of my segment (A-to-B versus B-to-A; see attached Concept Figure).
Best and thank you in advance,