Vector
Vector
Vector
Computer Graphics
Computer Graphics
Basic Definitions
Points Vectors
Basics of Vectors
v Vector as displacement:
P
v v is a vector from point P to point Q.
Another way:
P v
Operations on Vectors
Two operations
Addition
b
a+ b a+ b
b
a a
Multiplication by scalar
a
2a
-a
Operations on vectors
Subtraction
a-c a-c
a a a
c -c c
Properties of vectors
Length or size
w = (w1,w2,…,wn)
Unit vector
a
a
a
• The process is called normalizing
• Used to refer direction
Properties
1. Symmetry: a·b = b·a
2. Linearity: (a+c) ·b = a·b + c·b
3. Homogeneity: (sa) ·b = s(a·b)
4. |b|2 = b·b
Application of Dot Product
y
c
b ^ ^
θ cos( ) b c
Φc
Φb
x
a┴
a
Let a = (ax,ay). -a┴
Then
a┴ = (-ay,ax)
is the a
counterclockwise
perpendicular to a.
v┴
v
v┴sinA A
vcosA
Rotation in 3d
• We want to rotate a 3d vector l counterclockwise with respect to a
3d unit vector r by an angle A, where l and r are perpendicular to
each other
• First we determine the vector u, that is perpendicular to both l and
r and have a length equal to that of l
• So, u = r X l
• Then we scale l by cosA and scale u by sinA and take their sum
• We want to decompose the vector c into two vectors, one along the
direction of a unit vector v and another along perp(v)
• The length of the orthogonal projection of c along v is c.v
(as v is a unit vector)
• Thus the component (or orthogonal projection) of c along v is (c.v)v
• So the component of c along perp(v) is c-(c.v)v
c
v┴
v
c.v
Reflection [13]
n
n
a r a r
θ1 θ2 m -m
e e
r = a - 2 ( a . n) n
• Here m is the orthogonal projection of a along n
• m equals (a.n)n as n is a unit vector
Cross Product
Properties
1. Antisymmetry: a Χ b = - b Χ a
2. Linearity: (a +c) Χ b = a Χ b + c Χ b
3. Homogeneity: (sa) Χ b = s(a Χ b)
Geometric Interpretation of Cross Product
y
axb
a P1
P3
b
P2
x
z
Line Ray
2 types of representations:
1. Two point form
2. Parametric representation
Parametric Representation of a Line
y t>1
B
b t=
C 1
t=0
t<0
x
Planes in 3D
4 fundamental forms
Three-point form
Parametric representation
Point normal form
Equation
Parametric Representation of Plane
C b
a
Point Normal Form of a Plane
B
Representations of Plane [13]
{C, n}
Point
{A,C, B} n = (A-C)x(B – C) Normal
Three Point
n
)x
A
,1
=
,0
a
B
(0
nx
=
+
C
a=
a
b
+
ax
b
a=
=
b=
n
A–
B–
Parametric
C
C
{C, a, b}
Equation of a Plane [1][2][3][4]
(x, y) ny
How to convert between
nx equation and the other
p.n P = (px, py) forms?
L
Line-Plane Intersection [8]
• Plane: ax + by + cz + d = 0
• Line: P + tV
• Determine the specific value of t (say t’) for which the equation of
the plane is satisfied, i.e., the point on the line lies on the plane
Line-Line Intersection [5][6][7]
• L1: P1 + tV1
• L2: P2 + sV2
• If they are not parallel, how to decide whether they intersect or not?
• One solution
• Generate three equations for two unknowns
• Solve the first two equations to find a solution
• Check whether the solution satisfies the third equation
• Another solution
• Check whether (P1 – P2).(V1 X V2) = 0
• If lines intersect this condition must hold
• If lines do not intersect, is it sure not to hold?
Plane-Plane Intersection [9][10]
• Intersection is a line
• So we need two points on the line, or one point and the direction
• How to get a point on the intersecting line?
• How to get the direction of the intersecting line?
Plane-Plane Intersection
• Plane 2: P2, n2
Definition
Linear combination of m vectors v1, v2, …, vm:
w = a1v1 + a2 v2 + …+ amvm
where a1,a2,…am are scalars.
Types
Affine Combination Convex Combination
a1 + a2 + …+ am = 1 a1 + a2 + …+ am = 1
Examples:
and ai ≥ 0, for i = 1,…m.
3a + 2b - 4c
Example: .3a + .2b + .5c
(1- t)a + (t)b
Convex Combination of Vectors
v2
a(v2-v1)
v v3
v1
v2
v1
Links
[1] http://www.songho.ca/math/plane/plane.html
[2] http://mathinsight.org/distance_point_plane
[3] https://www.youtube.com/watch?v=gw-4wltP5tY
[4] https://www.youtube.com/watch?v=7rIFO8hct9g
[5] https://www.youtube.com/watch?v=nKVCvY-FW5Q
[6] https://www.youtube.com/watch?v=bJ56Xr9081k
[7] https://www.youtube.com/watch?v=r5DwyBFxD7Q
[8] https://www.youtube.com/watch?v=Td9CZGkqrSg
[9] https://www.youtube.com/watch?v=SoSTdgqknvY
[10] https://www.youtube.com/watch?v=LpardiBTAvU
Links
[11] https://www.youtube.com/watch?v=FlLbI7DB0SM
[12] https://www.youtube.com/watch?v=nZ2mS5M4fcQ
[13] (textbook) Chapter 4, Computer Graphics using OpenGL (2nd edition)
by Francis S Hill, Jr.