Drawing normals independent of polyline size


I am drawing a number of polylines on screen, and then drawing normal lines centered on the vertices of said polylines. Expectedly, the number of normal lines being drawn is dependent on the length of the line. How may I go about making this happen independently, so each polyline is drawn with the same number of normal lines? The ofBook suggests the use of getPerimeter(), though I can’t quite figure out how to implement it.

Any help is greatly appreciated!

I’d look at ofPolyline::getResampledByCount()— which can resample the polyline to a fixed number of points. Happy to post an example if it helps

Thank you for the quick reply Zach!

I realized I completely miswrote - I’m not looking for the number of normals to be the same across lines, I’m looking for the density of the normal lines drawn to be the same (so that each normal line is physically distanced the same amount form each other, regardless of the parent polyline’s size). I’m specifically following the polyline brush example provided here. The example shows how to evenly space the same number of normals relative to line size, whereas I’m looking to draw each normal some absolute distance apart.

See below screenshot:

I want to add more normals to the right line so that the spacing between each can be the same as the left.

I really appreciate the help!

ah ok – then instead of this

take a look at


you can set the distance between points – note that these functions return a new polyline, so you’d typically write code like

ofPolyline temp = drawing.getResampledBySpacing(10);