Sunteți pe pagina 1din 50

Co-ordinate systems and Geometric

Transformation - (2D & 3D)

Class -11
Basic transformations - translation, scaling,
rotation and reflection

CO-ORDINATE SYSTEM
Three types of coordinate systems are needed in order to input, store, and
display model geometry and graphics. These are the model coordinate system
(MCS), the working coordinate system (WCS), and the screen coordinate
system (SCS).

Model coordinate system

The model coordinate system is defined as the


reference space of the model with respect to which all the
model geometrical data is stored. The MCS is the only
coordinate system that the software recognizes when storing or
retrieving geometrical information in or from a model database.
Many existing software packages allow the user to input
coordinate information in Cartesian (x, y, z), cylindrical , and/or
spherical
systems. However, this input information is
transformed to (x, y, z), coordinates relative to the MCS
before being stored in the database.

Working coordinate system


Z W2

Y W2
B

E3

X W2
E2

Z
A

Y W1

E1

Y
X W1

Z W1

x max , y max

Ys
Xs

0, 0

It is often convenient in the development of


geometric models and the input of geometrical data to
refer to an auxiliary coordinate system instead of the
MCS.
This is usually useful when a desired plane (face) of
construction is not easily defined as one of the MCS
orthogonal planes, as in the case of inclined faces of a
model shown in Figure. The user can define a
Cartesian coordinate system whose x-y plane is
coincident with the desired plane of construction.

Screen coordinate system


The SCS is defined as two-dimensional, devicedependent coordinate system, whose origin is
usually located at the lower left corner of the
graphics display, as shown in Figure. The physical
dimensions of a device screen (aspect ratio) and the type
of device (vector or raster) determine the range and the
measurement unit of the SCS.

Transformations

changing

of something to something else via

rules
geometric: translate, rotate, scaling, mirroring
and shearing objects on screen / in space
mapping from model space to screen space

11/17/16

Basic Transformation (2D & 3D)

Translation: move one object to another position


Rotation: rotate the object around the origin
Scaling: change the size of the object
Reflection / Mirror :

Homogeneous Coordinates
Composite Transformation (or ) Concatenated
Transformation
Inverse transformation

2D Transforms Translation

Add a distance in x and y


to the point.

Can be expressed as components


or as addition of column vectors

x' x t x , y ' y t y
x'

P' , P
y '

P' P T

tx
,T

y
ty

Rotation 1
(x,y)
r

(x,y)

The original coordinates of the point in Polar Coordinates are


X= r cos ()

y = r sin ()

Rotation 2

x = r cos ( + ) = r cos cos r sin sin


Y = r sin ( + ) = r cos sin + r sin cos

x = x cos y sin
Y = x sin + y cos

P = R.P
R = cos
sin

- sin
cos

Scaling 1

X = x. sx y = y.sy
x
sx 0
x
y
0 sy
y
P = S . P

Turning a square into a rectangle with


scaling factors sx= 2 and sy =1.5

Homogeneous Coordinates
As translations do not have a 2 x 2 matrix representation,
we introduce homogeneous coordinates to allow a 3 x 3 matrix
representation. A point (x, y) can be re-written in homogeneous coordinates as

(xh, yh, h)

The homogeneous parameter h is a non- zero value such that:

xh
x
h

yh
y
h

We

can then write any point (x, y) as (hx, hy, h)

We

can conveniently choose h = 1 so that (x, y) becomes (x, y, 1)

2D Translation in Homogeneous Coordinates (HC)

X
Y
1

1 0 tx

1 ty

0 1

P = T ( tx , ty ) . P

2D Rotations about (Z) in HC


X
Y
1

Cos -Sin 0

Sin

Cos 0

P= R() .P

2D Scaling in HC
X
Y
1

Sx

Sy

P= S(sx, sy) .P

General pivot point rotation

Translate the object so that pivot-position is moved to the


coordinate origin
Rotate the object about the origin
Translate the object so that the pivot point is returned to its original
position
(xr,yr)

