Professional Documents
Culture Documents
Ciencia de la Computación
ICC Fase 1
Computer graphics
Mathematical Foundations
1 Vectors
Definition
Dot product
Cross product
vmachacaa@unsa.edu.pe
Table of Contents
1 Vectors
Definition
Dot product
Cross product
vmachacaa@unsa.edu.pe
Vectors
Vectors specify a magnitude and direction. In 3D graphics,
vectors are represented as a point in space. The vector is the
distance and direction from the origin to that point.
vmachacaa@unsa.edu.pe
Vectors
Vector V (shown in red) can be specified either as the difference
between points P1 and P2, or as an equivalent distance from
the origin to P3. In all of our applications, we specify V as
simply (x,y,z)
vmachacaa@unsa.edu.pe
vector operations
~ = lenght of A
where |A| ~
vmachacaa@unsa.edu.pe
vector operations
Dot Product
vmachacaa@unsa.edu.pe
vector operations
Dot Product
~ •B
A ~ = ux + vy + wz
Cross Product
vmachacaa@unsa.edu.pe
vector operations
Dot Product
~ •B
A ~ = ux + vy + wz
Cross Product
~ ×B
A ~ = (vz − wy , wx − uz, uy − vx)
glm: cross(vec3,vec3)
vmachacaa@unsa.edu.pe
GLSL: cross(vec3,vec3)
Table of Contents
1 Vectors
Definition
Dot product
Cross product
Dot product
Explanation
V~ •W ~
cos(θ) =
~ | ∗ |W
|V ~|
~ and W
Therefore, if V ~ are
normalized (i.e., of unit length,
here we use the notation for
~ •W
V ~ = |V
~ | ∗ |W
~ | ∗ cos(θ) normalization: V̂ and Ŵ . then:
cos(θ) = V̂ • Ŵ
θ = arcos(V̂ • Ŵ )
Dot product
Application
Uses Formula
Vector magnitude
Dot product
Application
Uses Formula
p
Vector magnitude ~ •W
V ~
~ •W
Two vectors are parallel but pointing in V ~ = −|V
~ | ∗ |W
~|
opposite direction if ?
Table of Contents
1 Vectors
Definition
Dot product
Cross product
Cross product
Explanation
~ ×W
V ~ = |V
~ | ∗ |W
~ | ∗ sin(θ) ∗ n
~
θ is the angle between V
and W ~
n is a unit vector
perpendicular to V ~ and W
~
~ is perpendicular (normal) to
R Moreover,
~ and W
V ~ , with a direction
given by the right-hand rule. ~ ×W
V ~ = −(W
~ ×V
~)
Cross product
Explanation
~ =V
P ~2 − V
~1
~ ~ ~1
Q = V3 − V
Figure: Computing outward ~ ~
N =P ×Q ~
normals.
References I
Questions?