11 geometry

Upload: parulitiec

Post on 30-May-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 11 Geometry

    1/34

    Geris Game Pixar.The Lord of the Rings New Line Productions, Inc.Finding Nemo Disney/Pixar.

  • 8/14/2019 11 Geometry

    2/34

    This Sections Objectives

    Define the basic elements of geometry

    Scalars

    Vectors

    Develop mathematical operations among them in acoordinate-freemanner

    e ne as c grap cs pr m ves Line segments

    Polygons

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    3/34

    Basic Elements

    Geometry is the study of the relationshipsamong o ects n an n- mens ona space we are interested in objects that exist in (at most) 3D

    We want a minimum set of primitives from which

    we can build more sophisticated objects

    We will need three basic elements Scalars

    Vectors

    Points

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    4/34

    Coordinate-Free Geometry

    When we learned simple geometry, most of us

    started with a Cartesian approach Points were at locations in space P=(x,y,z)

    involving these coordinates

    Most geometric results are independent of the

    coordinate system

    corresponding sides and the angle between them are

    identical

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    5/34

    Scalars

    Scalars are members of sets that can be combinedy a on an mu p ca on o ey ng some

    fundamental axioms

    a ociati it : x * * z = x * * z

    commutativity : x + y = y + x

    distributivity : x * (y + z) = (x * y) + (x * z) : - =

    multiplicative inverse : x * (1/x) = 1

    Scalars alone have no geometric properties

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    6/34

    Vectors

    A vector is an object with two attributes

    Direction Magnitude

    Examples include v Force

    Velocity

    rec e ne segmen s Most important example for graphics

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    7/34

    Vector Operations

    Every vector has an inverse

    Same magnitude but points in opposite direction

    Every vector can be multiplied by a scalar

    There is a zero vector

    Zero magnitude, undefined orientation

    The sum of any two vectors is a vector

    v -v 0.7v v w

    CSCI 3161- Com uter Animation

    u

  • 8/14/2019 11 Geometry

    8/34

    Linear Vector Spaces

    Mathematical system for manipulating vectors

    Operations Scalar-vector multiplication : u = v - w u v

    Expressions such as v=u+2w-3rmake sense in a vector space

    Magnitude of a vector

    Calculate length with Pythagorean theorem

    Normalizing a vector

    Form a unit vector

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    9/34

    Linear Combinations & Independence

    A linear combination of n vectors u1, u2,,un is the

    u = 1u1 + 2u2 ++ nun

    If the only set of scalars that produces

    1 1 2 2 n n

    is

    1 = 2 == n =

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    10/34

    Basis Vectors & Representation

    If a vector space has dimension n, any set of n linearly

    If u1, u2,,un is a basis for vector space, V, any vector vcan

    vectors:

    v = u + u ++ u

    The scalars i give the representation ofv with respect to the basisu , u ,,u :

    [ ]

    =Tn

    M

    K2

    1

    21

    CSCI 3161- Com uter Animation

    n

  • 8/14/2019 11 Geometry

    11/34

    Inner (Dot) Product

    The inner (dot) product between vectors uand vin an-

    n

    ii vu )*(

    if , then u and v are orthogonal (rightangles in 2D)

    =i 1

    0= vu

    length of vector uis: uuu =

    can use the dot product to define the angle ( )between two vectors:

    CSCI 3161- Com uter Animation

    cosvuvu =

  • 8/14/2019 11 Geometry

    12/34

    Projections of Vectors

    The dot product can also be used to project vector

    A onto vector B, yielding a new vector C

    where

    BB

    is the unit vector of BBu

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    13/34

    Projecting Vector A on Vector B

    #include #include

    .

    // a point data type

    t edef GLfloat oint2[2];

    // the vectors

    point2 vectorA = {0.0, 0.0};

    point2 vectorB = {0.0, 0.0};point2 vectorC = {0.0, 0.0};

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    14/34

    Projecting Vector A on Vector B

    void initializeGL(void)

    {

    // enter GL_PROJECTION mode

    glMatrixMode(GL_PROJECTION);

    c ear e pro ec on ma r x

    glLoadIdentity();

    gluOrtho2D(-1.0, 1.0, -1.0, 1.0);

    setu the vectors

    setupVectors();

    }

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    15/34

    Projecting Vector A on Vector B

    void myDisplay(void)

    {

    glClear(GL_COLOR_BUFFER_BIT);

    glBegin(GL_LINES); // draw the lines

    // draw vector A red

    glColor3f( , 0, 0);

    glVertex2f(0, 0);

    glVertex2fv(vectorA);

    draw vector B green

    // draw vector C blue

    glEnd();

    CSCI 3161- Com uter Animation

    g F us ;

    }

  • 8/14/2019 11 Geometry

    16/34

    Example projectVector.c

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    17/34

    Vectors Lack Position

    These vectors are identical: Same length and magnitude

    Vectors s aces are insufficient for constructin

    geometric objects We need points too

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    18/34

    Points

    Location in space

    perat ons a owe etween po nts an

    vectors

    o n -po n su rac on y e s a vec or

    Point-vector addition yields a point

    v= P-Qv

    P = v+Q

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    19/34

    Affine Spaces

    Point + a vector space

    O erations

    Vector-vector addition

    Scalar-vector multiplication Scalar-scalar operations

    Point-vector addition Point-Point subtraction

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    20/34

    Lines

    Consider all points of the form: P()=P0 + v

    Set of all points that pass through P0 in thedirection of the vector v or -v

    P()

    v

    P0P(-)

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    21/34

    Rays

    For 0, P() is the rayleaving P in

    the direction v :

    P()

    v

    P0

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    22/34

    Line Segments

    For 0 1 we get all the points on the

    line segmentjoining P0 and P(1.0) :

    .

    v

    P0

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    23/34

    Parametric Lines - Interpolation

    Nice since it extends to curves and

    surfaces Forms

    Explicit:

    y = mx + h Parametric:

    x() = x0 + (1-)x1P1= (x1, y1)

    0 - 1P0= (x0, y0)

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    24/34

    Convexity

    An object is convexiff:

    for any two points in the object all points on the line

    segment between these points are also in the object

    P

    P

    Q

    -

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    25/34

    Triangles

    3 sided polygon

    Can be defined by:

    3 points

    2 points and 2 angles

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    26/34

    Triangles Bi-linear Interpolation

    interpolation of

    P and Q

    CSCI 3161- Com uter Animation

    ,

  • 8/14/2019 11 Geometry

    27/34

    Triangles Bi-linear Interpolation

    interpolation of

    ,

    CSCI 3161- Com uter Animation

    ,

  • 8/14/2019 11 Geometry

    28/34

    Polygons

    Definition: a closed plane figure bounded by

    straight sides

    Can always be broken up into triangles

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    29/34

    Polygons

    Special names of common polygons:

    triangle A polygon with three sides

    quadrilateral A polygon with four sides

    pentagon A polygon with five sideshexagon A polygon with six sides

    heptagon A polygon with seven sides

    oc agon po ygon w e g s esn-gon A polygon with n sides

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    30/34

    Planes in 3D

    A plane can be determined by:

    a point (R) and two vectors (mand n)

    m

    Rn

    CSCI 3161- Com uter Animation

    , = + m + n

  • 8/14/2019 11 Geometry

    31/34

    Planes in 3D

    Or equivalently by:

    three points (m= P-R and n= Q-R)

    P

    R Q

    CSCI 3161- Com uter Animation

    P(, ) = R + - + -

  • 8/14/2019 11 Geometry

    32/34

    Normals

    Every plane has a vector normal n(perpendicular) to it

    we can use the cross product to find n

    n

    u

    v

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    33/34

    The Cross Product

    To compute the cross product between 3D vectors

    uand v:

    xyyxzxxzyzzy vuvuvuvuvuvuvu = ,,

    n

    u

    v

    CSCI 3161- Com uter Animation

  • 8/14/2019 11 Geometry

    34/34

    Questions

    CSCI 3161- Com uter Animation