3d Transformations 2-Computer Graphics-Lecture Notes, Study notes of Computer Graphics

Computer Graphics involves technology to accept, process, transform and present information in a visual form that also concerns with producing images and animations using a computer. This course teach how to make your own design in computer using OpenGl. This lecture includes: Normalization, Transformation, Moving, Origin, Points, Different, Opposite, Direction, Projection

Typology: Study notes

2011/2012

Uploaded on 08/04/2012

parnashi
parnashi 🇮🇳

4.4

(49)

71 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture No.18 3D Transformations II
Rotation
Rotation is the process of moving a point in space in a non-linear manner. More
particularly, it involves moving the point from one position on a sphere whose center is at
the origin to another position on the sphere. Why would you want to do something like
this? As we will show in later section, allowing the point of view to move around is only
an illusion – projection requires that the POV be at the origin. When the user thinks the
POV is moving, you are actually translating all your points in the opposite direction; and
when the user thinks the POV is looking down a new vector, you are actually rotating all
the points in the opposite direction; and when the user thinks the POV is looking down a
new vector, you are actually rotating all the points in the opposite direction.
Normalization: Note that this process of moving your points so that your POV is at the
origin looking down the +Z axis is called normalization.
Rotation a point requires that you know
the coordinates for the point, and
That you know the rotation angles.
You need to know three different angles: how far to rotate around the X axis( YZ
rotation, or “pitch”); how far to rotate around the Y axis (XZ plane, or “yaw”); and how
far to rotate around the Z axis (XY rotation, or “roll”). Conceptually, you do the three
rotations separately. First, you rotate around one axis, followed by another, then the last.
The order of rotations is important when you cascade rotations; we will rotate first around
the Z axis, then around the X axis, and finally around the Y axis.
To show how the rotation formulas are derived, let’s rotate the point <x,y,z> around the Z
axis with an angle of T degrees.
ROLL:-
If you look closely, you should note that when we rotate around the Z axis, the Z element
of the point does not change. In fact, we can just ignore the Z – we already know what it
will be after the rotation. If we ignore the Z element, then we have the same case as if we
were rotating the two-dimensional point <x,y> through the angle T.
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download 3d Transformations 2-Computer Graphics-Lecture Notes and more Study notes Computer Graphics in PDF only on Docsity!

Lecture No.18 3D Transformations II

Rotation Rotation is the process of moving a point in space in a non-linear manner. More particularly, it involves moving the point from one position on a sphere whose center is at the origin to another position on the sphere. Why would you want to do something like this? As we will show in later section, allowing the point of view to move around is only an illusion – projection requires that the POV be at the origin. When the user thinks the POV is moving, you are actually translating all your points in the opposite direction; and when the user thinks the POV is looking down a new vector, you are actually rotating all the points in the opposite direction; and when the user thinks the POV is looking down a new vector, you are actually rotating all the points in the opposite direction.

Normalization: Note that this process of moving your points so that your POV is at the origin looking down the +Z axis is called normalization.

Rotation a point requires that you know the coordinates for the point, and That you know the rotation angles.

You need to know three different angles: how far to rotate around the X axis( YZ rotation, or “pitch”); how far to rotate around the Y axis (XZ plane, or “yaw”); and how far to rotate around the Z axis (XY rotation, or “roll”). Conceptually, you do the three rotations separately. First, you rotate around one axis, followed by another, then the last. The order of rotations is important when you cascade rotations; we will rotate first around the Z axis, then around the X axis, and finally around the Y axis.

To show how the rotation formulas are derived, let’s rotate the point <x,y,z> around the Z axis with an angle of  degrees. ROLL:-

If you look closely, you should note that when we rotate around the Z axis, the Z element of the point does not change. In fact, we can just ignore the Z – we already know what it will be after the rotation. If we ignore the Z element, then we have the same case as if we were rotating the two-dimensional point <x,y> through the angle .

docsity.com

This is the way to rotate a 2-D point. For simplicity, consider the pivot at origin and rotate point P (x,y) where x = r cos and y = r sin If rotated by  then: x = r cos( + ) = r cos cos – r sin sin and y = r sin( + ) = r cos sin + r sin cos

Replacing r cos with x and r sin with y, we have: x = x cos – y sin and y = x sin + y cos and z = z (as it does not change when rotating around z-axis)

Now for rotation around other axes, cyclic permutation helps form the equations for yaw and pitch as well:

