Transformations in 3D Right-handed coordinate system z-axis points - - PowerPoint PPT Presentation
Transformations in 3D Right-handed coordinate system z-axis points - - PowerPoint PPT Presentation
Transformations in 3D Right-handed coordinate system z-axis points toward viewer y x z Translation in 3D What are the coordinates of P after translating by d=(dx,dy,dz) x' = ? y' = ? P'(x',y', z') z' = ? P(x,y,z) Translation in 3D
Translation in 3D
What are the coordinates of P after translating by d=(dx,dy,dz)
P(x,y,z) P'(x',y', z')
x' = ? y' = ? z' = ?
Translation in 3D
What are the coordinates of P after translating by d=(dx,dy,dz)
P(x,y,z) P'(x',y', z')
x' = x + dx = 1*x + 0*y + 0*z + 1*dx y' = y + dy = 0*x + 1*y + 0*z + 1*dy z' = z + dz = 0*x + 0*y + 1*z + 1*dz in matrix form
x' y' z' 1 x y z 1
= *
1 dx 1 dy 1 dz 1
Scaling in 3D
What are the coordinates of P after scaling by sx,sy,sz
P(x,y,z) P'(x',y',z')
x' = ? y' = ? z' = ?
Scaling in 3D
What are the coordinates of P after scaling by sx,sy,sz
P(x,y,z) P'(x',y',z')
x' = sx * dx = sx*x + 0*y + 0*z y' = sy * dy = 0*x + sy*y + 0*z z' = sz * dz = 0*x + 0*y + sz*z in matrix form
x' y' z' 1 x y z 1
= *
sx sy sz 1
Rotation in 3D around Z-axis
Rotating in a plane parallel to the XY-plane Same as rotating in 2D keep the Z-coordinate the same
P(x,y,z) a r r P'(x',y',z') P(x,y,z) a r r P'(x',y',z')
Rotation in 3D around Z-axis
Rotating in a plane parallel to the XY-plane Same as rotating in 2D keep the Z-coordinate the same Same matrix with extra row, column
cosα
- sinα
sinα cosα 1 1
x' y' z' 1 x y z 1
= *
P(x,y,z) a r r P'(x',y',z') P(x,y,z) a r r P'(x',y',z')
Rotation in 3D around Y-axis
P'(x',y',z') P(x,y,z)
Rotating in a plane parallel to the XY-plane Same as rotating in 2D keep the Y-coordinate the same
a P'(x',y',z') P(x,y,z) a
Rotation in 3D around Y-axis
cosα sinα 1
- sinα
cosα 1
P'(x',y',z') P(x,y,z)
Rotating in a plane parallel to the XY-plane Same as rotating in 2D keep the Y-coordinate the same
x' y' z' 1 x y z 1
= *
a P'(x',y',z') P(x,y,z) a
Rotation in 3D around X-axis
P(x,y,z) P'(x',y',z') α P(x,y,z) P'(x',y',z') α
Rotating in a plane parallel to the YZ-plane Same as rotating in 2D keep the X-coordinate the same
Rotation in 3D around X-axis
1 cosα
- sinα
sinα cosα 1
P(x,y,z) P'(x',y',z') α P(x,y,z) P'(x',y',z') α
Rotating in a plane parallel to the YZ-plane Same as rotating in 2D keep the X-coordinate the same
x' y' z' 1 x y z 1
= *
Rotation around arbitrary axis
P(x,y,z) α P'(x',y',z') A(ax,ay,az)
can reduce to rotation around Z-axis by realignment of coordinate system
Rotation around arbitrary axis
P(x,y,z) A(ax,ay,az)
Rotation around arbitrary axis
P(x,y,z) A(ax,ay,az) P(x,y,z) A(ax,ay,az) A'(ax',ay',az') A”(ax”,ay”,az”)
compute A',A” s.t. A,A',A” perpend.
Rotation around arbitrary axis
P(x,y,z) A(ax,ay,az) P(x,y,z) A(ax,ay,az) A'(ax',ay',az') A”(ax”,ay”,az”) P(x,y,z) A(ax,ay,az) A'(ax',ay',az') A”(ax”,ay”,az”)
compute A',A” s.t. A,A',A” perpend. align A',A”,A with main axes X,Y,Z
Rotation around arbitrary axis
P(x,y,z) A(ax,ay,az) P(x,y,z) A(ax,ay,az) A'(ax',ay',az') A”(ax”,ay”,az”) P(x,y,z) A(ax,ay,az) A'(ax',ay',az') A”(ax”,ay”,az”)
compute A',A” s.t. A,A',A” perpend. align A',A”,A with main axes X,Y,Z
ax' ay' az' ax” ay” az” ax ay az 1
M
Rotation around arbitrary axis
P(x,y,z) A(ax,ay,az) P(x,y,z) A(ax,ay,az) A'(ax',ay',az') A”(ax”,ay”,az”) P(x,y,z) P'(x',y',z') A(ax,ay,az) A'(ax',ay',az') A”(ax”,ay”,az”) α
compute A',A” s.t. A,A',A” perpend. align A',A”,A with main axes X,Y,Z rotate around z
ax' ay' az' ax” ay” az” ax ay az 1
M
ca
- sa
sa ca 1 1
R
Rotation around arbitrary axis
P(x,y,z) α P'(x',y',z') A(ax,ay,az) P(x,y,z) A(ax,ay,az) A'(ax',ay',az') A”(ax”,ay”,az”) P(x,y,z) P'(x',y',z') A(ax,ay,az) A'(ax',ay',az') A”(ax”,ay”,az”) α
compute A',A” s.t. A,A',A” perpend. align A',A”,A with main axes X,Y,Z r e s t
- r
e a l i g n m e n t rotate around z
ax' ay' az' ax” ay” az” ax ay az 1
M
ax' ax” ax ay' ay” ay az' az” az 1
M'
ca
- sa
sa ca 1 1
R
Rotation around arbitrary axis
P(x,y,z) α P'(x',y',z') A(ax,ay,az)
can reduce to rotation around Z-axis by realignment of coordinate system R = M' * Rz * M multiply top of stack by R
Rendering Pipeline
Mmodel Mview*Mproj World space View space Screen space
P’ = Mproj Mview Mmodel * P
http://www.songho.ca/opengl/gl_transform.html
The Camera Model (2D)
v u e camera parameters: e – eye point coordinates v – the directions of the view u – up vector e – what is the position (ex,ey)
- f the camera in the world
v – what are the coordinates (vx,vy) of the viewing direction in the world u – a vector perpendicular to v v u e The camera parameters and the coordinates of the model are specifjed in world space
The Camera Model (2D)
v u e To render the model need to: represent it from world space to camera view space coordinates – Mview project it on the camera film – Mproj v u e x y x' y'
The Camera Model (2D)
World to View space transformation (Mview) – align camera axes with the world axes u v e
The Camera Model (2D)
T R
World to View space transformation (Mview) – align camera axes with the world axes u v e
The Camera Model (2D)
T R
1
- ex
1
- ey
1
World to View space transformation (Mview) – align camera axes with the world axes u v e
The Camera Model (2D)
T R
1
- ex
1
- ey
1 vx vy ux uy 1
World to View space transformation (Mview) – align camera axes with the world axes u v e
The Camera Model (2D)
T R
1
- ex
1
- ey
1 vx vy ux uy 1