Week 5 Assignment

 

Problem1

vvoid drawStroke(void){

glLineWidth(1);
glBegin(GL_LINE_STRIP);

float strokeWidth=20;

for( int i=0; i<numPoint-1; i++){

Vec2d currentPoint= pointList[i];

Vec2d A= pointList[i-1];
Vec2d B = pointList[i+1];

Vec2d difference = pointList[i]-pointList[i-1];
float diff= difference.getLength();
if (diff>5){



Vec2d V= B-A;
V.normalize();

Vec2d Vp;
Vp.x = V.y * -1.0;
Vp.y= V.x;




Vec2d C= currentPoint + Vp*strokeWidth - V*strokeWidth;
Vec2d D= currentPoint - Vp*strokeWidth - V*strokeWidth ;

glVertex2f(C.x, C.y);

glVertex2f(currentPoint.x, currentPoint.y);

glVertex2f(D.x, D.y);
glVertex2f(currentPoint.x, currentPoint.y);
}

}

glEnd();

}