computational form 23,
information 13,
play 13,
everybityoumake 12,
atoz 10,
processingtext 10,
mapping 9,
mobility 9,
nime 9,
fabricatinginformation 8,
interactivesound 7,
locative 7,
thesis 7,
ubicomp 5,
blah 4,
isco 3,
pcomp 3,
design thinking 2,
assistive technologies 1,
visualization 1
Comform Assignment 2 - Problem 6 · posted by vaibhav bhawsar Sep 21, 2007
Problem 6. Create a function called drawClock that takes as arguments an hour (float), a minute (float) and a number of seconds (float), and draws an analog clock. Feel free to add a pendulum or any other fancy clock accoutrements.
void drawClock( float hours, float min, float sec)
{
float HOURANGLE = 30;//for every hour the hand moves 360/12//
float MINANGLE = 6; //for every minute the hand moves 360/60//
float SECANGLE = 6; //for every second the hand moves 360/60//
float hour = hours;
float minutes = min;
float seconds = sec;
float hourA = ((12-hour)*HOURANGLE)+90; //add 90 to correct rotation
float minutesA = ((60-minutes)*MINANGLE)+90;
float secondsA = ((60-seconds)*SECANGLE)+90;
Vec2d center(windowW/2,windowW/2);
float clockRadius = 100;
drawCircle(center,clockRadius,30);
// //
glColor3f(1,0,0);
glLineWidth(3);
glPushMatrix();
glTranslatef(center.x,center.y,0);
glRotatef(hourA,0,0,1);
glBegin(GL_LINE_LOOP);
glVertex2f(0,0);
glVertex2f(30,0);
glEnd();
glPopMatrix();
// //
glColor3f(1,1,0);
glLineWidth(2);
glPushMatrix();
glTranslatef(center.x,center.y,0);
glRotatef(minutesA,0,0,1);
glBegin(GL_LINE_LOOP);
glVertex2f(0,0);
glVertex2f(50,0);
glEnd();
glPopMatrix();
// //
glColor3f(1,0,1);
glLineWidth(1);
glPushMatrix();
glTranslatef(center.x,center.y,0);
glRotatef(secondsA,0,0,1);
glBegin(GL_LINE_LOOP);
glVertex2f(0,0);
glVertex2f(70,0);
glEnd();
glPopMatrix();
}
Commenting is closed for this article.
Previous: CompForm Assignment 2 - Problem 5 Next: NIME - Performance note




