comp3320 lect 01 pipeline1

Upload: mrzaggy

Post on 02-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    1/46

    SCHOOL of ELECTRICAL ENGINEERING & COMPUTER SCIENCEFACULTY of ENGINEERING & BUILT ENVIRONMENT

    The UNIVERSITY of NEWCASTLE

    Comp3320/6370 Computer Graphics

    Course coordinator: Dr Joe Ryan

    Semester 2, 2012

    1

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    2/46

    LECTURE 1

    Fundaments ofthe Computer Graphics PipelineVersion 1.2

    July 25, 2012

    2

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    3/46

    OVERVIEW

    Geometrical Background 6

    Some Typical Maths Topics In Computer Graphics 8

    Some Basic Algebraic Concepts 9Notes about Vector Spaces . . . . . . . . . . . . . . . . 12

    Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Subspaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Example subspace . . . . . . . . . . . . . . . . . . . . . . 16

    Basis of a vector space . . . . . . . . . . . . . . . . . . . 18Linear Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Equations for Lines in 2D-Space [with (x,y)-coordinates] 20

    Geometrical Definitions 22

    3

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    4/46

    The Computer Graphics Rendering Pipeline 23Virtual Camera and View Frustum . . . . . . . . . . . 24The Three Conceptual Stages . . . . . . . . . . . . . . 25

    The Application Stage 27

    The Geometry Stage 28Model and View Transform . . . . . . . . . . . . . . . . 29Lighting and Shading . . . . . . . . . . . . . . . . . . . . 31Lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32Projection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Orthographic and Perspective Projections . . . . . 34

    Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Screen Mapping . . . . . . . . . . . . . . . . . . . . . . . . 37Screen Mapping Process . . . . . . . . . . . . . . . . . . 38

    4

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    5/46

    Summary of the Geometry Stage 39

    The Rasteriser Stage 40

    Buffers, Visibility . . . . . . . . . . . . . . . . . . . . . . . 41Texturing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    Summary of the Pipeline 43

    Exercise 1 44

    Exercise 2 45

    Exercise 3 46

    5

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    6/46

    Geometrical Background

    In Computer Graphics we typically work with objects that live

    in a three-dimensional world. The aim is to draw them in twodimensions on the screen.

    Special cases are 2-dimensional objects and worlds.

    Using dimensionality reduction we can also attempt to under-

    stand 4D or higher dimensional objects and worlds.

    Some elementary maths can help us to make some of thecalculations required in computer graphics simpler, clearer andmuch faster.

    Linear algebra covers properties of vectors and matrices re-quired for displaying and modifying 3D objects in 3D space.

    Basic differential geometry helps to deal with non-linear curvesand surfaces.

    6

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    7/46

    Notation

    R, R+, Rn real numbers, reals greater than 0, n-tuples of realsN natural numbers: {0, 1, 2,...}Z integer numbers: {..., 1, 0, 1, 2,...}Q rational numbers, i.e fractionsC complex numbersH Hamiltonian quaternions

    {...; ...} set of ... such that ...(a , b) open interval of reals between a and b[a , b] closed interval of reals between a and b

    (a , b], [a , b) half-open intervals of reals between a and bV,W,U vector spacesv, w vectors

    v w = v, w dot product of two vectors0, 0V zero vector, zero vector of V

    7

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    8/46

    Some Typical Maths Topics In Computer Graphics

    Some topics which can be relevant for Computer Graphics

    Vector spaces, vectors, points

    Points, lines, planes, 3-space, ...

    Systems of linear equations

    Dot product, cross product Curves, surfaces, manifolds

    Matrices, transformations

    Triangulations, splines

    Complex numbers, quaternions

    More ..

    8

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    9/46

    Some Basic Algebraic Concepts

    Please try to look up the definitions of the mathematical structures

    below in an Algebra book in the library or on-line (e.g. [?] or [?]).

    sets

    monoids and semi-groups

    groups rings

    fields

    division rings, division algebras

    modules

    vector spaces

    9

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    10/46

    DEF. An abelian group is a set, V, together with an operation that combines any two elements a and b to form another elementdenoted a b. The following axioms have to be satisfied:

    Closure For all u, v V we have u v V.

    Associativity For all u, v, w V we have(u v) w = u (v w).

    Identity element There exists a identity element Id V suchthat v Id = Id v = v for all v V

    Inverse element For each v A there exists an inverse w Vsuch that w v = v w = Id.

    Commutativity For all u, v A we have v w = w vNote: The operation could be replaced by + or anythingsimilar that satisfies the axioms above.

    10

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    11/46

    DEF. By a vector space over the real numbers R we shall mean aset V along with two operations + and such that ifv, w Vthen v + w V and ifr R and v V then each scalar multipler v ofv is in V and the following five properties are satisfied:

    VS 1. For all u, v, w V we have associativity, namely(u + v) + w = u + (v + w).

    VS 2. There exists a zero vector 0 V such thatv + 0 = 0 + v = v for all v V

    VS 3. For each v V there exists an additive inverse w Vsuch that w + v = v + w = 0.

    VS 4. For all u, v V we have v + w = w + v

    VS 5. If r, s R are scalars and v, w V then 1 v = v and

    (r + s) v = r v + s v

    r (v + w) = r v + r w

    (rs) v = r (s v) 11

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    12/46

    Notes about Vector Spaces

    VS 14 say that V is an abelian group under vector addition.

    The additive inverse w in VS 3 is uniquely determined andusually denoted by v.

    For all r R and for all v V

    r 0 = 0 v = 0 and (r v) = (r) v = r (v)

    12

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    13/46

    Terminology

    The elements of a vector space V are called vectors.

    To determine if a set V is a vector space one must specify theset V, and define vector addition and scalar multiplication in V.Then if V satisfies the properties VS 15 it is a vector spaceover the real numbers R.

    A vector space over the set of real numbers R, is called a realvector space.

    Instead of using real numbers R any field can be employed suchas the complex numbers C. A vector space over the set of

    complex numbersC

    , is called a complex vector space.

    13

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    14/46

    Examples

    1. Let V = Rn be the set of n-tuples of real numbers. If

    x = (x1, x2,...,xn) and y = (y1, y2,...,yn) are two suchn-tuples, define

    x + y = (x1 + y1, x2 + y2,..., xn + yn)

    and if a R, define

    a x = (ax1, ax2,..., axn)

    (Verify the vectorspace axioms.)

    2. Let V be the set of all real valued functions on a non-empty setS. If f, g are functions, we can define f + g in the usual way,and af in the usual way.

    3. Let V = M(n n, R) be the set of all n nMatrices withreal elements. Then V together with component-wise additionand component-wise multiplication with a scalar a R is a

    vector space over R. 14

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    15/46

    Subspaces

    Given a vector space V over R, a subspace of V is any nonempty

    subset W of V with1. 0 W and

    2. W is closed under addition (i.e., if x,y, W then x + y W)and

    3. W is closed under scalar multiplication (i.e., if x W anda R the ax W)

    It is easy to see that subspaces of V are vector spaces (over thesame field) in their own right.

    15

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    16/46

    Example subspace

    1. Let V be a vector space over R, and let v1, v2,...,vr V. The

    subset of all linear combinationsx1v1 + ... + xrvr, with xi R

    is a subspace (verify !). It is called the subspace generated byv1, v2,...,vr.

    2. Let n > 1 and let j be a fixed integer, 1 j n. Let V = Rn

    and let W be the set of all n-tuples in Rn whose j-thcomponent is zero, i. e. xj = 0. Then W is a subspace which is

    sometimes identified with Rn1 because it essentially consists

    of (n 1)-tuples.

    16

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    17/46

    DEF. A norm on a vector space V over the real numbers R is afunction . : V R, v v such that following threeproperties are satisfied:

    N1. For all v V v = 0 v = 0.

    N2. For all v V, R v = ||v.

    N3. For all v, w V v + w v + w (triangle inequality).

    Examples

    v1 =n

    i=1 |vi| (Manhattan norm or 1-norm)

    v2 = ni=1 v

    2i (Euclidean norm or 2-norm)

    vp = (n

    i=1 |vi|p)

    1p , where p 1 is a real number (p-norm)

    v = max(|v1|, ..., |vn|) (maximum norm)

    Note. v

    v

    = 117

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    18/46

    Basis of a vector space

    DEF. The intersection of all subspaces of a vector space V

    containing a given set of vectors is called their span. The set ofvectors is called linearly independent if no vector can be removedwithout diminishing the span. A linearly independent set whosespan is the whole vector space V is called a basis of V.

    Note. It can be shown that every vector space has a basis, andvector spaces over a given field are fixed up to isomorphism by asingle cardinal number (called the dimension of the vector space)representing the size of the basis. For instance the real vectorspaces are just R0, R1, R2, R3, ..., R.

    18

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    19/46

    Linear Maps

    DEF. Let V and W be two Rvector spaces. A linear map from

    V to W is a map V W which preserves the vector spacestructure, i.e. it preserves sums of vectors and products of scalarswith vectors.

    The set of all linear maps from V to W is denoted L(V, W). It is

    a Rvector space. Given the bases of both vector spaces V andW, elements of L(V, W) can be identified with matrices.

    An isomorphism is a linear map that is one-to-one(monomorphism) and onto (epimorphism). Two vector spaces V

    and W are called isomorphic if and only if there exists anisomorphism between them.

    19

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    20/46

    Equations for Lines in 2D-Space [with (x,y)-coordinates]

    Basic form: y = mx + b (m = slope, b = section on y-axis)

    Point & direction form: y p2 = m(x p1)

    Parametric vector form: (x(t), y(t)) = p + tv =

    p1 + tv1p2 + tv2

    (through point p = (p1, p2) in direction of vector v = (v1, v2))

    Two-Point form: yp2q2p2 = xp1q1p1, through points p and q.

    Implicit form: ax + by + c = 0 (a,b,c are real constants).

    Axis section form: xpx +y

    qy= 1

    (line through points p = (px, 0) and q = (0, qy))

    Hessian Normal Form (HNF): x cos + y sin d = 0(d = closest distance from origin, = angle between normaland x-axis)

    20

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    21/46

    Some literature and sources

    This lecture uses a number of texts as sources, including:

    [?], [?], [?], and [?].

    The remaining slides and pictures are mostly based on the book:Tomas Akenine-Moller and Eric Haines and Natty Hoffman,Real-Time Rendering, 3rd Edition, 2008, isbn 987-1-56881-424-7,

    A. K. Peters, Ltd., Natick, MA, USA. [?] or [?].For this book there is an excellent support page at:http://www.realtimerendering.com/

    21

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    22/46

    Geometrical Definitions

    Basic rendering primitives used by most graphics hardware:

    points, lines, triangles.

    A model or an object is a collection of geometric entities.

    A scene is a collection of models comprising that everythingthat is included in the environment is rendered. It can include

    material descriptions, lighting, and viewing specifications.

    Examples of objects: A car, a building, a line. Objects canconsist of other objects.

    22

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    23/46

    The Computer Graphics Rendering Pipeline

    Main function of the pipeline: Given a virtual camera, 3D ob-

    jects, light sources, lighting models, textures and other fea-tures generate, or render, a 2D image.

    Locations and shapes of objects in the image depend on: theirgeometry, placement of camera, and characteristics of envi-

    ronment. Appearance of objects depends on: material properties, light

    sources, textures, and lighting models.

    The pipeline has different stages. Some of them are imple-

    mented in hardware. Only primitives inside the view frustum are rendered.

    23

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    24/46

    Virtual Camera and View Frustum

    3$Z 1d y t Y j P $ 8 s s % $ Z s j { s 8 s $ R j B { s I s Y $ } B P Y } k s 8 $ I w b Y P B Z j $ t R { B t % D ! t j k Y } $ 8 $ $ % R $ t R $ I Y % $ b % B j Z 8 s t I I

    3 B s t $ 8 s Y s $ R t I I $ t } R } { $ % w s R $ R Y { s R Y D Y % $ b % B j Z 8 $ R s

    P Z R Z 8 $ s Z t { s I } k s 8 $ I b $ Y s { s t Z j s A s R q Y $ Y $ 8 s R Y B b R b Y s

    Y { s 8 s X R R " W B Y A B B 8 8 B R { Z A $ t Y j P $ 8 s $ R t B $ t Y t I $ t

    B Y $ Y A { s Z R $ $ R j B { s I B Z R $ I Y % $ b P Z R Z 8 V j R B Y $ s t j $ t Y

    j P $ 8 s $ R { j $ } } I s s $ t R Y R 8 s j j w t s D } j s t B P Y P Z R Z 8 b Y $ { Y R Z j R $ t s

    J Z s I $ j s s j

    24

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    25/46

    The Three Conceptual Stages

    There are three conceptual stages:

    1. Application stage: driven by the application and thereforeimplemented in software; it may contain collision detection,animations, acceleration algorithms

    2. Geometry stage: implemented in soft- or hardware; trans-

    forms, projections, lighting, etc.3. Rasteriser stage: draws an image using the data provided by

    the previous stage

    Each of these stages typically is a pipeline in itself, i.e. it consists

    of several substages.

    25

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    26/46

    3$Z 11 q Y A s R $ { { B t R Z { $ B t B P Y t I $ t } $ } j $ t { B t R $ R $ t B P Y R s R Us } } j $ { s $ B t B 8 k s t I Y s R $ 9 e s { Y B P Y R R s R 8 s k A s } $ } j $ t $ t

    $ R j P s R $ j j Z R s I A j B b Y B 8 k R s B s R s 8 s k A w } s j k D } s s j j j $ 9 I s R

    R Y B b t A j B b Y s R $ 9 R s y t Y $ R $ j j Z R s $ B t Y s } } j $ { s $ B t R s $ R s R $ t j

    } B { R R A Z Y $ R R s { B Z j I s j R B A } $ } j $ t I B } s s j j j $ 9 I

    26

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    27/46

    The Application Stage

    It is software based and the developer has full control (The

    other stages are built upon hardware).

    Takes care of inputs from mouse, joystick keyboard, touch-screen, VR helmet, ...

    At the end of the application stage, the geometry (points,

    lines, triangles) is fed into the next stage.

    Typical processes of the application stage:

    Collision detection ; response is fed back into collidingobjects

    Texture animation, animations via transforms, geometrymorphing

    Acceleration algorithms (e.g. hierarchical view frustumculling)

    27

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    28/46

    The Geometry Stage

    It is subdivided in five functional stages:

    3$Z 1nq Y B 8 k R s R Z A I $ % $ I I $ t B s } $ } j $ t B P P Z t { $ B t s j R s R

    28

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    29/46

    Model and View Transform

    Model transform: applied to vertices and normals of the model for positioning and orienting.

    View transform: places camera at origin and aims it in direction of neg. z-axis.

    model transform view transform

    (4 4)-matrix (4 4)-matrix

    model space ; world space ; camera space

    model coordinates world coordinates

    model several instances

    camera neg. zaxis

    29

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    30/46

    3$Z 1;y t Y j P $ j j Z R s $ B t Y { s 8 s $ R j B { s I s t I B $ t I s R Y Z R

    b s t R $ B A q Y % $ b s t R P B 8 j B { s R Y { s 8 s s Y B $ $ t j B B , $ t s j B t Y

    t s $ % F T s - $ R s R R Y B b t B t Y $ Y q Y $ R $ R I B t B 8 s , Y { j $ } } $ t s t I } B ` { $ B t

    B } s $ B t R R $ 8 } j s t I P s R q Y j $ Y s k s s $ R Y % $ b % B j Z 8 < } R } { $ %

    % $ b $ t $ R s R R Z 8 I R $ t { Y % $ b % B j Z 8 $ R s P Z R Z 8 7 $ 8 $ j s { Y t $ J Z R s } } j k B s t k

    , $ t I B P } B ` { $ B t

    1

    30

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    31/46

    Lighting and Shading

    One or more light sources.

    The geometric model may have a colour associated with eachvertex.

    Texture can give a 3D effect without lighting.

    Lighting equation: Calculate colour for each vertex of the

    model.

    Gouraud shading: Use location and properties of light sources,position and normal of the vertex and material properties tocompute the colour at each vertex of the surface. Then in-

    terpolate the colours at the vertex of each triangle over thetriangle.

    Pixel shading can be used for more elaborate lighting effects.

    Normally, lighting is calculated in world space.

    31

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    32/46

    Lighting

    3$Z 1x V R { t b $ Y B Z j $ Y $ t $ R B t Y j P s j $ R { t B t Y $ Y

    32

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    33/46

    Projection

    After lighting the view volume is transformed into a unit cube

    with extreme points at (1,1,1) and (-1,-1,-1), called the canon-ical volume.

    Two projection methods

    1. Orthographic: parallel lines remain parallel; combine trans-

    lation and scaling2. Perspective: The farther away the smaller; parallel lines may

    converge at horizon; mimics how we perceive object size.

    View frustum = truncated pyramide with rectangular base; is

    transformed into the unit cube. Both projections can be constructed with (44)-matrices.

    After projection the model is called to be in normalised devicecoordinates.

    z-coordinate is stored in the Z-buffer.33

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    34/46

    Orthographic and Perspective Projections

    3$Z 1E ! t Y j P $ R s t B Y B s } Y $ { B } s s j j j } B ` { $ B t B t Y $ Y $ R s } R } { $ % } B ` { $ B t

    34

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    35/46

    Clipping

    Only primitives wholly or partially inside the view volume need

    to be passed to the rasterizer stage, which then draws themon the screen.

    Due to the projection transform the transformed primitives arealways clipped against the unit cube.

    The view volume has six clipping planes, but additional onescan be defined.

    35

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    36/46

    Clipping

    3$Z 1 V P Y } B ` { $ B t s t R P B 8 B t j k Y } $ 8 $ $ % R $ t R $ I Y Z t $ { Z A w b Y $ { Y { B R } B t I B } $ 8 $ $ % R $ t R $ I Y % $ b P Z R Z 8 D s I R $ I P B { B t $ t Z I

    } B { R R $ t q Y P B Y } $ 8 $ $ % R B Z R $ I Y Z t $ { Z A s I $ R { s I I } $ 8 $ $ % R

    B s j j k $ t R $ I s , } s t I } $ 8 $ $ % R $ t R { $ t b $ Y Y Z t $ { Z A s { j $ } } I s s $ t R

    Y Z t $ { Z A s t I Y Z R t b % $ { R s t s I s t I B j I B t R s I $ R { s I I

    36

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    37/46

    Screen Mapping

    Only the clipped primitives are passed on to the screen map-

    ping stage. Still 3D.

    x-, and y-coordinates of each primitive are transformed toform screen coordinates.

    Translation and scaling.

    z-coordinate not affected ; z [-1,1].

    Screen coordinates together with the z-coordinate are passedon to the rasteriser stage.

    37

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    38/46

    Screen Mapping Process

    3$Z 1M q Y } $ 8 $ $ % R j $ $ t Y Z t $ { Z A s P Y } B ` { $ B t s t R P B 8 s t I Y R { t 8 s } } $ t } B { I Z s , R { s B P h t I $ t Y { B B I $ t s R B t Y R { t

    38

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    39/46

    Summary of the Geometry Stage

    In summary the geometry stage performs a very demanding task.With a single light source each vertex requires about 100 individ-ual precision floating point operations.

    3$Z 1nq Y B 8 k R s R Z A I $ % $ I I $ t B s } $ } j $ t B P P Z t { $ B t s j R s R

    39

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    40/46

    The Rasteriser Stage

    Rasterization or Scan Conversion: Given the transformed and

    projected vertices, colors, texture coordinates, assign correctcolors to the pixels.

    Unlike the geometry stage which handles per polygon opera-tions, the rasterizer stage handles per-pixel operations.

    Pixel information is stored in the colour buffer which is arectangular array of colours.

    For high performance the rasterizer stage should be imple-mented in hardware.

    40

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    41/46

    Buffers, Visibility

    Double buffering uses a front and a back buffer to avoid that

    the viewer observes the rastering. Z-buffer = depth buffer. It stores the z-value from the camera

    to the closest primitive.

    Z-buffer algorithm: If the polygon point being scan converted

    at (x, y) is no farther from the viewer than is the point whosecolour and depth are currently in the buffers, then the newpoints colour and depth replace the old values.

    has O(n) convergence

    allows primitives to be rendered in any order works for any primitive for which a z-value can be computed

    for each pixel

    Texturing means glueing an image to an object.

    41

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    42/46

    Texturing

    3$Z 1 V { B b 8 B I j b $ Y B Z - Z R $ R R Y B b t B t Y j P q Y b B - Z R $ t Y 8 $ I I j s X j Z I " B t B Y { B b s t I Y R Z j $ R R Y B b t B t Y $ Y q Y B } - Z

    $ R P B Y k R b Y $ j Y A B B 8 - Z $ R P B Y A B I k B P Y { B b w ] B b 8 B I j Z R I

    { B Z R k B P F t R N s R R B t D

    42

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    43/46

    Summary of the Pipeline

    A model is built from points, lines and triangles; texture; lightsource.

    Application:

    User can interact with the model.

    Camera can move.

    view transform and model transform.

    Geometry:

    Put models into eye space.

    Lighting, textures

    Projection; unit cube; clipping.

    Map into a window on the screen. Rasterizer:

    All primitives are rasterized.

    Render primitives with texture.

    Visibility: Z-buffer algorithm.43

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    44/46

    Exercise 1

    Calculate the midpoint of the circle in 2D that contains the

    following three points:A = (1, 1)

    B = (3, 0)

    C = (5, 1)

    44

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    45/46

    Exercise 2

    Show that the following two definitions of the dot product are

    equivalent (we restrict it to 3D now but is works the same in ndimensions):

    Def 1: v w = v1w1 + v2w2 + v3w3Def 2: v w = |v| | w| cos ,

    where is the angle between v and w.

    45

  • 7/27/2019 Comp3320 Lect 01 Pipeline1

    46/46

    Exercise 3

    Select a plane and a line in 3D and calculate the hitpoint:

    For the plane you require a normal vector n and an anchor point B.For the line you require a direction vector c and an anchor point A.Use the example: n = (1, 0, 1), B = (1, 2, 2), c = (1, 2, 0),A = (0, 1, 1).

    46