Docsity

Maths Preliminaries - Computer Graphics - Lecture Slides, Slides of Computer Graphics

Partial preview of the text

Download Maths Preliminaries - Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

Maths Preliminaries

Introduction

• Computer graphics is all about maths!

• None of the maths is hard, but we need to

understand it well in order to be able to

understand certain techniques

• Today we’ll look at the following:

  • Coordinate reference frames
  • Points & lines
  • Vectors
  • Matrices

Coordinate Reference Frames – 2D

• When setting up a scene in computer graphics

we define the scene using simple geometry

• For 2D scenes we use

simple two dimensional

Cartesian coordinates

• All objects are defined

using simple coordinate

pairs

x axis

y axis

P y

x

Coordinate Reference Frames – 2D (cont…)

x

y

(2, 3)

(2, 7) (7, 7)

(7, 3)

2 7

3

7

Left Handed Or Right Handed?

• There are two different ways in which we can

do 3D coordinates – left handed or right

handed

Right-Hand Reference System

Left-Hand Reference System

We will mostly use

the right-handed

system

Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

Points & Lines

  • Points:
    • A point in two dimensional space is given as an

ordered pair (x, y)

  • In three dimensions a point is given as an ordered

triple (x, y, z)

• Lines:

  • A line is defined using a start point and an end-

point

  • In 2d: (xstart, ystart) to (xend , yend )
  • In 3d: (xstart, ystart , z (^) start) to (xend , yend , z (^) end )

The Equation of A Line

  • The slope-intercept

equation of a line is:

  • where:
  • The equation of the line gives us the

corresponding y point for every x point

x

y

y 0

y end

x 0 x end

y = m ⋅ x + b

0

0

x x

y y

m

end

end

0 0

b = y − m ⋅ x

A Simple Example

• Let’s draw a portion of the line given by the

equation:

• Just work out the y coordinate for each x

coordinate

y = x +

A Simple Example (cont…)

For each x value just work out the y value:

y ( 3 ) = ⋅ + =

y ( 4 ) = ⋅ + =

y ( 5 ) = ⋅ + =

y ( 6 )= ⋅ + =

y ( 7 ) = ⋅ + =

y ( 2 ) = ⋅ + =

x

y

2 3 4 5 6 7

2

5

Docsity.com

Vectors

• Vectors:

  • A vector is defined as the difference between two

points

  • The important thing is that a vector has a

direction and a length

• What are vectors for?

  • A vector shows how to move from one point to

another

  • Vectors are very important in graphics - especially

for transformations

Vectors (3D)

• In three dimensions a vector is calculated in

much the same way

V = P 2 − P 1

= ( x 2 (^) − x 1 , y 2 − y 1 , z 2 − z 1 )

= ( V (^) x , Vy , Vz )

x axis

y axis

z axis

P 1

P 2 So for (2, 1, 3) to (7, 10, 5)

we get

Vector Operations

• There are a number of important operations

we need to know how to perform with

vectors:

  • Calculation of vector length
  • Vector addition
  • Scalar multiplication of vectors
  • Scalar product
  • Vector product

Vector Operations: Vector Addition

• The sum of two vectors is calculated by simply

adding corresponding components

1 2 1 x 2 x 1 y 2 y

V + V = V + V V + V

x axis

y axis

V (^1)

V (^2)

x axis

y axis

V (^1)

V (^2)

V 1 + V (^2)

Vector Operations: Scalar Multiplication

  • Multiplication of a vector by a scalar proceeds

by multiplying each of the components of the

vector by the scalar

( , ) x y sV = sV sV

x axis

y axis

sV

(sV (^) x, sVy)

x axis

y axis

V

(V (^) x, Vy)