In the above equations replacing x with y and y with z gives equations for rotation around x-axis. Now in the modified equations if we replace y with z and z with x then we get the equations for rotation around y-axis.

X Y

Z

docsity.com

earlier, you can consider each column to be a vector, so when we multiply by a matrix, we are just doing a bunch of vector multiplies. So which vector multiply do you use-the dot product, or the crosss product? You use the dot product. We also follow on simple rule when multiplying a matrix by something: mubliply each ro by the multiplier. Again, rows are just vectors, and the type of ultiplicaiton is the dot product. Let’s look at some examples. First, let’s assume that I have a matrix M, and I want to multiply it by a point < x,y,z>, the first ting I know is that the vector rows of the matrix must contain three elements (in other words, three columns). Why? because I have to multiply those rows by my point using a dot product, and to do that, the two vectors must have the same number of element. Since I am going to get dot product for each row in M, I will end up with a tuple that has one element for each row in M. as I stated earlier, we work almost exclusively with square matrices, since I must have three columns, M will also have three rows. Lets see: |1 0 0| < x,y,z> * |0 1 0| ={<x,y,z>*< 1,0,0> ,<x,y,z> < 0,1,0 >,< x,y,z > *<0,0,1>}={ x,y,z} |0 0 1|

Using Matrices for Rotation

Roll (rotate about the Z axis):

Pitch (rotate about the X axis):

Yaw (rotate about the Y axis):

sin cos 0 0

cos sin 0 0

z

y

x

z

y

x

0 sin cos 0

0 cos sin 0

z

y

x

z

y

x

sin 0 cos 0

cos 0 sin 0

z

y

x

z

y

x

docsity.com

Example: To show this happening, let's manually rotate the point <2,0,0> 45 degrees clockwise about the z axis.

Now you can take an object and apply a sequence of transformations to it to make it do whatever you want. All you need to do is figure out the sequence of transformations needed and then apply the sequence to each of the points in the model. As an example, let's say you want to rotate an object sitting at a certain point p around its z axis. You would perform the following sequence of transformations to achieve this:

The first transformation moves a point such that it is situated about the world origin instead of being situated about the point p. The next one rotates it (remember, you can only rotate about the origin, not arbitrary points in space). Finally, after the point is rotated, you want to move it back so that it is situated about p. The final translation accomplishes this.

docsity.com

The next step would be to rotate the object w.r.t. x-axis through angle .

Then the object is translated such that the arbitrary axis gets back to its original position.

And thus the job is done. An interesting usage of compound transformations:-

docsity.com

Now, if the arbitrary axis is not parallel to any of the coordinate axes, then the problem is slightly more difficult. It only adds to the number of steps required to get the job done. Let P1, P2 be the line arbitrary axis.

In the first step, the translation takes place that coincides the point P1 to the origin. Points after this step are P1’ and P2’.

docsity.com

In the next step the object of interest is rotated around z-axis.

Now the object of interest is rotated about origin such that the arbitrary axis is poised like in above figure. Point P2’’ gets back to its previous position P2’.

docsity.com

Finally the translation takes place to position the arbitrary axis back to its original position.

Scaling Coordinate transformations for scaling relative to the origin are X= X. Sx Y = Y. Sy Z` = Z. Sz Scaling an object with transformation changes the size of the object and reposition the object relative to the coordinate origin. If the transformation parameters are not all equal, relative dimensions in the object are changed.

Uniform Scaling : We preserve the original shape of an object with a uniform scaling ( Sx = Sy = Sz)

Differential Scaling : We do not preserve the original shape of an object with a differential scaling ( Sx <> Sy <> Sz)

Scaling relative to the coordinate Origin:

Scaling transformation of a position P = (x, y, z) relative to the coordinate origin can be written as

Scaling with respect to a selected fixed position:

z

y

x

S

S

S

docsity.com

The matrix representation for this reflection of points relative to the Y axis

The matrix representation for this reflection of points relative to the xy plane is

Shears Shearing transformations can be used to modify object shapes. As an example of three-dimensional shearing, the following transformation produces a z-axis shear:

Parameters a and b can be assigned and real values. The effect of this transformation matrix is to alter x and y- coordinate values by an amount that is proportional to the z value, while leaving the z coordinate unchanged.

y-axis Shear

x-axis Shear

b

a

c

a

c

b

docsity.com