Skip to content
PostComputer Graphics / Assignment

CG-Assignment-1

2025-03-05
Back to Blog

CG-Assignment-1 ​

Question-1 ​

Consider the unit sphere centered at the origin as shown in the figure below. An implicit equation of the sphere is x2+y2+z2−1=0

KGZWcw

Give the matrix S that scales the sphere to the ellipsoid whose radii along the x-, y-, and z-axes are 3, 0.5, and 0.3, respectively. What is the inverse of S? ​

S=[300000.500000.300001]S−1=[0.330000200003.3300001]

Given the matrix R that rotates the ellipsoid -45 degrees about the z-axis. What is the inverse of R? ​

R=[22−220022220000100001]R−1=[222200−22220000100001]

Give the matrix T that translates the rotated ellipsoid to (10, 4, 2). What is the inverse of T? ​

T=[100−10010−4001−20001]T−1=[10010010400120001]

Let M be the matrix representing the overall transformations described in (b), (c), and (d). Give a formula for M in terms of S, R, and T. ​

M=T⋅R⋅SM=[322−240−10322240−4000.3−20001]

Give a formula for M−1 ​

M−1=S−1⋅R−1⋅T−1

Let the equation of the ellipsoid by M from the sphere be PTQ′P=0. Derive a formula for Q′. ​

Q′=MT⋅Q⋅M

Brief Solution:

The original sphere has the quadratic form:

PTQP=0

After applying the transformation matrix M, the sphere becomes an ellipsoid, and its new quadratic form becomes:

PTQ′P=0

To derive Q′, substitute the transformation P′=M⋅P into the above. The transformed equation is:

(M⋅P)TQ(M⋅P)=0

This expands to:

PTMTQMP=0

Thus, the new quadratic form matrix is:

Q′=MTQM

Question-2 ​

The following shows a perspective projection where the eye is at the origin, the viewing direction is the opposite of the z-axis, and the projection plane is z=−1.

5pWnbl

A point at (x,y,z) in the viewing frustum is projected on (x′,y′,z′). Give the formula to form x′,y′,z′. ​

x′=x−zy′=y−zz′=−1

Give the 4×4 matrix that represents the projection. ​

Mperspective projection=[100001000010001d0]

Since d=1, the matrix is:

Mperspective projection=[1000010000100010]

Question-3 ​

1. Write down the steps and the composite matrix for rotating 30 degrees about point (1,2). ​

Mcomposite=T(1,2)⋅R(α)⋅T(−1,−2)Mcomposite=[101012001]⋅[22−0.500.5220001]⋅[10−101−2001]

2. Write down the composite matrix for rotating 30 degrees about z-axis, then rotating 60 degrees about y-axis. ​

Mcomposite=Ry(60∘)⋅Rz(30∘)Mcomposite=(0.503200100−3200.500001)⋅(32−0.5000.5320000100001)

3. Write down the rotation matrix for rotating 30 degrees about the axis (1,1,1). Note that rotation by default is counter-clock wise according to right hand rule. ​

According to Rodrigues' Rotation Formula

R=I+sin⁡θ[K]+(1−cos⁡θ)K2

where:

  • I is the identity matrix,
  • θ=30∘=π/6,
  • K is the skew-symmetric matrix of the unit vector v=13(1,1,1).

Compute the Skew-Symmetric Matrix K

The unit vector along (1,1,1) is:

v=13[111]

The skew-symmetric matrix K is:

K=[0−1313130−13−13130]

Compute K2

K2=[−23131313−23131313−23]

Compute the Rotation Matrix

Using sin⁡(30∘)=12 and cos⁡(30∘)=32, we substitute:

R=I+sin⁡(30∘)K+(1−cos⁡(30∘))K2

After computation, the rotation matrix is:

Mcomposite=[2+331−3313132+331−331−33132+33]

4. Given eye point (0,−2,2), center point (0,0,0), up vector (0,1,1), find the camera frame, the transformation matrix from world frame to camera frame. (ref: code assign0). ​

a=Peye−Plook=(0,−2,2)r=up×a=(4,0,0)u=a×r=(0,8,8)

a^=a||a||=(0,−22,22)

r^=r||r||=(1,0,0)

u^=u||u||=(0,22,22)

Question-4 ​

Please draw a, up, r, u vector on the below pictures, and specify which up you choose.

YcczYO