Quantcast
Viewing all articles
Browse latest Browse all 40524

'strange' normal at first/last point of polyline

I'm trying to create a circle using polylines and add some effects to vertexes of the polylines later on. When I add normals to the polyline the first and last one don't act as expected (or intended) as the normals are not parallel to the x axis: http://imgur.com/ZEOolqd

Code of the circle:

ofVec2f radius( 200, 0);
ofVec2f center = ofGetWindowSize() / 2;

float steps = 36.0;
float angle = 360.0 / steps;
ofVec2f point = center + radius;
currentPolyline.curveTo(point);
currentPolyline.curveTo(point);

for(int i = 0; i < steps; i++)
{
    radius.rotate(angle);
    point = center + radius;
    
    currentPolyline.curveTo(point);
}
currentPolyline.curveTo(point);


currentPolyline.simplify(0.7);
polylines.push_back(currentPolyline);
currentPolyline.clear();

and then just a

ofPolyline polyline = polylines[i];
polyline.draw();

to draw the circle.

What am I doing wrong? Image may be NSFW.
Clik here to view.
:confused:

Thanks in advance!


Viewing all articles
Browse latest Browse all 40524

Trending Articles