3D Geometry Representation for Computer Graphics
Transcript of 3D Geometry Representation for Computer Graphics
3D Geometry Representation
for Computer Graphics
November 3, 2016
Outline
• Implicit vs. parametric equations for surfaces
• Surface normals
• Surface types discussed in this lecture
– Plane
– Quadrics: Sphere, ellipsoid, cylinder, cone, etc.
– Toroid
– Superquadric
– Supertoroid
Sphere
Implicit equation for sphere centered at origin:
3D point (x,y,z) is on, outside, or inside sphere:
Parametric equation for sphere:
f (x, y, z) = x2 + y2 + z2 − r2
ϕ
θϕ
θϕ
sin
sincos
coscos
rz
ry
rx
=
=
= −π
2≤ φ ≤
π
2
−π ≤θ ≤ π
f (x, y, z) = 0 f (x, y, z) < 0f (x, y, z) > 0
Sphere
Parametric equation, rewritten in vector form:
p(u, v) =
r cosucosv
r cosusin v
rsinu
1
−π
2≤ u ≤
π
2
−π ≤ v ≤ π
Parametric Surface Equations
• Parametric form is good for generating triangle mesh
• The (u,v) parameters of each vertex can be used for applying a 2D texture map to the surface
Texture maps from:
http://www.robinwood.com/Catalog/FreeStuff/Textures/TexturePages/BallMaps.html
Ellipsoid
Implicit equation for ellipsoid centered at origin:
Parametric equation for ellipsoid:
f (x, y, z) = xrx
( )2
+ y
ry( )2
+ zrz
( )2
−1
p(u, v) =
rx cosucosv
ry cosusin v
rz sinu
1
−π
2≤ u ≤
π
2
−π ≤ v ≤ π
Implicit Equation: Quadric Form
Implicit equation for general quadric surface can be
written in terms of symmetric matrix Q:
Equivalent to:
xTQx = 0 Q =
A B C D
B E F G
C F H I
D G I J
x =
x
y
z
1
f (x, y, z) = Ax2 + 2Bxy + 2Cxz + 2Dx + Ey2 + 2Fyz + 2Gy + Hz2 + 2Iz + J = 0
Sphere
Implicit equation:
Equivalent to:
xTQx = 0
Q =
A B C D
B E F G
C F H I
D G I J
=
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 −r2
=
1
r2
0 0 0
01
r2
0 0
0 01
r2
0
0 0 0 −1
x =
x
y
z
1
f (x, y, z) = Ax2 + 2Bxy + 2Cxz + 2Dx + Ey
2 + 2Fyz + 2Gy + Hz2 + 2Iz + J = 0
f (x, y, z) = x2 + y
2 + z2 − r
2
f (x, y, z) =x
2
r2
+y
2
r2
+z
2
r2
−1
Ellipsoid
Implicit equation:
Equivalent to:
xTQx = 0
Q =
A B C D
B E F G
C F H I
D G I J
=
1
rx
20 0 0
01
ry
20 0
0 01
rz
20
0 0 0 −1
f (x, y, z) = Ax2 + 2Bxy + 2Cxz + 2Dx + Ey
2 + 2Fyz + 2Gy + Hz2 + 2Iz + J = 0
f (x, y, z) =x
2
rx
2+
y2
ry
2+
z2
rz
2−1
Cylinder Implicit Equation
Infinite cylinder (along z axis), elliptical cross-section:
Equivalent to:
xTQx = 0
Q =
A B C D
B E F G
C F H I
D G I J
=
1
rx
20 0 0
01
ry
20 0
0 0 0 0
0 0 0 −1
f (x, y, z) = Ax2 + 2Bxy + 2Cxz + 2Dx + Ey
2 + 2Fyz + 2Gy + Hz2 + 2Iz + J = 0
f (x, y, z) =x
2
rx
2+
y2
ry
2−1
Parametric Surface Equations
Ellipsoid:
Cylinder with elliptical cross-section:
umin ≤ u ≤ umax
−π ≤ v ≤ πp(u, v) =
rx cosv
ry sin v
u
1
−π
2≤ u ≤
π
2
−π ≤ v ≤ πp(u, v) =
rx cosucosv
ry cosusin v
rz sinu
1
Cone Implicit Equation
Infinite cone (along z axis), elliptical cross-section:
Equivalent to:
xTQx = 0
Q =
A B C D
B E F G
C F H I
D G I J
=
1
rx
20 0 0
01
ry
20 0
0 0 −1
s2
0
0 0 0 0
f (x, y, z) = Ax2 + 2Bxy + 2Cxz + 2Dx + Ey
2 + 2Fyz + 2Gy + Hz2 + 2Iz + J = 0
f (x, y, z) =x
2
rx
2+
y2
ry
2−
z2
s2
Parametric Surface Equation
Cone with elliptical cross-section:
umin ≤ u ≤ umax
−π ≤ v ≤ πp(u, v) =
urx cosv
ury sin v
u
1
Plane Implicit Equation
Given plane equation
Equivalent to:
xTQx = 0
Q =
A B C D
B E F G
C F H I
D G I J
=
0 0 0a
2
0 0 0b
2
0 0 0c
2
a
2
b
2
c
2−d
f (x, y, z) = Ax2 + 2Bxy + 2Cxz + 2Dx + Ey
2 + 2Fyz + 2Gy + Hz2 + 2Iz + J = 0
f (x, y, z) = ax + by + cz − d
ax + by + cz − d = 0
Parametric Plane Equation
There are a number of ways to parameterize a plane surface. One is to use basis vectors u, v and origin p0
Basis vectors u v are orthogonal in this case.
p(u, v) = p0 + uu + vv
p(u, v) =
x0
y0
z0
1
+ u
xu
yu
zu
0
+ v
xv
yv
zv
0
p0
v
u
Quadric Surfaces
See wikipedia page for more examples
Torus
Implicit equation for torus with circular cross-section
centered at origin:
Parametric equation:
f (x, y, z) = x2 + y2 − raxial( ) + z2 − r2
p(u, v) =
(raxial + r cosu)cosv
(raxial + r cosu)sin v
rsinu
1
−π ≤ u ≤ π
−π ≤ v ≤ π
Varying the Radius: raxial
Superquadric Ellipsoids
Superquadric Ellipsoids
Implicit equation:
Parametric equation:
f (x, y, z) = xrx
( )2
ε2 + y
ry( )2
ε2
ε2
ε1
+ zrz
( )2
ε1 −1
p(u, v) =
rx sign(cosu) cosuε1
sign(cosv) cosvε2
ry sign(cosu) cosuε1
sign(sin v) sinvε2
rz sign(sinu) sinuε1
1
−π
2≤ u ≤
π
2,−π ≤ v ≤ π
ε1 > 0,ε2 > 0
ε1 = ε2 =1 is ellipsoid
ε1 = ε2 = 0.1 is box-like shape
Supertoroids!
Supertoroid
Implicit equation:
Parametric equation:
f (x, y, z) = xrx
( )2
ε2 + y
ry( )2
ε2
ε2
2
− raxial
2
ε1
+ zrz
( )2
ε1 −1
p(u, v) =
rx sign(cosu) cosuε1
raxial + sign(cosv) cosvε2( )
ry sign(cosu) cosuε1
raxial + sign(sinv) sin vε2( )
rz sign(sinu) sinuε1
1
−π ≤ u ≤ π,−π ≤ v ≤ π
Computing Surface Normals
Surface Normal
• Surface normal at each vertex can be used in
illumination and shading of the mesh.
Surface Normal
• Advanced topic: Surface normals are also used in game
physics and animation: computing collision response,
friction, etc., where surfaces are in contact.
Computing the Surface Normal
• Parametric form:
– Take partial derivative (tangent to surface) along each
parametric direction.
– Cross-product yields the normal.
• Use 3D (non-homogeneous form), for instance sphere:
n(u, v) =∂
∂up(u, v) ⊗
∂
∂vp(u, v)
p(u, v) =
r cosucosv
r cosusin v
rsinu
Computing Sphere Surface Normal
n(u, v) =∂
∂u
r cosucosv
r cosusinv
rsinu
⊗∂
∂v
r cosucosv
r cosusinv
rsinu
n(u, v) =
−rsinucosv
−rsinusinv
r cosu
⊗
−r cosusinv
r cosucosv
0
n(u, v)
|| n(u, v) ||=
cosucosv
cosusinv
sinu
Computing Surface Normal
from Implicit Equation
• Given the implicit equation for a surface, we can
obtain the normal at (x,y,z) by taking the gradient:
n(x, y, z) = ∇f (x, y, z)
n(x, y, z) =
∂
∂xf (x, y, z)
∂
∂yf (x, y, z)
∂
∂zf (x, y, z)
Computing Sphere Surface Normal
from Implicit Equation
Given a point on surface
n(x, y, z) = ∇f (x, y, z)
n(x, y, z) =
∂
∂xx
2 + y2 + z
2 − r2( )
∂
∂yx
2 + y2 + z
2 − r2( )
∂
∂zx
2 + y2 + z
2 − r2( )
=
2x
2y
2z
f (x, y, z) = x2 + y
2 + z2 − r
2 = 0
Quadric Surface Normal
from Implicit Equation
Given a point x on surface
n(x) = ∇ xTQx( )n(x) = 2Qx
xTQx = 0