CS计算机代考程序代写 Answers to Quiz 2 Qn 1

Answers to Quiz 2 Qn 1
a)
1(1−cos𝛼) 0≤𝛼≤𝜋 2
b)
Paper 1
void animate ( void )
{
}
Paper 2
void animate ( void )
{
}
Qn 2
a)
Paper 1
void ground_plane (void)
{
double t;
t = glutGet (GLUT_ELAPSED_TIME);
alpha = 20.0 + 50.0 * (1 – cos ( PI * t/(3000.0);
glutPostRedisplay ( );
double t;
t = glutGet (GLUT_ELAPSED_TIME);
alpha = 40.0 + 60.0 * (1 – cos ( PI * t/(3000.0);
glutPostRedisplay ( );
1

glColor3f (0, 1, 0); glVertex3f (-100, -100, 2); glVertex3f ( 100, -100, 2); glVertex3f ( 100, 100, 2); glVertex3f (-100, 100, 2);
}
Paper 2
void ground_plane (void)
{
}
b)
void cube (void)
{
} c)
After changing to the light coordinate system, a perspective projection on the plane 𝑍 = −28 is performed. The matrix is
glColor3f (0, 1, 0); glVertex3f (-150, -150, 2); glVertex3f ( 150, -150, 2); glVertex3f ( 150, 150, 2); glVertex3f (-150, 150, 2);
glPushMatrix ( );
glColor3f (0, 0, 1); glTranslate (0, 0, 7); glutSolidCube (10);
glPopMatrix ( );
GLfloat Xs = 10; GLfloat Ys = 20; GLfloat Zs = 30;
1000 (01 0 0) 0010 0 0 1.0/−28.0 0
2

GLfloat light1PosType [ ] = {Xs, Ys, Zs, 1.0}; :
GLfloat M[16];
for (i=0; i<16; i++) M[i]=0; M[0]=M[5]=M[10]=1; M[11]=-1.0/28.0; ground_plane ( ); cube ( ); glPushMatrix ( ); glTranslatef (Xs, Yz, Zs); glMultMatrixf (M); glTranslatef (-Xs, -Ys, -Zs); glColor3fv (shadowcolour); cube ( ); glPopMatrix ( ); Qn 3 a) 𝑀= 𝑉𝑉 1 0 − 𝑝𝑥 𝑧 𝑝𝑥 𝑉 𝑣𝑝𝑉 𝑝𝑧 𝑝𝑧 𝑉𝑉 0 1 − 𝑝𝑦 𝑧 𝑝𝑦 𝑉 𝑣𝑝𝑉 𝑝𝑧 𝑝𝑧 0 0 0 𝑧𝑣𝑝 (000 1) (𝑉 ,𝑉 .𝑉 )=(−1,1,2√2) 𝑝𝑥 𝑝𝑦 𝑝𝑧 𝑧 =2 𝑣𝑝 101−1 2√2 √2 01−1 1 2√2 √2 0002 (00 0 1) 𝑀= b) 𝑉 𝑡𝑎𝑛−1 𝑝𝑧 √𝑉 2+𝑉 2 𝑝𝑥 𝑝𝑦 = 2 𝐶𝑎𝑏𝑖𝑛𝑒𝑡 𝑝𝑟𝑜𝑗𝑒𝑐𝑡𝑖𝑜𝑛 3 c) 1. the shadow has sharp boundaries 2. the shadow has a constant colour. There is no difference in shading when shadows overlap 3. the shading of the shadow is not varying (there is no soft shadow) 4. it can only generate shadow correctly if the shape the shadow casts is planar or any other reasonable answers Qn 4 a) The camera is pointing at (0, 0, 0) 𝑁 = (0,0,1) 𝑉=|(100,100,100)|=(1 , 1 , 1 ) √3 √3 √3 𝑁∙𝑉=1 √3 b) 𝐼 = 𝑘𝑎𝐼𝑎 + 𝑘𝑑(𝑁 ∙ 𝐿)𝐼𝑙 + 𝑘𝑠(𝑉 ∙ 𝑅)𝑛𝑠𝐼𝑙 = (0.1)(0.2) + (0.8)(𝑁 ∙ 𝐿)(0.8) + (0.1)(𝑉 ∙ 𝑅)2(0.8) 𝐿 = (0, − 1 , 1 ) √2 √2 𝑅=2(𝑁∙𝐿)𝑁−𝐿=(0,0,√2)−(0,− 1 , 1)=(0, 1 , 1) √2 √2 √2 √2 122 𝐼=(0.1)(0.2)+(0.8)(√2)(0.8)+(0.1)(√6) (0.8)=0.525881673 4