Understanding Coordinates and Basis Vectors in 3D Spaces, Slides of Fundamentals of E-Commerce

The concept of coordinates and basis vectors in 3d spaces. It discusses how coordinates define the location of a point in a space using a set of orthogonal unit vectors called a basis. The document also covers the importance of having a complete basis to describe any point in space and demonstrates how to find the coordinates of a point relative to a different basis. Additionally, it introduces the concept of using matrices to represent and transform points between different bases.

Typology: Slides

2012/2013

Uploaded on 07/30/2013

post_box
post_box 🇮🇳

4.7

(3)

113 documents

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Vector Spaces and Basis
Transforms
Co-ordinates
Bases
Using a matrix to represent a basis
World space, camera space, object space
Building interactive objects in the virtual world
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download Understanding Coordinates and Basis Vectors in 3D Spaces and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

Vector Spaces and BasisTransforms

Co-ordinates

Bases

Using a matrix to represent a basis

World space, camera space, object space

Building interactive objects in the virtual world

What are co-ordinates?

Well, yes... in a way. But even if they’re the same point,you might describe them using different co-ordinates.

Co-ordinate spaces

Consider the point [ x, y]:

Is this the same point?

What is a basis?

Basis Vectors

If P = [ x, y, z ] then

P = [ 1, 0, 0 ] * x +

// X axis

[ 0, 1, 0 ] * y +

// Y axis

[ 0, 0, 1 ] * z

// Z axis

These three vectors are all that’s needed to uniquely definethe location of any point in the world. Any point can bedescribed as a sum of one or more of these three vectors,multiplied by some scalar coefficient.

These three vectors, X axis, Y axis, and Z axis, form what’scalled a

basis

, or

co-ordinate system

The particular vectors shown here--

[ 1, 0, 0 ], [ 0, 1, 0 ], and [ 0, 0, 1 ]

--form what’s called the

identity basis

What is a basis?

A basis is a set of n orthogonal unit vectors

where each vector is of dimension n.

The term

orthogonal

means

perpendicular

A basis forms a co-ordinate system which can be used tospecify the location of any point in space as a sum of one ormore of the basis vectors multiplied by scalar coefficients.

Examples:

[ 1, 0, 0 ], [ 0, 1, 0 ], and [ 0, 0, 1 ] is a basis.

[ 1, 0, 0 ], [ 0, 1, 0 ], and [ 0, 0, 2 ] is not; Z is not length one.

[ 1, 0, 0 ], [ 0, 1, 0 ], and [ 0, 1, 1 ] is not; Z is not perpendicular to Y.

Building a new basis

Remember the rotation matrix around the Y axis?

[

cos(45º)

0

-sin(45º)

]

R

=

[

0

1

0

]

[

sin(45º)

0

cos(45º)

]

which can be simplified, because

cos(45º)

=

sin(45º)

=



2/

as:

[



2/

0



2/

]

R

=

[

0

1

0

]

[



2/

0



2/

]

We can multiply X, Y, and Z by R:

X’ = R * [1,0,0] =

[

2/2 ]

Y’ = R * [0,1,0] =

[

0 ]

Z’ = R * [0,0,1] =

[ -

2/2 ]

Building a new basis

Now we can build the basis B:

X

[

2/2 ]

Y

[

0 ]

Z

[

2/2 ]

…which is just like our usual identity basis except that the X and

Z vectors are rotated 45 degrees in the X Z plane.

Is this a basis?

All three vectors are unit vectors

2

2

2



All three vectors are orthogonal

X • Y = (

[

2/2]

) • (

[0,1,0]

) = 0+0+0 = 0

X • Z = 0Y • Z = 0



There are three vectors in three dimensions... It’s a basis!

Using different bases to describe the samepoint in space

Finding the co-ordinates (a,b,c) :

We know that

(



2/2,

0,



2/2)

a

(1,0,0)

0

