# Vectors

Document Sample

```					2. Modelling Geometry
Modelling

   Generic definition – Model: an abstract or actual representation of
system or an object.

   Models in Computer Graphics deal with data that eventually leads to
graphical output (images + animation + video)
Lecture Summary

   How basic geometry is stored

   Vectors
 Some fundamental operations

   Geometric Primitives:
 Points, Lines, Curves, Polygons

   Vector vs Raster data
Modelling spectrum
Each stage has it’s own unique type
   3D Modelling             of data and can accept user input.
The more abstract the representation
   2D Modelling             then (arguably) the better our
opportunities for re-usability and
data/computational efficiency.
   Painting / drawing

r
Modelling vs. Painting
   Models are usually:              Images:
 More abstract                    Low level
 More compact                     Resolution bound
 Reusable                         Less re-usable
 Modifiable                       More limited in how we can
change them
   Models need to be
rasterized/processed before
drawing
Modelling Issues

   A few questions that should concern us about models:

   Where do models come from?

   How are models stored?

   How are models modified?

   How are models rendered?
Modelling
   Model Acquisition/ Creation      Model Manipulation

Automatic
   Image/3D Scanners               Transformation /
deformation operations
   3D Model-extraction
 from images                  Procedural animation
 from video

   Mechanical Digitizers           Modelling Tools

Manual
   Modelling Tools

   From scratch                    User manipulation
3D Scanning
3D mechanical digitizers
   Co-ordinate measurement machine
(CMM) record 3D points

   Similar to “tracing” in 3D

Ghost 3D Microscribe

Ghost 3D Microscribe Laser
The building blocks of a model

   Geometry is often represented in terms of very basic numerical data

   Scalars: single values

   Vectors: a couple or triple (or n-tuple) containing scalars – the number
of scalars is the dimensionality.
 Vectors usually denote a value and a direction.

   In Graphics, more complex geometry e.g. Curves and Surfaces can also be
defined based on scalars and vectors
Cartesian Coordinates

10     (10, 12)

12

Rene Descartes - 1637
Cartesian Coordinates
   Two distances used to
denote unique
13     (13, 15)       position in 2D

15
Cartesian Coordinates
   Two distances used to
denote unique
(13, 15)       position in 2D
   We can also represent
a line with two
endpoints, each
(10, 12)                  donated by vector.
Cartesian Coordinates
   Two distances used to
denote unique
(13, 15)       position in 2D
   We can also represent
a line with two
(+3, +3)
endpoints, each
(10, 12)                    donated by a vector.
   Finally we can denote
translation (or
change in position)
with two values.
Vector
   A quantity characterized by a magnitude and direction
   Can be represented by an arrow, where magnitude is the length of
the arrow and the direction is given by slope of the line

Y

 2                                       2
v 
v  2
Y
1
 
2
 
1
X
2
X
2
2
Z           2

A vector in 2D                         A vector in 3D
Examples in 2D

0                 1
"up"          "right"                        1
1                 0   " north  east"   
1

2                       4
1                       2
                         
Conventions

   Vector quantities denoted as v or    v

   We will use column format vectors:

 v1 
v  v2   v1 v2 v3 
 
 v 1   v2 v3 
T

 v3 
 
In code, we may have to revert to { v1, v2, v3 }

   Each vector is defined with respect to a set of basis vectors (which
define a co-ordinate system).
Row vs. Column Formats
   Both formats, though appearing equivalent, are in fact
fundamentally different:
 be wary of different formats used in textbooks

column format         row format

a b c  u             a d             g
d e f   v   u v w b e             h
                                      
 g h i  w
                     c f
                i

Mv  vT MT
transposed
Co-ordinate Systems

   By convention we usually employ a Cartesian basis:
 basis vectors are mutually orthogonal and unit length
 basis vectors named x, y and z

   We need to define the relationship between the 3 vectors: there are 2
possibilities:
 right handed systems: z comes out of page
 left handed systems: z goes into page

   This affects direction of rotations and specification of normal
vectors
3D Cartesian co-ordinates

0.5  0.5 
v  0.7   0.7 
           
0.5  0.5
           
RHS      LHS
    Addition of vectors follows the parallelogram law in 2D and the
parallelepiped law in higher dimensions:

1   4   5 
 2    5   7 
     
 3   6  9 
     
u       v     u v

u
OR

u

0      2
u    v 
1     1
Vector Multiplication by a Scalar
   Multiplication by a scalar scales the vectors length appropriately
(but does not affect direction):

2 1.5  2  3 
1.5           1.5                       2  4
1 1.5 1  
2  3  6 
   
 2  4
   
Subtraction

-v

u

-v

Can be seen as an addition of
u + (-1v)

1   5    4 
 4   2   2                     -v
     
u     v      u v
u
Vector Magnitude
   The magnitude or “norm” of a vector of dimension n is given by the
standard Euclidean distance metric:

v  v12  v 2    v 2
2         n

2D example                               3D example
3
1
v  3
 
4      3                                1
 
v 
 4
1
v  3  12  32  12  11
3                                             2
1
v         3  4  25  5
2       2

4
Vectors for direction
   Vectors represent

   a direction
   and a magnitude

   Can be used for representing   Describing velocity (direction and
e.g.                           speed) of roller coaster and ball at
different points in time

   Position
   Velocity
   Forces / impulses
Other Vectors

LIFT

DRAG
Mesh Normals

GRAVITY            THRUST

The forces of flight.
Vertices/Points
vx   vx 
v  P 
   Vectors can however                         v y  v y 
communicate a position –
referred to as a point or vertex
both vectors equal

   A vertex is actually represented
by its displacement from the
origin { 0, 0, 0 }

With the origin O, we can use this to
represent a unique position in space.
Unit Vectors
   Vectors of length 1 are often termed unit vectors (a.k.a. normalised
vectors).
   When we only wish to describe direction we use normalised vectors
– often to avoid redundancy
   For this and other reasons, we often need to normalise a vector:

v             1
v
ˆ                           v
   e.g.              v   v12  v 2    v 2
2         n

   1 
   11  .3015
1                      1              
v  1   1    1         3  
v          v  3   v
ˆ       v    3                 .9045
ˆ
       v  11   11     11     11          
v              1
                       1
            1  .3015
     
      
   11 
Dot Product
   Dot product (inner product) is defined as:         u  v   ui vi
i

 u1   v1 
 u1   v1 
u  v       u1v1  u2v2       u  v  u2  v2   u1v1  u2v2  u3v3
  
u2  v2                          u3  v3 
  
   Note:
 Therefore we can redefine magnitude in terms of the dot-product
operator:

u  uu
2
uu  u  u  u  u
2
1
2
2
2
3

   The dot product operator is commutative and associative.
Dot Product
   The Dot Product can also be obtained from the following equation:

u  v  u v cosq
where q is the angle between the two vectors              q
u

   So, if we know the vectors u and v, then the dot product is useful for
finding the angle between two vectors.
 uv 
u  v  u v cosq          q  cos 
1


 u v
   Note that if we had already normalised the vectors u and v then it
would simply be:
q  cos 1 u  v 
ˆ ˆ
Dot Product
   If both vectors are normal, the dot product defines the cosine of
the angle between the vectors:

u  v  cosq

In general:

u  v  u v cosq
 uv 
 q  cos     1

u v
     

if q > 90 then the dot product is negative.
Dot Product Examples

   Find the angle between vectors { 1, 1, 0} and {0, 1, 0}?
Cross Product
   Used for defining orientation and constructing co-ordinate axes.
   Cross product defined as:
 u1   v1  u2v3  u3v2 
u  v  u2   v2    u3v1  u1v3 
                         
u3   v3   u1v2  u2v1 
                         

   The result is a vector, perpendicular to the plane defined by u and v:

u  v  w u v sinq
Cross Product

Right Handed Coordinate System
Cross Product
   Cross product is anti-commutative:       u  v  v  u 

   It is not associative:   u  v  w   u  v   w

   Direction of resulting vector defined by operand order:

R.H.S.
Cross Product Examples

   Find the line that is orthogonal to a polygon defined by the vertices
{ 1, 1, 0} {0, -1, 0} and {-2, 0, 0}.

   If a person stands upright (direction {0, 1, 0}) at the origin {0, 0, 0},
facing a direction { 1, 0, 1 },
 Then what vector describes the direction that the person
considers “LEFT”?
Describing a Line

   Line Segment: Start and                         END

Endpoint

   START at { 0, 0 }
   END at { 200, 160 }         START

   Ray: Start, Direction, Length

   START at { 0, 0 }                   angle

   Turn 115° from due north    START

   Move forward by 160
Representing objects with lines
on the surface of an object
 Defined as displacement
vectors { x, y, z } from the
origin

   Edges are line segments on
the surface, defined by pairs of
points.

   Closed polygons are made up
of a number of co-planar
edges.
Surface Representations
   Polygon Mesh a.k.a. Wire frame
Curves and Splines
   A larege number of smooth curves can be defined by mathematical
functions. However finding a mathematical function that defines
every real-world object is difficult

y  ax 2               x2  y2  r 2                     ???

   Splines are curves fitted to a set of control points, and are useful for
more generic modelling
   Valid in 2D and 3D
Modelling Techniques
x2  y2  z2  r2

Implicit
Polygonal   3D Modelling
x  sin 4q
y  cos 2q

Volumetric
Parametric
Modelling 3D Shape
   Boundary Representation – Surface Models
vs
   Spatial Partitioning – Volume Models

   Mathematical Models
vs
   Discrete Models
Volumetric Modules

Constructive Solid Geometry
Volumetric Models

Voxels (Volume elements/Volumetric pixels)
Mathematical Models

x2  y2  z2  r2

x  sin 4t
y  cos 2t

Parametric                Implicit
Polygon Mesh

   This is the basis for modelling a large range of complex shapes in 3D
applications
Discretization
300 polygons
48 polygons         120 polygons                             1000 polygons

In most cases, mathematical models need to be converted to discrete representations
before we use them in scenes. We need to find an appropriate resolution for this.

   Sometimes the trick is to use
larger polygons in flat areas
and a greater number of small
polygons in areas of fine detail

   Alternatively more detail in
silhouette areas

```
DOCUMENT INFO
Shared By:
Categories:
Stats:
 views: 13 posted: 1/26/2011 language: English pages: 51
Description: computer graphics and its applicationa
About if any file u wil find copyright contact me it will be remove in 3 to 4 buisnees days. add me on sanjaydudeja007@gmail.com or visit http://www.ohotech.com/