(a)

(b)

(c)

(d)

Original Position
of Object and
pivot point

Translation of
object so that
pivot point
(xr,yr)is at origin

Rotation was
about origin

Translation of the object


so that the pivot point is
returned to position
(xr,yr)

General pivot point rotation


1

xr

cos

-sin 0

-xr

yr

sin

cos 0

-yr

cos

-sin xr(1- cos)+ yr sin

sin

cos yr(1- cos) - xr sin

Can also be expressed as T(xr,yr).R().T(-xr,-yr) = R(xr,yr,)

General fixed point scaling

Translate object so that the fixed point coincides with the


coordinate origin
Scale the object with respect to the coordinate origin
Use the inverse translation of step 1 to return the object to its
original position
(xf,yf)

(a)

(b)

Original Position Translation of


object so that
of Object and
fixed point
Fixed point
(xf,yf)is at origin

(c)
scaling was
about origin

(d)
Translation of the object
so that the Fixed point
is returned to position
(xf,yf)

General pivot point Scaling


1

xf

sx

-xf

yf

sy

-yf

sx

xf(1- sx)

sy

yf(1- sy)

Can also be expressed as T(xf,yf).S(sx,sy).T(-xf,-yf) = S(xf, yf, sx, sy)

Reflection / Mirroring about X axis in


homogeneous coordinates

Reflection is a transformation that produces a mirror image of


an object. It is obtained by rotating the object by 180 deg about
the reflection axis
1 Original position

Reflection about the line y=0, the


axis , is accomplished with the
transformation matrix
1 0

0 -1 0
0

1
Reflected position

Reflection about y axis in HC


Original position

Reflected position

2
1

1
3

-1 0

Reflection perpendicular to xy
plane

Reflected position
3

-1 0

-1

2
1
1
2
3
Original position

Reflection of an object relative to an axis


perpendicular to the xy plane and passing through
the coordinate origin

Reflection of an object w.r.t the line y=x

Original position
3
2

1
1
3
Reflected position
2

3D Transformation
Translation
Rotation
Scaling
Mirroring

/ Reflection

Translation in 3D
Remembering

2D transformations -> 3x3

matrices
x
T t x , t y
y

T t x , t y , t z

1 0 tx
tx
0 1 t y
ty 0 0 1

1 0 0 tx
x tx

0
1
0
t
y
y t y
0 0 1 tz
z t z

0
0
0
1

T=(tx, ty, tz)

3D Rotations about the Z axis


What do you think the rotation matrix is for rotations
about the z axis?

cos
R
sin

cos
sin
sin
cos
0

cos
sin
R (0,0,1, )
0

sin

sin
cos
0

cos
0

0 0
0 0
1 0

0 1

R=(0,0,1,)

0
1

3D Rotations about the X axis

R=(1,0,0,)

R (1,0,0, )

0
1
0 cos

0 sin

0
0

0
sin
cos
0

0
0

3D Rotations about the Y axis

R=(0,1,0,)

R(0,1,0, )

cos
0

0 sin 0

1 0 0
sin 0 cos 0

0
0 0 1

Scale in 3D
sx
S sx , s y
0

0 x
*
s y y

sx
S s x , s y , s z 0
0

0
sy
0

sx
0
0
0

0
s z

x
* y
z

sy
0

S=(sx, sy, sz)

0
1

sx
0

sy
0

0
sz

0
0

3D Transformations - Summary
Use homogeneous coordinates, just as in 2D
case.
Transformations are now 4x4 matrices.

x
z (out of page)

Note:
Convenient to think of display as
Being left-handed !!
( z into the screen )

Rotation in 3D

Need to specify which axis the rotation is about.

z-axis rotation is the same as the 2D case.


cos
sin
R z ( )
0

sin
cos
0
0

0
0
1
0

0
0
0

X and Y -axis rotation is the same as the 2D case.

R x ( )

0
1
0 cos

