Week 5 Assignment

 

Problem6

void drawStrokeRotated(void){

float A=180;
Vec2d center(windowW/2, windowH/2);

float Amp=1.5;
float Freq=60;
glColor3f(1, 0,0);
glLineWidth(2);

glBegin(GL_LINE_STRIP);

for( int i=0; i<numPoint-1; i++){
glColor4f(i*0.001, 0.5,1,0.5);
Vec2d currentPoint= pointList[i];
Vec2d A= pointList[i-1];
Vec2d B = pointList[i+1];


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

Vec2d Vp;
Vp.x = V.y * -1.0;
Vp.y= V.x;
Amp= ((i/2)%8)*2+ 2;

Vec2d C= currentPoint + Vp*(Amp*sin_deg(i*Freq));
rotatedList[i]=C;

glVertex2f(C.x, C.y);
}

glEnd();



Vec2d Xp, Yp;
Xp.x= cos_deg(A);
Xp.y= sin_deg(A);

Yp.x= -1*sin_deg(A);
Yp.y= cos_deg(A);


glColor4f(0, 0,0, 1);

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

Vec2d currentPoint= rotatedList[i];
currentPoint= currentPoint- center;
glColor4f(0.5, i*0.001,1,0.5);

Vec2d rotatedPoint= Xp*currentPoint.x + Yp*currentPoint.y;
rotatedPoint= rotatedPoint+ center;
glVertex2f(rotatedPoint.x, rotatedPoint.y);

}

glEnd();


}