Title: Mathematics for Computer Graphics
1Mathematics for Computer Graphics
- Computer Graphics Algorithms make use of many
mathematical concepts and techniques. - Coordinate Reference Frames
- Graphics packages typically require that
coordinate parameters be specified with respect
to Cartesian reference frames. But in many
applications, non-Cartesian coordiante systems
are useful Spherical, Cylindriacl and others.
2- We must convert any non-Cartesian description to
Cartesian coordinates. - The most common two orientations for a Cartesian
screen are
(0,0)
x
y
y
x
(0,0)
The origin in the lower-left corner of the screen.
The origin at the upper-left corner of the screen.
It is possible in some graphics packages to
select a position, such as the center of the
screen, for the coordinate origin.
3- (2) Polar Coordinates in the xy Plane
- The coordinate position is specified with a
radial distance r from the coordinate origin, and
an angular displacement ? from the horizontal. - Positive angular displacements are
counterclockwise, and negative angular
displacements are clockwise.
r
?
4- Angle ? can be measured in degrees, with one
complete counterclockwise revolution about the
origin as 360o. - The relation between Cartesian and polar
coordinates is shown here
5- Using the definition of the trigonometric
functions, we transform from polar coordinates to
Cartesian coordinates with the expressions - x r cos ? y r sin ?
- The inverse transformation from Cartesian to
polar coordinates is
P
y
r
?
O
x
6- Example
- ? 60, r 32
- --gt x r cos ? 32 0.5 16
- y r sin ? 32 0.866 27.712
- Example
- x 60, y 24
- --gt r sqr(602 242) sqr(4176) 64.621
- ? tan-1(24/60) tan-1(0.4) 21.8o
7- Angular values can be specified in degree or they
can be given in dimensionless units (radians), ?
s / r, where s is the length of the circular
arc subtending ?, and r is the radius of the
circle. - Total angular distance around point P is the
length of the circle perimeter 2?r/r 2?.
s
?
r
P
8- (3) Three Dimensional Cartesian Reference Frames
- Most computer graphics packages use the right
handed Cartesian Coordinates, in which the right
hand thumb points in the positive z direction.
y axis
P
x axis
z axis
9(4) Points and Vectors
- A point is a position specified with coordinate
values in some reference frame, so that the
distance from the origin depends on the choice of
reference frame. - Here we have coordinate specification in two
reference frames. In frame A, point coordinates
are given by the values of the ordered pair
(x,y). If frame B, the same point has coordinate
(0,0) and the distance to the origin of frame B
is 0.
P
Frame B
y
OB
x
OA
Frame A
10- A vector is defined as the difference between two
points positions.
P2
y2
V
y1
P1
x1
x2
V P2 - P1 (x2 - x1, y2 - y1) (Vx,
Vy) Where Vx and Vy are the projections of the x
and y axes.
11- The vector magnitude can be calculated using
Pythagorean theorem - The direction of the vector can be given in terms
of the angular displacement from the x axis as - A vector has the same properties (magnitude and
direction) no matter where we position the
vector. - The vector magnitude is independent of the
coordinate system.
12Example P1 (5,2) , P2 (8,4) --gt V
(3,2) V sqr(32 22) 3.605 ? tan-1(2/3)
33.69o
13- If we change the coordinate representation, the
values for the vector components change. - For a three-dimensional Cartesian space, we
calculate the vector magnitude as - Vector direction is given with the direction
angles, ?, ?, ?, that the vector makes with each
of the coordinate axes.
x
V
?
?
y
?
z
14- Direction angles are the positive angles that the
vector makes with each of the positive coordinate
axes. We calculate these angles as - These three values are called the direction
cosines of the vector. - One property of them is
- cos2? cos2? cos2? 1
- By definition, the sum of two vectors is obtained
by adding corresponding components - V1V2 (V1xV2x, V1yV2y, V1zV2z)
15- Example
- A vector in the three dimensional space, P1
(3,4,2) , P2 (9,12,16) - Vx(9-3)6, Vy(12-4)8, Vz (16-2) 14
- --gt V sqr(6282142) sqr(3664196)sqr(296)
17.2 - cos ? Vx/V 6/17.2 0.348 cos2?
cos2? cos2? ? - --gt ? cos-1(0.348) 69.583
(.348)2(.465)2(.813)2.998 - cos ? Vy/V 8/17.2 0.465
- --gt ? cos-1(0.465) 62.282
- cos ? Vx/V 14/17.2 0.813
- --gt ? cos-1(0.813) 35.515
16- Two vectors can be added geometrically by
positioning the two vectors end to end and
drawing the resultant vector from the start of
the first one to the tip of the second one. - Scalar multiplication of a three-dimensional
vector is defined as - aV (aVx , aVy, aVz)
- There is no addition of vectors and scalars.
y
V2
y
V1 V2
V2
V1
V1
x
x
17- Examples
- V1 (4,7,-2), V2 (3,-3,8)
- Addition
- V1 V2 (7,4,6)
- Scalar Product
- 4V1 (16,28,-8)
- Dot Product
18- There are two types of vector multiplication
- (Dot product) Vector multiplication for producing
a scalar is defined as - V1 . V2 V1 V2 cos ?, 0 ? ? ? ?
- where ? is the angle between the two vectors.
- In addition to the coordinate-independent
- form of the scalar product, we can
- express this product in specific
- coordinate representation
- V1 . V2 V1xV2x V1yV2y V1zV2z
V1
V2
?
V2 cos ?
19- The dot product of a vector with itself is simply
another statement of the Pythagorean theorem. - The scalar product of two vectors is zero if and
only if they are perpendicular. - Dot products are commutative
- V1.V2 V2.V1
- Dot products are distributive with respect to
vector addition - V1 . (V2 V3 ) V1 . V2 V1 . V3
20- (Cross Product) Vector multiplication for
producing a non scalar is defined as - V1 ? V2 u V1 V2 sin ?, 0 ? ? ? ?
- where u is a unit vector (its magnitude is 1)
that is perpendicular to both V1 and V2. The
direction of u is determined by the right hand
rule. - The cross product of two
- vectors is a vector that is
- perpendicular to the plane
- of the two vectors and with
- magnitude equal to the area
- of the parallelogram formed
- by the two vectors.
V1 ? V2
V2
?
V1
21- We can also express the cross product in terms of
vector components in a specific reference frame,
in the Cartesian coordinate system we calculate
the components of the cross product as - V1 ? V2 (V1yV2z - V1zV2y , V1zV2x - V1xV2z ,
V1xV2y - V1yV2x) - The cross product of any two parallel vectors is
zero. - The cross product of a vector with itself is
zero. - The cross product is not commutative but
anticommutative - V1 ? V2 - (V2 ? V1 )
22- The cross product is not associative
- V1 ? (V2 ? V3 ) ? (V1 ? V2 ) ? V3
- The cross product is distributive with respect to
vector addition - V1 ? (V2 V3 ) (V1 ? V2 ) (V1 ? V3 )
23(5) Matrices
- A matrix is a rectangular array of quantities
(numbers, functions or numerical expressions). - We identify matrices according to the number of
rows and number of columns. - To multiply a matrix A by a scalar value s, we
multiply each element ajk by the scalar. - Matrix addition is defined only for matrices that
have the same size, by adding corresponding
elements.
24- We can multiply an mn A matrix by an np B
matrix to form the matrix product np AB. We then
obtain the product matrix by forming sums of the
products of the elements in the row vectors of A
with the corresponding elements in the column
vectors of B. - AB ? BA because
-
while