View
217
Download
0
Tags:
Embed Size (px)
Citation preview
General
Office hour: Sunday 16:00 – 17:00 in Schreiber 002
Webpage with the slides: http://www.cs.tau.ac.il/~sorkine/courses/cg/
E-mail: [email protected] Short home assignments will be given from time
to time
Why??
We represent objects using mainly linear primitives: points lines, segments planes, polygons
Need to know how to compute distances, transformations…
Basic definitions
Points specify location in space (or in the plane). Vectors have magnitude and direction (like
velocity).
Points Vectors
Map points to vectors
If we have a coordinate system with
origin at point O We can define correspondence between points
and vectors:
vOv
OPPP
Distance between point and line
Find a point Q’ such that (Q Q’)vdist(Q, l) = ||Q Q ’ ||
P0
v
Q
Q’ = P0 +tv
2
202
022
200
0
0
||||
,||||||||),(dist
||||
,
,
,
0,,
0,
0,
v
vPQPQQQlQ
v
vPQ
vv
vPQt
vvtvPQ
vtvPQ
vQQ
l
Easy geometric interpretation
P0
v
Q
Q’
.||||
,||||
||||),(dist
||||,
||||),(dist
:
2
202
0
220
2
0
20
22
v
vPQPQ
LPQQQ
vLvPQ
PQQQL
Pythagoras
l
L
Distance 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…
Line-segment intersection
0))((
linetheintersectsQQsegmentThe
2211
21
CByAxCByAx
x
yAx+By+C > 0
Ax+By+C < 0
Q1 (x1, y1)
Q2 (x2, y2)
Representation of a plane in 3D space
The plane is defined by a normal n and one point in the plane (P0).
A point Q belongs to the plane <Q – P0 , n> = 0
The normal n is perpendicular to all vectors in the plane
n
P0
Q
Distance between point and plane
Project the point onto the plane in the direction of the normal:
dist(Q, ) = ||Q’ – Q||
n
P0Q’
Q
Distance between point and plane
n
P0Q’
Q
.||||
,||||||'||),(dist
||||
,
0,,
0,
0,
R,||)(
2
202222
20
0
0
0
n
nPQnsQQQ
n
nQPs
nnsnPQ
nsnPQ
nPQ
snQQssnQQnQQ
Implicit representation of planes in 3D
0,R,,,,0 CBADCBADCzByAx
(x, y, z) are coordinates of a point on the plane (A, B, C) are the coordinates of a normal vector to the
plane
Ax+By+Cz+D > 0
Ax+By+Cz+D < 0
Ax+By+Cz+D = 0
Distance between two lines in 3D
P1
P2
u
v
d
The distance is attained between two points Q1 and Q2
so that (Q1 – Q2) u and (Q1 – Q2) v
Q1
Q2
l1
l2
tvPtl
suPsl
22
11
)(
)(
Distance between two lines in 3D
P1
P2
u
v
d
Q1
Q2
l1
l2
tvPtl
suPsl
22
11
)(
)(
0,)(
0,)(
21
21
vtvsuPP
utvsuPP
0||||,),(
0,||||),(2
21
221
vtvusvPP
uvtusuPP
Distance between two lines in 3D
P1
P2
u
v
d
Q1
Q2
l1
l2
tvPtl
suPsl
22
11
)(
)(
2222121
2
22221
221
,||||||||
,,,||||~
,||||||||
,||||,,~
vuvu
PPuvuPPuut
vuvu
PPuvPPvvus
Distance between two lines in 3D
P1
P2
u
v
d
Q1
Q2
l1
l2
tvPtl
suPsl
22
11
)(
)(
||)~()~(||),(dist 2121 tlslll
Barycentric coordinates (2D)
Define a point’s 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, , , [0, 1], ++ = 1
A B
C
P
Barycentric coordinates (2D)
A B
C
P
triangletheofareathedenotes,,
,,
,,
,,
,,
,,
,,
CCBA
BAPB
CBA
ACPA
CBA
CBPP
Example of usage: warping
Tagret
AB
C
AB
C
We take the barycentric coordinates , , of P’ with respect to A’, B’, C’.Color(P) = Color( A + B + C)
P
P
P