
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 24
This page cannot be seen from the preview
Don't miss anything!

















Co-ordinates
Bases
Using a matrix to represent a basis
World space, camera space, object space
Building interactive objects in the virtual world
Well, yes... in a way. But even if they’re the same point,you might describe them using different co-ordinates.
Consider the point [ x, y]:
Is this the same point?
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
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.
[ 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.
[
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/
]
…which is just like our usual identity basis except that the X and
Z vectors are rotated 45 degrees in the X Z plane.
All three vectors are unit vectors
2
2
2
All three vectors are orthogonal
X • Y = (
) • (
) = 0+0+0 = 0
X • Z = 0Y • Z = 0
There are three vectors in three dimensions... It’s a basis!
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)
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/
[
[ 1 ]
[ 0 ]
[ 0 ]
]
I = [
[ 0 ]
[ 1 ]
[ 0 ]
]
[
[ 0 ]
[ 0 ]
[ 1 ]
]
[
[ (
2/2) ]
[ 0 ]
[ (
2/2)
]
]
B = [
[
0
]
[ 1 ]
[
0
]
]
[
[-(
2/2) ]
[ 0 ]
[ (
2/2)
]
]
[
[
]
[
]
[
]
]
M = [
[ X ]
[ Y ]
[ Z ]
]
[
[
]
[
]
[
]
]
Try a simple matrix multiply:
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
lookFrom,
lookAt
lookUp
Z = (lookAt – lookFrom).normalised()
Y = lookUp.normalised()
C
[
[
]
[
]
[
]
]
M
C
=
[
[ X ]
[ Y ]
[ Z ]
]
[
[
]
[
]
[
]
]
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
I
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
C
) + lookFrom
In graphics we generally refer to P
I
as being in
world space
and P
C
as being in
camera space
C
C
I
I
C
C
) + lookFrom
The operation (P
I
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.
We can extend the matrix M
C
, the matrix which encapsulates
the transformation from world space to camera space, into a4x4 matrix.
C4x
C
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
C
4x
lookFrom
which allows us to write
C
WorldToCamera
I
I
WorldToCamera
-
C