Академический Документы
Профессиональный Документы
Культура Документы
Computer Graphics
Class 1
General
E-mail: sorkine@tau.ac.il
The plan today
Monsters, Inc
Manipulation of geometry and color
Manipulation of geometry and color
Manipulation of geometry and color
Manipulation of geometry and color
Why??
Geometric approach:
If we look from the direction of one of the lines, that
line reduces to a point
So all we need is point-line distance in 2D (the
projection plane)
By projecting, we reduced the problem from 3D to 2D
Example: distance between 2 lines in 3D
Geometric approach:
We can continue reducing the dimension!
Project the red point and the blue line on the plane
perpendicular to the blue line
Now we get point-point distance
Example: distance between 2 lines in 3D
Alternative:
(Almost) skip the geometric intuition step
Represent the lines mathematically
We know that the distance is achieved at a segment
that is perpendicular to both lines
Write down the equation for that segment and solve
(p1 p 2 ), u s || u ||2 t v, u 0
(p1 p 2 ), v s u, v t || v || 0
2
Conclusion so far:
Points Vectors
Point + vector = point
vector + vector = vector
Parallelogram rule
point - point = vector
A
point + point: not defined!!
Map points to vectors
p
p p pO
v O+v
O
Inner (dot) product
v, w || v || || w || cos
L
w cos
||w||
v, w
L
v || v ||
L
Projection of w onto v
Dot product in coordinates (2D)
v ( xv , yv )
y
w ( xw , yw )
yw v, w xv xw yv yw
w
yv
v
O xw xv x
Perpendicular vectors
v, w 0
In 2D only: v ( xv , yv ) v ( yv , xv )
v
Distance between two points
y dist ( A, B) || B A ||
A B A, B A
yA
( xB x A ) 2 ( y B y A ) 2
yB B
O xA xB x
Parametric equation of a line
(t ) p0 t v, t (, )
v
p0
Parametric equation of a ray
(t ) p0 t v, t (0, )
v
p0
Distance between point and line
|| v ||2
Easy geometric interpretation
q
Pythagoras : l
(1) L2 dist(q, q) 2 || q p 0 ||2 v
q p0 , v q
(2) L p0
|| v || L
dist(q, q) 2 || q p 0 ||2 L2
q p0 , v 2
|| q p 0 ||
2
2
.
|| v ||
Distance between point and line
also works in 3D!
Ax By C 0, A, B, C R, ( A, B) (0, 0)
y
Ax+By+C > 0
Ax+By+C < 0
x
Line-segment intersection
Q1 (x1, y1)
y
Ax+By+C > 0
Q2 (x2, y2)
Ax+By+C < 0
x
Representation of a plane in 3D space
q
p0
Distance between point and plane
q n
q p0
Distance between point and plane
(q q) || n q q n, R q q n
q p 0 , n 0 (because q is in the plane )
q n p0 , n 0
q p 0 , n n, n 0
p 0 q, n
|| n ||2
q p0 , n 2
dist (q, ) || q q || || n ||
2 2 2 2
.
|| n ||2
q n
q p0
Distance between point and plane
Geometric way:
Project (q - p0) onto n!
| q p0 , n |
dist
n
q n
p0
Implicit representation of planes in 3D
Ax By Cz D 0, A, B, C , D R, ( A, B, C ) (0, 0, 0)
Ax+By+Cz+D > 0
Ax+By+Cz+D = 0
Ax+By+Cz+D < 0
Distance between two lines in 3D
q1
l1 ( s) p1 su l1
p1
u
l2 (t ) p 2 tv d
p2
v
l2 q2
l1 ( s ) p1 su l1 q1
p1
u
l2 (t ) p 2 tv d
p2
v
l2 q2
l1 ( s ) p1 su l1 q1
p1
u
l2 (t ) p 2 tv d
p2
v
l2 q2
u, v v, p1 p 2 || v ||2 u, p1 p 2
s
|| u ||2 || v ||2 u, v 2
|| u ||2 u, p1 p 2 u, v u, p1 p 2
t
|| u ||2 || v ||2 u, v 2
Distance between two lines in 3D
l1 ( s ) p1 su l1 q1
p1
u
l2 (t ) p 2 tv d
p2
v
l2 q2
~ ~
dist (l1, l2 ) || l1 (s ) l2 ( t ) ||
Distance between two lines in 3D
Exercise () :
Develop the distance formula using the geometric
intuition we talked about in the beginning of the class
Compare to the formula weve just developed
analytically
See you next time!
Barycentric coordinates (2D)
A B
Barycentric coordinates (2D)
P, B, C P, C , A P, A, B
P A B C
A, B, C A, B, C A, B, C
, , denotes the area of the triangle
P
A B
Example of usage: warping
Example of usage: warping
C
P
P
Tagret P1
B
A