I have an Array of Points (CGPoints) which form a curve, actually not a real curve but short line-segments. I need a parallel offset of that curve. Just moving the curve down obviously results in thinner segments if the slope is steep. Any ideas on how i could approach this?
Asked
Active
Viewed 1,614 times
1 Answers
1
You will need to compute the tangent/normal per segment and then translate the points along the normal.
For a polyline - the normal at a vertex is some combination ((n1 + n2) / 2?) of the two segment normals it straddles, so you may need to take that into account during your "offset" curve computation.
Actually - all you need is the Normal - as indicated here.
Hope this helps.
-
Ok, i get the idea, but the first thought which comes to my mind is that i would need additional edge-points and i have no idea how to calculate them. Let`s say i have a V - if i calculate the tangent and add points moved in that direction i will get a horizontal line at the bottom of the V. Pretty difficult for me to explain. – Alex Sep 05 '12 at 17:11
-
Why would you need additional points? Please explain with a diagram if possible. – Ani Sep 05 '12 at 17:14
-
That's what I meant above by saying that "the normal at a vertex is a combination of the normals of a adjacent segments". In the case of the green points - averaging both segment normal should move the center point to the green destination point correctly. – Ani Sep 05 '12 at 17:30