slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Basic elements of 3-D coordinate systems and linear algebra PowerPoint Presentation
Download Presentation
Basic elements of 3-D coordinate systems and linear algebra

Loading in 2 Seconds...

play fullscreen
1 / 25

Basic elements of 3-D coordinate systems and linear algebra - PowerPoint PPT Presentation


  • 118 Views
  • Uploaded on

Basic elements of 3-D coordinate systems and linear algebra. Coordinatate systems are used to assign numeric values to locations with respect to a particular frame of reference commonly referred to as the origin.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Basic elements of 3-D coordinate systems and linear algebra' - belden


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1

Basic elements of 3-D coordinate systems and linear algebra

Coordinatatesystems are used to assign numeric values to locations with respect to a particular frame of reference commonly referred to as the origin.

The number of dimensions in the coordinate system is equal to the number of perpendicular (orthgonal) axes and is also the number of values needed to specify a location with respect to the origin.

Two dimensions: the plane

slide2

Basic elements of 3-D coordinate systems and linear algebra

One dimension: the line

Two dimensions: the plane

Two dimensions: the plane

slide3

Basic elements of 3-D coordinate systems and linear algebra

Three dimensions: the universe as we perceive it

(A right handed coordinate system is shown. In a left handed system the direction of the positive z axis is reversed. )

Two dimensions: the plane

slide4

Points in 3-D space

The location of a point P in 3-D Euclidean space is given by a triple(px, py, pz)

The x, y, and z coordinates specify the distance you must travel in directions parallel to the thex, y, and z axes starting from the origin (0, 0, 0) to arrive at the point (px, py, pz)

slide5

Vectors in 3-D space

A vectorin 3-D space is sometimes called a directed distance because it represents both

  • adirection and
  • a magnitude or distance

In this context, the triple(px, py, pz) can also be considered to represent

  • the direction from the origin (0, 0, 0) to (px, py, pz) and
  • its length sqrt(px2 + py2 + pz2) is the Euclidean (straight line) distance from the origin to (px, py, pz)
slide6

Points and vectors

Two points in 3-D space implicitly determine a vector pointing from one to the other. Given two points P and Q in 3-D Euclidean space, the vector

R = P - Q = (px - qx, py - qy, pz - qz)

represents the direction fromQtoP. Its length, as defined above, is the distance between P and Q.

Note that the direction is a signed quantity. The direction from P to Q is the negative of the direction from Q to P. However, the distance from P to Q is always the same as the distance from Q to P.

slide7

Points and vectors

R = P - Q = (px - qx, py - qy, pz - qz)

represents the direction fromQtoP. Its length, as defined above, is the distance between P and Q.

Example: Let V = (8, 6, 5) and P = (3, 2, 0).

Then the vector direction from V to P is

(3 - 8, 2 - 6, 0 - 5) = (-5, -4, -5)

The vector direction from P to V is

(5, 4, 5)

The distance between V and P is

sqrt(25 + 16 + 25) = sqrt(66) = 8.12.

slide8

The geometric interpretation of vector arithmetic

Here we work with 2 dimensional vectors to simplify the visual interpretation, but in 3-d the principles are the same.

P = (5, 1) => +5in the x direction and then +1 in the y direction

Q = (2, 4) => +2in the x direction and +4 in the y direction.

R = P + Q = (7, 5)

P = R + (– Q) = R - Q

slide9

Useful operations on vectors:

We define the sum of two vectors P and Q as the componentwise sums:

R = P + Q = (px + qx, py + qy, pz + qz)

(3, 4, 5) + (1, 2, 6) = (4, 6, 11)

The difference of two vectors is computed as the componentwise differences:

R = P - Q = (px - qx, py - qy, pz - qz)

(3, 4, 5) - (1, 2, 6) = (2, 2, -1)

slide10

Useful operations on vectors (cont’d):

We also define multiplication (or scaling) of a vector by a scalar number a

S = aP = (apx, apy, apz)

3 * (1, 2, 3) = (3, 6, 9)

The length of a vector P is a scalar whose value is denoted:

|| P || =sqrt(px2 + py2 + pz2)

|| (3, 4, 5) || = sqrt(9 + 16 + 25) = sqrt(50)

slide11

Useful operations on vectors (cont’d):

A unit vector is a vector whose length is 1. Therefore an arbitrary vector P may be converted to a unit vector by scaling it by 1 / (its own length). Here U is a unit vector in the same direction as P.

U = ( 1 / || P || ) P

The inner product or dot product of two vectors P and Q is a scalar number. It is a value expressing the angular relationship between two vectors.  The dot product is computed by taking the sum of the componentwise products of the two vectors.

x = P dot Q = (pxqx+ pyqy, + pzqz)

(2, 3, 4) dot (3, 2, 1) = 6 + 6 + 4 = 16

Thus || P || = sqrt(P dot P)

slide12

