vector geometry - nus computing - homecs5240/lecture/vector-geometry.pdf · vector geometry cs5240...
TRANSCRIPT
Vector Geometry
CS5240 Theoretical Foundations in Multimedia
Leow Wee Kheng
Department of Computer Science
School of Computing
National University of Singapore
Leow Wee Kheng (NUS) Vector Geometry 1 / 41
Motivation
Motivation
You are an IT assistant to a surgeon operating on a patient.She wants to know the difference between the left and right side.
? ?
Leow Wee Kheng (NUS) Vector Geometry 2 / 41
Motivation
Need to calculate
◮ symmetric plane
◮ distance of point to plane
◮ average difference between left and right sides
She also wants to know
◮ Is symmetric plane perpendicular to horizontal plane?
◮ Are certain features on a straight line?
◮ etc.
Need a convenient tool: vector geometry.
Leow Wee Kheng (NUS) Vector Geometry 3 / 41
Vector Geometry
Vector Geometry
Vector geometry studies plane geometry using vector algebra.Can be 2-D, 3-D or m-D.
Basic geometrical elements
◮ 0-D: point
◮ 1-D: line
◮ 2-D: plane
◮ m-D: hyperplane
A hyperplane is a m-D linear structure in (m+ 1)-D vector space.
◮ In 2-D space, it is a 1-D line.
◮ In 3-D space, it is a 2-D plane.
Leow Wee Kheng (NUS) Vector Geometry 4 / 41
Vector Geometry
Geometry studies many interesting properties:
◮ Normal of a plane.
◮ Distance of a point to a plane.
◮ Projection of a point on a plane.
◮ Intersection of two planes.
◮ Distance of a point to a line.
◮ Projection of a point on a line.
◮ Intersection of two lines.
Leow Wee Kheng (NUS) Vector Geometry 5 / 41
Vector Geometry Vector Space
Vector Space
A vector space is a structure in which vector addition and scalarmultiplication are defined:
◮ commutative: u+ v = v + u
◮ associative: (u+ v) +w = u+ (v +w)
◮ zero vector: v + 0 = v
◮ negatives: v + (−v) = 0
◮ distributive: s(u+ v) = su+ sv
◮ associative: r(sv) = (rs)v
◮ distributive: (r + s)v = rv + sv
◮ scalar-identity: 1v = v
Leow Wee Kheng (NUS) Vector Geometry 6 / 41
Vector Geometry Vector Space
A Hierarchy of Spaces
a set of vectors
vector addition,scalar multiplication
y
vector space
with norm
y
normed space
with limit
y
Banach space
with inner product
y
Hilbert space(Euclidean space)
Leow Wee Kheng (NUS) Vector Geometry 7 / 41
Vector Geometry Vector Space
◮ length or norm: ‖v‖ =
m∑
j=1
v2j
1/2
◮ distance: d(u,v) = ‖u− v‖ =
m∑
j=1
(uj − vj)2
1/2
◮ dot product: u · v =m∑
j=1
ujvj .
◮ In matrix notation, we denote a vector as a column matrixu = [u1 · · · um]⊤, and vector dot product becomes matrix innerproduct u⊤v.
◮ v · v = ‖v‖2
Leow Wee Kheng (NUS) Vector Geometry 8 / 41
Vector Geometry Vector Space
◮ u · v = ‖u‖‖v‖ cos θ, where θ is the angle between u and v.
vθ
u
◮ If v is a unit vector, then u · v = ‖u‖ cos θ, which is thecomponent of u along v.
◮ In 3-D vector space, cross product u×v is orthogonal to u and v.
u×v =
∣
∣
∣
∣
∣
∣
i j k
u1 u2 u3v1 v2 v3
∣
∣
∣
∣
∣
∣
= (u2v3 − u3v2)i+ (u3v1 − u1v3)j+ (u1v2 − u2v1)k.
(1)
Leow Wee Kheng (NUS) Vector Geometry 9 / 41
Vector Geometry Vector Space
◮ positive: v · v ≥ 0
◮ non-degenerate: v · v = 0 iff v = 0
◮ distributive: u · (v +w) = u · v + u ·w◮ multiplicative: su · v = s(u · v)◮ symmetric: u · v = v · u
◮ positive: ‖v‖ ≥ 0
◮ non-degenerate: ‖v‖ = 0 iff v = 0
◮ multiplicative: ‖sv‖ = |s| ‖v‖
◮ positive: d(u,v) ≥ 0
◮ non-degenerate: d(u,v) = 0 iff u = v
◮ symmetric: d(u,v) = d(v,u)
Leow Wee Kheng (NUS) Vector Geometry 10 / 41
Plane Geometry Normal of Plane
Normal of Plane
A hyperplane π in m-D space is given by the linear equation
a1x1 + a2x2 + · · ·+ amxm + am+1 = 0. (2)
◮ Eq. 2 may be scaled by 1/am+1 to remove am+1.
◮ We keep am+1 in Eq. 2 to retain the scaling factor.
Denote vectors a = (a1, . . . , am), x = (x1, . . . , xm).Then, equation of π can be written as
a · x+ am+1 = 0. (3)
◮ a and am+1 represent the plane π.
◮ x is a point on π.
Leow Wee Kheng (NUS) Vector Geometry 11 / 41
Plane Geometry Normal of Plane
Plane π has a unit normal vector n.
p2
p1
p2p1
π
n
−
Let p1 and p2 be two points on π. Then,
a · p1 + am+1 = 0, (4)
a · p2 + am+1 = 0. (5)
Subtracting Eq. 4 and 5 yields
a · (p1 − p2) = 0. (6)
Leow Wee Kheng (NUS) Vector Geometry 12 / 41
Plane Geometry Normal of Plane
Since p1 − p2 is on π, a must be normal to π.Then, the unit normal n of π is
n =a
‖a‖ . (7)
Leow Wee Kheng (NUS) Vector Geometry 13 / 41
Plane Geometry Distance to Plane
Distance to Plane
Now, consider a point q not on π.
π
O
d
x
nq
Let x denote the (perpendicular) projection of q on π along n.Then, the signed (perpendicular, shortest) distance d of q to π is
d = q · n− x · n. (8)
Leow Wee Kheng (NUS) Vector Geometry 14 / 41
Plane Geometry Distance to Plane
d = q · n− x · n
=q · a− x · a
‖a‖(9)
From Eq. 3, for any point x on π,
a · x = −am+1. (10)
So,
d =a · q+ am+1
‖a‖ . (11)
◮ For a point p on π, d = 0.
◮ For a point q on the +n side of π, d > 0.
◮ For a point q on the −n side of π, d < 0.
Leow Wee Kheng (NUS) Vector Geometry 15 / 41
Plane Geometry Projection on Plane
Projection on Plane
π
O
d
x
nq
The projection x of q on π along n is given by
x = q− dn. (12)
Leow Wee Kheng (NUS) Vector Geometry 16 / 41
Plane Geometry Projection on Plane
So,
x = q− a · q+ am+1
‖a‖2 a. (13)
For q at the origin, q = 0, and its projection is
x = −am+1
‖a‖2 a. (14)
Leow Wee Kheng (NUS) Vector Geometry 17 / 41
Plane Geometry Representations
Representations
A hyperplane can be represented in several ways.
The implicit equation represents a hyperplane as
a1x1 + a2x2 + · · ·+ amxm + am+1 = 0, (15)
where aj are the plane’s coefficients and x is a point on the plane.
In contrast, an explicit equation has the form xj = · · · .
The point-normal form represents a hyperplane by a known point pand unit normal n on the plane, with
n · (x− p) = 0, (16)
where x is a point on the plane.
Leow Wee Kheng (NUS) Vector Geometry 18 / 41
Plane Geometry Representations
A line in 2-D can be represented in the previous forms.
A line in m-D, m ≥ 3, can only be represented as a parametric equation
x = p+ su, (17)
◮ x is a point on the line.
◮ p is a known point on the line.
◮ u is the unit vector along the line.
◮ s is a scalar parameter.
Leow Wee Kheng (NUS) Vector Geometry 19 / 41
Plane Geometry Representations
Consider a point p = (x1, . . . , xm) in m-D vector space.
x2
x1
b1
b2
p
O
Let bj denote m mutually non-parallel unit vectors in the same space.
Then, p can be represented as a linear combination of bj :
p = c1b1 + · · ·+ cmbm. (18)
The vectors bj form a basis.
Leow Wee Kheng (NUS) Vector Geometry 20 / 41
Plane Geometry Representations
In particular, if bj are orthogonal to each other, they form anorthonormal basis.
x2
x1
b1
b2
p
O
In this case,p = p · b1b1 + · · ·+ p · bmbm. (19)
The coordinates of p in this basis is (p · b1, . . . ,p · bm).
Leow Wee Kheng (NUS) Vector Geometry 21 / 41
Plane Geometry Conversion of Representations
Conversion of Representations
Consider a plane π represented by
a1x1 + · · ·+ amxm + am+1 = 0. (20)
As shown previously, π can be represented in point-normal form by
◮ its unit normal n =a
‖a‖ ,
◮ the projected point p of the origin on π, where p = −am+1
‖a‖2 a.
Leow Wee Kheng (NUS) Vector Geometry 22 / 41
Plane Geometry Conversion of Representations
Now, consider a plane π represented by a point p and unit normal n.
From Eq. 6,n · (x− p) = 0. (21)
So, we obtain the implicit equation
n1x1 + · · ·+ nmxm − n · p = 0. (22)
Leow Wee Kheng (NUS) Vector Geometry 23 / 41
Plane Geometry Conversion of Representations
Example
Consider a 1-D hyperplane, i.e., a line, in a 2-D space represented by
x+ y − 1 = 0. (23)
x
y
O 1
1 n
p
In this case, a1 = 1, a2 = 1, a3 = −1.
Leow Wee Kheng (NUS) Vector Geometry 24 / 41
Plane Geometry Conversion of Representations
Line normal n is
n =(a1, a2)
‖(a1, a2)‖=
(1, 1)√2
=
(
1√2,1√2
)
(24)
The projected point p of the origin on the line is
p = − a3‖(a1, a2)‖2
(a1, a2) =1
2(1, 1) =
(
1
2,1
2
)
. (25)
The signed distance d of the origin to the line is
d =a · 0+ a3‖(a1, a2)‖
= − 1√2. (26)
That is, the origin is on the negative side of the line.
Leow Wee Kheng (NUS) Vector Geometry 25 / 41
Plane Geometry Plane Intersection
Plane Intersection
Consider two non-parallel (infinite) hyperplanes πa and πb
π1 : a · x+ am+1 = 0,
π2 : b · x+ bm+1 = 0.(27)
The intersection of π1 and π2 is a hyperplane of one fewer dimension.Any point x on the intersection satisfies both plane equations.
Caution!
Do not subtract the two equations to get
(a− b) · x+ am+1 − bm+1 = 0. (28)
Why?
Leow Wee Kheng (NUS) Vector Geometry 26 / 41
Plane Geometry Plane Intersection
Now, let us consider 2-D planes in 3-D space.
π2
π1
n1 n2
n1 n2x
Denote the planes’ point-normal forms as
π1 : n1 · x− n1 · p1 = 0,
π2 : n2 · x− n2 · p2 = 0.(29)
In 3-D space, n1×n2 is well-defined.n1, n2, and n1×n2 form a basis.
Leow Wee Kheng (NUS) Vector Geometry 27 / 41
Plane Geometry Plane Intersection
So, any point p can be represented as
p = c1n1 + c2n2 + c3n1×n2 (30)
for some appropriate c1, c2, c3.
In 3-D space, intersection of 2 planes is a line.
n1×n2 is parallel to the line of intersection.So, the line can be represented by the parametric equation
x = c1n1 + c2n2 + sn1×n2 (31)
where s is a scalar parameter.
Leow Wee Kheng (NUS) Vector Geometry 28 / 41
Plane Geometry Plane Intersection
Let’s denote h1 = n1 · p1 and h2 = n2 · p2.
Substituting Eq. 31 into Eq. 29 gives
c1 + c2n1 · n2 = h1,
c1n1 · n2 + c2 = h2.(32)
Solving Eq. 32 yields (Homework)
c1 =h1 − h2n1 · n2
1− (n1 · n2)2,
c2 =h2 − h1n1 · n2
1− (n1 · n2)2.
(33)
Leow Wee Kheng (NUS) Vector Geometry 29 / 41
Plane Geometry Plane Intersection
Example
Consider these two 2-D planes 3-D space:
π1 : x+ y − 1 = 0,
π2 : x− y = 0.
Want to find the intersectionof the planes.
π2
1π
1n
n2
O
x
y
1
1
z
Leow Wee Kheng (NUS) Vector Geometry 30 / 41
Plane Geometry Plane Intersection
Convert to point-normal form with the projected point of the origin.
plane π1 : n1 =
(
1√2,1√2, 0
)
, p1 =
(
1
2,1
2, 0
)
,
plane π2 : n2 =
(
1√2,− 1√
2, 0
)
, p2 = (0, 0, 0).
(34)
So,
h1 = n1 · p1 =1√2, h2 = n2 · p2 = 0. (35)
Note: n1 · n2 = 0, n1×n2 = (0, 0,−1). (Homework)
Then, the intersection line is given by
x = c1 · n1 + c2 · n2 + sn1×n2 =
(
1
2,1
2, 0
)
+ s(0, 0,−1). (36)
Leow Wee Kheng (NUS) Vector Geometry 31 / 41
Line Geometry Projection on Line
Projection on Line
A line l in m-D space with m ≥ 3 is given by the parametric equation
x = p+ su. (37)
O
p
q
ux l
Consider a point q not on l that projects to x on l.The distance between p and x is
q · u− p · u = (q− p) · u. (38)
So,x = p+ (q− p) · uu. (39)
Leow Wee Kheng (NUS) Vector Geometry 32 / 41
Line Geometry Distance to Line
Distance to Line
O
p
q
ux l
The (perpendicular) distance d from q to its projection x on line l is
d = ‖q− x‖ = ‖(q− p)− (q− p) · uu‖. (40)
Leow Wee Kheng (NUS) Vector Geometry 33 / 41
Line Geometry Line Intersection
Line Intersection
In general, two non-parallel lines l1 and l2 in m-D space with m ≥ 3do not intersect.
They can intersect only if they are coplanar, i.e., lie on a 2-D plane.
In this case, suppose they are given by the implicit equations
a1x+ a2y + a3 = 0,
b1x+ b2y + b3 = 0.(41)
Then, their intersection is (Homework)
x =a2b3 − a3b2a1b2 − a2b1
,
y =a3b1 − a1b3a1b2 − a2b1
.
(42)
Leow Wee Kheng (NUS) Vector Geometry 34 / 41
Line Geometry Line Intersection
Example
l2l1
x
y
O 1
1
x
The line equations are:
l1 : x+ y − 1 = 0
l2 : x− y − 0 = 0(43)
So,
x =0− 1
−1− 1=
1
2, y =
−1− 0
−1− 1=
1
2.
Leow Wee Kheng (NUS) Vector Geometry 35 / 41
Line Geometry Line Intersection
In general, can only solve for a point that is closest to the lines.
l2
l1
d2
d1
q
Point q projects perpendicularly to x1 on line l1 and x2 on line l2.Point q is mid-way between x1 and x2.
Point q minimizes its distance to l1 and l2.
Leow Wee Kheng (NUS) Vector Geometry 36 / 41
Line Geometry Line Intersection
Given n lines of the form x = pi + sui, the closest point q to the linesminimizes the sum squared distance D
D =n∑
i=1
‖(q− pi)− (q− pi) · ui ui‖2. (44)
There is no closed-form solution for this problem.
In practice, have to apply optimization algorithm instead.
Leow Wee Kheng (NUS) Vector Geometry 37 / 41
Summary
Summary
◮ Vector geometry studies plane geometry using vector algebra.
◮ Studies geometrical properties such as normal, distance,projection, intersection.
◮ Two representations for planes:implicit equation vs. point-normal form.
◮ Lines in m-D space with m ≥ 3 are represented by point-directionform.
Leow Wee Kheng (NUS) Vector Geometry 38 / 41
Probing Questions
Probing Questions
◮ A point is on a plane when its distance to the plane is 0. Inprogramming, we may not get exactly 0 due to floating-pointrounding error. How to handle this problem?
◮ The distance between a point to a plane has a sign. Does thedistance between a point to a line has a sign?
◮ What is the intersection of 3 planes?How to get the intersection of 3 planes?
Leow Wee Kheng (NUS) Vector Geometry 39 / 41
Homework
Homework
1. What are the key concepts that you have learned?
2. Consider a plane π represented by a known point p and a unitnormal n on π. Let q denote a point whose projected point on π isnot p. Show that the perpendicular distance d of q to π is givenby d = (q− p) · n.
3. Solve Eq. 32 to obtain Eq. 33 for the intersecting line of twoplanes.
4. Show that for the n1 and n2 in Eq. 34, n1 · n2 = 0, andn1×n2 = (0, 0,−1).
5. Solve Eq. 41 to obtain Eq. 42 for the intersection point of twocoplanar lines.
Leow Wee Kheng (NUS) Vector Geometry 40 / 41
References
References
1. J. E. Marsden and M. J. Hoffman, Elementary Classical Analysis, 2nded., W. H. Freeman, 1993.
2. B. Noble and J. W. Daniel, Applied Linear Algebra, 3rd ed.,Prentice-Hall, 1988.
Leow Wee Kheng (NUS) Vector Geometry 41 / 41