Title: 3D Geometry for Computer Graphics
13D Geometry forComputer Graphics
2General
- Office hour Sunday 1100 1200
in Schreiber 002 - Webpage with the slides http//www.cs.tau.ac.il/
sorkine/courses/cg/cg2004/ - E-mail sorkine_at_tau.ac.il
- Short home assignments will be given from time to
time
3The plan today
- Basic linear algebra and
- Analytical geometry
4Why??
- We represent objects using mainly linear
primitives - points
- lines, segments
- planes, polygons
- Need to know how to compute distances,
transformations, projections
5Basic definitions
- Points specify location in space (or in the
plane). - Vectors have magnitude and direction (like
velocity).
Points ? Vectors
6Point vector point
7vector vector vector
Parallelogram rule
8point - point vector
B A
B
A
A B
B
A
9point point not defined!!
10Map points to vectors
- If we have a coordinate system with
- origin at point O
- We can define correspondence between points and
vectors
11Inner (dot) product
w
?
v
L
Projection of w onto v
12Dot product in coordinates (2D)
y
yw
w
yv
v
xv
xw
x
O
13Perpendicular vectors (2D)
v?
v
14Parametric equation of a line
v
t gt 0
p0
t 0
t lt 0
15Parametric equation of a ray
v
t gt 0
p0
t 0
16Distance between two points
y
A
yA
B
yB
xB
xA
x
O
17Distance between point and line
- Find a point q such that (q ? q)?v
- dist(q, l) q ? q
l
18Easy geometric interpretation
q
l
v
q
p0
L
19Distance between point and line also works in
3D!
- The parametric representation of the line is
coordinates-independent - v and p0 and the checked point q can be in 2D or
in 3D or in any dimension
20Implicit equation of a line in 2D
y
AxByC gt 0
AxByC 0
AxByC lt 0
x
21Line-segment intersection
Q1 (x1, y1)
y
AxByC gt 0
Q2 (x2, y2)
AxByC lt 0
x
22Representation of a plane in 3D space
- A plane ? is defined by a normal n and one point
in the plane p0. - A point q belongs to the plane ? lt q p0 , n gt
0 - The normal n is perpendicular to all vectors in
the plane
n
q
p0
?
23Distance between point and plane
- Project the point onto the plane in the direction
of the normal - dist(q, ?) q q
n
q
q
p0
?
24Distance between point and plane
n
q
q
p0
?
25Implicit representation of planes in 3D
- (x, y, z) are coordinates of a point on the plane
- (A, B, C) are the coordinates of a normal vector
to the plane
AxByCzD gt 0
AxByCzD 0
AxByCzD lt 0
26Distance between two lines in 3D
q1
l1
p1
u
d
p2
v
l2
q2
The distance is attained between two points q1
and q2 so that (q1 q2) ? u and (q1 q2) ? v
27Distance between two lines in 3D
q1
l1
p1
u
d
p2
v
l2
q2
28Distance between two lines in 3D
q1
l1
p1
u
d
p2
v
l2
q2
29Distance between two lines in 3D
q1
l1
p1
u
d
p2
v
l2
q2
30Barycentric coordinates (2D)
- Define a points position relatively to some
fixed points. - P ?A ?B ?C, where A, B, C are not on one
line, and ?, ?, ? ? R. - (?, ?, ?) are called Barycentric coordinates of P
with respect to A, B, C (unique!) - If P is inside the triangle, then ???1, ?, ?,
? gt 0
C
P
A
B
31Barycentric coordinates (2D)
C
P
A
B
32Example of usage warping
33Example of usage warping
C
Tagret
B
A
We take the barycentric coordinates ?, ?, ? of
P with respect to A, B, C. Color(P) Color(?
A ? B ? C)
34See you next time!