23
SE 313 – Computer Graphics Lecture 3: Analytical Geometry and Linear Algebra Lecturer: Gazihan Alankuş lease look at the last three slides for assignments (marked with TO 16.02.2012 1

SE 313 – Computer Graphics Lecture 3: Analytical Geometry and Linear Algebra Lecturer: Gazihan Alankuş Please look at the last three slides for assignments

Embed Size (px)

Citation preview

1

SE 313 – Computer Graphics

Lecture 3: Analytical Geometry and Linear Algebra

Lecturer: Gazihan Alankuş

Please look at the last three slides for assignments (marked with TODO)

16.02.2012

2

Quiz

• Turn off monitors• Take out a piece of paper and a pen/pencil• 5 minutes

16.02.2012

3

Our Goal

• Remember basic concepts in analytical geometry and learn about how they are applied in linear algebra and in computer graphics

16.02.2012

4

Coordinate Frame

• An origin point • Three axes (x, y, z) – that are perpendicular to each other– that are ordered by the right hand rule (x-thumb,

y-index finger, z-middle finger)

16.02.2012

5

Point

• Location in space• Coordinates (x, y, z)

16.02.2012

6

Displacement between two points

• Vector = Point – Point• Example: “North-east, 5 meters”• No position, only direction.– If you want to, you can draw it starting from any

position.

16.02.2012

7

Representing points and vectors

• Both of them are represented with three scalar values for the x, y and z axes.

• They mean different things– Point – precise location in space– Vector – precise direction, no location

16.02.2012

8

Operations

• Point addition• Point subtraction• Vector addition• Vector subtraction

16.02.2012

9

Operations

• Point addition• Point subtraction -> Vector• Vector addition -> Vector• Vector subtraction -> Vector

• Details are presented on the board, check your book or assigned online readings if you missed it.

16.02.2012

10

Different Coordinate Frames

• In computer graphics sometimes we use multiple reference coordinate frames– World coordinates, character coordinates, camera

coordinates, etc.• The same geometrical point or vector is

represented with different values in different coordinate frames.

• The values depend on the coordinate frame being used.

16.02.2012

11

More Simple Operations

• Point – vector addition• Point scaling• Vector scaling

16.02.2012

12

More Simple Operations

• Point – vector addition -> point• Point scaling -> point• Vector scaling -> vector

• Details are presented on the board, check your book or assigned online readings if you missed it.

16.02.2012

13

Vectors have length

– How much you would travel if you followed the vector

• Unit vectors: a vector in the same direction, but with a length of 1

– Direction without magnitude

16.02.2012

14

More Interesting Operations

• Vector dot product• Vector cross product

16.02.2012

15

More Interesting Operations

• Vector dot product -> scalar• Vector cross product -> vector

16.02.2012

16

Dot product

• Gives a number for two vectors

– Greatest when vectors are in the same direction– Zero when vectors are perpendicular – Negative when vectors are opposing

• http://www.falstad.com/dotproduct/

16.02.2012

17

Properties

• Dot product two perpendicular vectors, you get zero

• Dot product a vector with itself, you get the square of its magnitude

• Can be used to calculate projections

16.02.2012

18

Cross product

• Gives a new vector for two vectors• (don’t try to memorize, use computers)

– Perpendicular to the two vectors according to the right hand rule

– Maximum when vectors are perpendicular– Zero when vectors are the same or opposite

directions• http://physics.syr.edu/courses/java-suite/cros

spro.html16.02.2012

19

Properties

• (opposite direction)

16.02.2012

20

Angle between two vectors

• Can find the angle using atan(y/x)• Watch out for the sign– Use atan2(y, x)

16.02.2012

21

Lab assignment• Part 1

– Open up Blender, create a cone. Go to edit mode. Make sure everything is selected using Select->(De)select All.– Use View->Properties to show the properties pane. You will see the median location of all selected points there. Set

it to 0, 0, -2 so that the tip of the cone is at the reference point.– Go back to object mode. Make the cone red. Duplicate the cone, make that duplicate blue. You should have one red

and one blue cone.– Create a sphere in origin and make it white.

• Part 2– Locate the two cones so that the vectors from the origin to the cones make an angle between 0-90 degrees.– Create two cylinders, locate and rotate them so that they look like the stems of the vectors. Color them the same as

the cones. – Rotate the cones accordingly. The end result should look like two vectors with an angle between 0-90 degrees.

• Part 3– Convert the properties pane on the right to be a Python console. Create two vectors using a code like this. The

values should come from the locations of the cones. • v1 = Vector([1.2, 1.3, -1.4]) • v2 = Vector([5.5, 1.4, -3.4])

– Calculate the cross product like this:• c=v1.cross(v2)

– Normalize the vector using:• c.normalize()• print(c)

– Draw a third vector starting from the origin and representing the normalized cross product. Make it green. 16.02.2012

22

TODO: Homework 3.a (video)• Re-watch the Blender intro to modeling

video here:– http://cgcookie.com/blender/2010/08/31/blen

der-intro-to-modeling/

• There will be quiz about it next week.

16.02.2012

23

TODO: Homework 3.b (deliverable)• Start with a cube and use the extrude

tool to create the first letter of your name. Feel free to make it pretty.

• Submit the rendered image and the .blend file, just like you did last week.

16.02.2012