Useful operations on vectors (cont’d):

The dot product has the following relationship with the lengths of two vectors and the angle between them. If U and V are vectors and q is the angle between them, then

U dot V = V dot U =|| U ||* || V || * cos(q)

If U and V are unit vectorsand q is the angle beween them then:

cos(q) = U dot V = V dot U

In this course, we will refer to vectors as tuples.

slide13

Representing tuples in C

There are at least two easy ways to represent a tuple:

Array based representation:

We can use the typedeffacility to create a user defined type called tuple_t. An instance of tuple_tis a three element double precision array:

typedefdouble tuple_t[3];

An instance of tuple_tisa three element double precision array and can be created as shown.

tuple_t tuple;

It is understood that

tuple[0] is the x-component (coordinate)

tuple[1] is the y-component

tuple[2] is the z-component

slide14

Representing tuples in C

Array based representation (cont’d):

To make this association explicit we use the#definefacility

#define X 0

#define Y 1

#define Z 2

We can then create an instance of the vector (11, 2, -4) as shown:

tuple_tt;

t[X] = 11;

t[Y] = 2;

t[Z] = -4;

slide15

Representing tuples in C

Structure based representation

We can also define a structured type in which the elements are explicitly named

typedefstructtuple_type

{

double x;

double y;

double z;

} tuple_t;

slide16

Representing tuples in C

Structure based representation

tuple_t t;

In this representation, it is explicit that

t.xis the x-component

t.yis the y-component

t.zis the z-component

slide17

Representing rgbdata

In the raytracer we will work with three types of rgbdata:

reflective materials

emissive lights

pixels

We will use rgbdata for all three, but will use different models for the interaction of lights with materials than for the image itself.

slide18

Representing rgbdata

/** pixel_t definition **/

typedefstructpixel_type

{

unsigned char r; // Red value

unsigned char g; // Green value

unsigned char b; // Blue value

} pixel_t;

slide19

Representing tuples

The tuple.hfile contains the following definition:

typedefstructtuple_type

{

double x;

double y;

double z;

} tuple_t;

slide20

Tuple functions

tuple_tray(tuple_t t1, tuple_t t2);

Compute a non-unitized vector from point t1 to point t2. This is just computing the componentwise difference t2 - t1 and returning the new tuple value.  NOTE:  The vector from t1 to t2 is not the same as the vector from t2 to t1!!!

double length(tuple_t t);

Computes the length of the tuple. The length is the square root of the sum of the squares of the components of the tuple: || t || = sqrt(tx2 + ty2 + tz2)

slide21

Tuple functions

tuple_tscale(tuple_tt, double factor);

This function multiplies each component of the input tuple “t" by a scaling factor "factor" and returns a new tuple that is scaled.

tuple_tadd(tuple_t t1, tuple_t t2);

Compute the componentwise sum t1 + t2 and return a new tuple.

tuple_t diff(tuple_t t1, tuple_t t2);

Compute the componentwise difference t2 – t1 and return a new tuple.

slide22

Tuple functions

tuple_tunitize(tuple_tt);

Construct a unit length tuple in the direction of the input tuple t.  A unit tuple is a tuple having length 1. To obtain the unit tuple in the direction of a tuple "t", scale "t" by  (1 / ||t||). Hint: you can use length() and scale() to do much of the work for you in this function. If this function is called with the zero tuple (0 = (0, 0, 0)) it should return zero tuple (i.e. (0, 0, 0)). To avoid crashing on a divide-by-zero exception, check for a zero-length tuple before calling scale().

slide23

Tuple functions

double dot(tuple_t t1, tuple_t t2);

The inner product or dot product of two tuples P and Q is a scalar number:x = P dot Q = (pxqx + pyqy + pzqz).  Thus || P || = sqrt(P dot P) We will find that the dot product operation is very useful in the construction of the ray tracer because the dot product of two UNIT vectors (a vector is just a type of tuple) yields the cosine of the angle between the two vectors. That is, if P and Q are unit vectors then P dot Q is the cosine of the angle between the vectors P and Q.  If they are not unit vectors then (P dot Q) / (|| P || || Q || ) yields the cosine.

slide24

Tuple functions

void printTuple(FILE *outFile, char *label, tuple_tt);

Print the 3 elements of a tuple on a line prefixed by a label to the output stream "outfile". Each value should be printed in a field that is a minimum of 8 characters wide and with 4 decimal places (e.g. " 23.1200"). If t=(2.2, 0, -4.34567) the call: printTuple(stderr, "Result: ", t); should result in the output: Result: 2.2000 0.0000 -4.3456

slide25

Tuple functions

tuple_treadTuple(FILE *inFile, char *errmsg)

Try to read three double values from the input stream "inFile" and store the result in the tuple pointed to by t. The return value from readTuple() should be the tuple_t value if no errors occur. On error readTuple() should print the error message pointed to by "errmsg" and exit the program.