0 sin

0
0

0
sin
cos
0

0
0

R y ( )

cos
0

sin

0 sin
1
0
0 cos
0
0

0
0

Inverse transformations
The inverse of the transformation is the inverse of its matrix

Composition of transformations
Series of transformation of matrices are

P' T ( x1 , y1 ) S ( S x , S y ) T ( x1 , y1 ) P

Inverse transformations
The

inverse of the transformation


is the inverse of its matrix
Translation:

1 0 tx

1
T 0 1 ty
0 0 1

Inverse transformations
Rotation:

cos

1
R sin
0

sin
cos
0

0
1

Inverse transformations
Scaling:

0
1 / sx

S (sx , s y ) 0 1 / s y
0
0

0
0

Reflection -3D

Reflection in 3D
Reflection about the y-axis Reflection about the x-axis

11/17/16

1 0 0
0 1 0

0 0 1

37

1 0 0
0 1 0

0 0 1

Reflection 3D

Reflection about the origin Reflection about the line y=x

11/17/16

38

0 1 0
1 0 0

0 0 1

1 0 0
0 1 0
0

Shear

A transformation that distorts the shape of an


object such that the transformed shape appears as
if the object were composed of internal layers that
had been caused to slide over each other is called
a shear.

1 shx
0 1

0 0

0
1

Shear
The

transformed positions are:

x x shx y, y y
'

'

3D Shear

xy Shear: SHxyP

1 0 shx 0
0 1 sh 0
y

0 0 1 0

0 0 0 1

x
y

z

1

Compositing Matrices
Remember:

the transformations, in order,


are written from right to left

In other words, the first matrix to affect the

vector goes next to the vector, the second


next to the first, etc.
This is the rule with column vectors
(OpenGL); row vectors would be the opposite

So

in our case:
p = Ry-1 Rx -1 Rz Rx Ry p

Homogeneous Coordinates
Homogeneous

coordinates: represent
coordinates in 3 dimensions with a 4vector
x / w x
y / w y

( x, y , z )
z / w z


1 w

(Note that typically w = 1 in object coordinates)

Homogeneous Coordinates

Homogeneous coordinates seem unintuitive, but


they make graphics operations much easier

Our transformation matrices are now

4x4:

0
0
0
1
0 cos() sin( ) 0

Rx
0 sin( ) cos() 0

0
0
1
0

Homogeneous Coordinates

Homogeneous coordinates seem unintuitive,


but they make graphics operations much
easier

Our transformation matrices are now 4x4:

cos()

0
Ry
sin( )

0 sin( )
1
0
0 cos()
0
0

0
0

Homogeneous Coordinates

Homogeneous coordinates seem unintuitive, but


they make graphics operations much easier
Our transformation matrices are now 4x4:

cos() sin( ) 0 0
sin( ) cos() 0 0

Rz
0
0
1 0

0
0 1
0

Homogeneous Coordinates

Homogeneous coordinates seem unintuitive, but


they make graphics operations much easier

Our transformation matrices are now

Sx 0
0 Sy

0
0

0
0

0
0

Sz 0

0 1

4x4:

Homogeneous Coordinates

How can we represent translation as a


4x4 matrix?

1
0
T
0

0
1
0
0

0 T x
0 T y
1 T z

0 1

Translation Matrices

Now that we can represent translation as a matrix,


we can composite it with other transformations
Ex: rotate 90 about X, then 10 units down Z:

x'
y'

z'

w'

1 0 0
0 1 0

0
0

0 0 1 10

0 0 0 1

1 0 0 0
0 0 1 0

0 1 0 0

0 0 0 1

x
y

z

w

Translation Matrices

Now that we can represent translation as a matrix,


we can composite it with other transformations
Ex: rotate 90 about X, then 10 units down Z:

x'
y'

z'

w'

1 0 0
0 0 1

0 1

0 0

0
0

0 x
0 y
10 z

1 w

S-ar putea să vă placă și