(

0,

1,

b

=

(0,1,0)

0

(-



2/2,

0,



2/2)

c

(0,0,1)

z

Multiply through on both sides:

(

(



2/2)a,

0,

(



2/2)a)

(1,0,0)

(

0,

b,

=

(0,1,0)

(-(



2/2)c,

0,

(



2/2)c)

(0,0,z)

Add through on both sides, x’es with x’es, y’s with y’s:

((



2/2)a-(



2/2)c,

b,

(



2/2)a+(



2/2)c)

=

(0,0,z)

Using different bases to describe the samepoint in space

From ((



2/2)a-(



2/2)c,

b,

(



2/2)a+(



2/2)c)

=

(0,0,z)

we know that

(



2/2)a-(



2/2)c

=

0

(



2/2)a+(



2/2)c

=

z

b

=

0

and so

a-c

=

0

a+c

=

2

z

/



2

b

=

0

and thus

a

=

z

/



2

b

=

0

c

=

z

/



2

...so the co-ordinates of P in basis B are (z/

2, 0, z/

Using matrices to describe bases



To transform a point from one basis to another basis, wecan build a matrix representation of the basis:

[

[ 1 ]

[ 0 ]

[ 0 ]

]

I = [

[ 0 ]

[ 1 ]

[ 0 ]

]

[

[ 0 ]

[ 0 ]

[ 1 ]

]

and

[

[ (



2/2) ]

[ 0 ]

[ (



2/2)

]

]

B = [

[

0

]

[ 1 ]

[

0

]

]

[

[-(



2/2) ]

[ 0 ]

[ (



2/2)

]

]

or in general, the matrix representation of a basis is the matrix

whose columns are the vectors of the basis:

[

[

]

[

]

[

]

]

M = [

[ X ]

[ Y ]

[ Z ]

]

[

[

]

[

]

[

]

]

Using matrices to describe bases

What can this representation do?

Try a simple matrix multiply:

P’ = B * P

I

or rather

[

[ (



2/2) ]

[ 0 ]

[ (



2/2)

]

]

[ 0 ]

P’ = [

[

0

]

[ 1 ]

[

0

]

] * [ 0 ]

[

[-(



2/2) ]

[ 0 ]

[ (



2/2)

]

]

[ z ]

which means

P’ = [ (



2/2)z, 0, (



2/2)z ]

which is the co-ordinates for P

B

World Space and Camera Space

The three vectors defining a camera,

lookFrom,

lookAt

lookUp

…yield three perpendicular vectors X, Y, and Z:

Z = (lookAt – lookFrom).normalised()

Y = lookUp.normalised()

X = Y

Z

These three vectors define a basis B

C

, in which

the camera looks up the Z axis towards (0, 0, 1).

[

[

]

[

]

[

]

]

M

C

=

[

[ X ]

[ Y ]

[ Z ]

]

[

[

]

[

]

[

]

]

World Space and Camera Space

“Camera space” vs “World space” :

Given any point P

I

in the virtual world, if you subtract the

lookFrom of the camera from P

I

and then multiply the

resulting vector by M

C

, you will have the

position of P relative

to the camera

P

C

= M

C

  • (P

I

  • lookFrom)

By the same token, if you take a point in camera space—say,the point on the screen where the user just clicked (if I click atx=20, y=20 then in camera space that’s the point (20, 20, 0))then that point can be converted to world space by

P

I

= (M

C

  • P

C

) + lookFrom

In graphics we generally refer to P

I

as being in

world space

and P

C

as being in

camera space

Simplifying world and camera space

The camera-to-world equations can be rewrittenas a single matrix transformation.

P

C

= M

C

* (P

I

  • lookFrom)

P

I

= (M

C

* P

C

) + lookFrom

The operation (P

I

  • lookFrom) is a translation operation,

shifting P by lookFrom units. Any translation can beexpressed in matrix form:

[

1

0

0

–lookFrom.x

]

T

lookFrom

= [

0

1

0

–lookFrom.y

]

[

0

0

1

–lookFrom.z

]

[

0

0

0

1

]

Multiplying any point P by the matrix

T

lookFrom

, above, would

subtract lookFrom from P.

Simplifying world and camera space

We can extend the matrix M

C

, the matrix which encapsulates

the transformation from world space to camera space, into a4x4 matrix.

[

0 ]

M

C4x

= [

M

C

0 ]

[

0 ]

[ 0 0 0 1 ]

Concatenating M

C4x

onto

T

lookFrom

creates a matrix which will

first translate any point it multiplies, then transform that pointinto a new basis:

WorldToCamera

= M

C

4x

T

lookFrom

which allows us to write

P

C

WorldToCamera

* P

I

P

I

WorldToCamera

-

* P

C