141 views

Uploaded by TrailerUK

- Pallin Drome
- Tetris Tutorial in C++ Platform Independent Focused in Game Logic for Beginners _ Javilop
- C# (Nishant Orignal Copy)
- Matrix
- quiz on plotting and translation
- SKC mosesConvention
- norman rockwell 751
- Kinematics
- 241031852 Kinematics of Robots
- Math Resarch paper
- GE KKTanks Interactive LIO PDF
- Affinity Diagram
- 14nopakitl Maths Investigation
- DistanceMatrix.java
- Bussines Statistics
- Visualizing Maths
- CG_MR
- rotation_matrix_representations.pdf
- 3 d Arbitrary Rotate
- Tutoriais Do AutoCAD 2010 Para Iniciantes, Como Aprender o Trabalho Mais Fácil GT

You are on page 1of 38

Contents:

a. Drawing the vertices in 3DS Max

b. Exporting the vertices to Excel

2. 2D Transformation

a. Translation

b. Scaling

c. Shearing

d. Rotation around an arbitrary point

e. Reflection across the X and Y axis

f. Reflection across an arbitrary axis

3. 3D Transformations

a. 1 Point Perspective

(i). Vanishing Points

b. 2 Point Perspective

c. 3 Point Perspective

d. General Perspective

e. Orthographic

f. Scaling

g. Shearing

h. Rotation around an axis

i. Rotation around an arbitrary axis

j. Reflection in a arbitrary plane

1. Obtaining the vertices of a 2D Image

To begin this assignment, I had to first plot the 2D vertices of a chosen

vehicle. I decided to use a helicopter. I decided to use the following side

view image of a helicopter to plot my co-ordinates.

then used the line tool to trace around the image, plotting my co-

ordinates. Below are a couple of images showing the process.

After I had drawn each part of the helicopter as a separate line I had to

export these co-ordinates into excel. To do this, I selected the part of the

helicopter I wanted the co-ordinates for and chose to export it as a

Wavefront Object. This produced an .Obj file, which contained the X, Y and

Z co-ordinates of the helicopter part and was also readable in any

common text reader such as notepad. This was good as it allowed me to

easily copy the co-ordinates into excel without too much trouble. The

reason for each part of the helicopter being split up is because when

trying to draw the helicopter as a graph in excel, if there was no split then

all parts would be joined.

A Wavefront (.Obj) file open in Notepad

After I had exported the helicopter from 3D Studio Max and imported all

the X, Y and Z data into excel I plotted the co-ordinates on a scatter graph

and joined the lines. Below is the final result.

2. 2D Transformations

see the following transformations being implemented:

• Translation

• Scaling

• Shear

• Rotation

• Reflection

Screenshots as well as short descriptions will be produced to explain how I

achieved each transformation. In the screenshots, the blue helicopter will

represent the original position, whereas the red helicopter will represent

the helicopter with the transformation applied.

2a. Translation

The first transformation I applied to the helicopter was a translation.

Translation is used to move an object along the X and Y axis. In 2D, the

matrix to achieve this is a 3x3 matrix as shown below.

b=distance along the Y axis

Example:

If I wanted to move the helicopter 150 units along the X axis and 200 units

along the Y axis the matrix would look like:

2b. Scaling

The next transformation I applied was scaling. Scaling is used to expand

or shrink and object. The matrix to achieve scaling is shown below.

b=scaling along the Y axis

However, unlike translation, scaling is factor based. This means that the

current length and height of the helicopter, will be multiplied by the

values entered for a and b.

Example

If I entered the value of 2 into a and b, both the height and width of the

helicopter would be multiplied by 2. This would create a helicopter twice

as big as the original. The matrix to achieve this is shown below.

Values less than 1 can also be applied to the scaling matrix. The result of this is a

smaller object. The image below, is a result of entering 0.5 into both a and b.

2c. Shearing

Shearing produces a distortion of the object along a specific axis

proportional to the opposite axis. The matrix to achieve shearing is shown

below.

b=shearing along the Y axis

Example

If I entered the value of 0.5 into both a and b then the helicopter would be

sheared by a factor of 0.5 along the X and Y axis. The matrix to achieve

this is shown below.

2d. Rotation around an arbitrary point

Rotation around an arbitrary point is the first transformation that requires

using multiple types of transformations. The process of rotating around an

arbitrary point requires 3 matrices. One matrix translates the point to the

origin, one performs the actual rotation and the final matrix translates the

point back to its original position. The set of matrices below shows the

process.

b =translation along the Y axis

θ=angle of rotation (in radians)

The reason for the layout being backwards is due to the way that the

matrices need to be multiplied. For them to work correctly, they need to

be multiplied in the opposite order.

The above 3 matrices would then be multiplied together to create 1 final

matrix. The coordinates of the 2D helicopter could then my multiplied

together with this final matrix to produce the coordinates of the rotated

helicopter.

Example:

If I wanted to rotate the helicopter 45° around the point (160,100) I would

substitute these values into the above matrices to produce the following

matrices. However, I would make sure I entered the degrees into the

rotation matrix as radians. 45°= 0.785398 Radians.

I would then multiply together these matrices to produce the final matrix. I

would then multiply the coordinates for each part of the helicopter to

produce the coordinates for the rotated helicopter. I can then re-plot this

rotated helicopter onto a graph as shown below.

2e. Reflection across the X and Y axis

Reflection across either the X or Y axis requires the use of 1 matrix. The matrix

used is very similar to the 3x3 identity matrix. The matrix below shows which 2

parameters affect the reflection of an object.

b position or both. The matrices below show where to specifically place

the -1 for the desired reflection.

Axis Axis Axis

(Across the X Axis)

2f. Reflection across an arbitrary axis

Reflection across an arbitrary axis is most likely the hardest 2d

transformation to achieve. The process of reflecting across an arbitrary

axis requires 5 matrices. The set of matrices required are shown below.

Just like rotating around an arbitrary point, these matrices are shown in

this order because they have to be multiplied together in this order. From

right to left the matrices above perform the following actions:

2. Rotate the arbitrary axis down so it lies on the X axis.

3. Reflect across the X axis.

4. Rotate the arbitrary axis back to its original angle.

5. Translate the arbitrary axis back up to its original position.

required (in radians) to rotate the arbitrary axis to the X axis and then

back up again.

=ATAN((b1-b)/(a1-a)

axis

a1 & b1 = X and Y coordinates of the second point of the

arbitrary axis

Example

To reflect the helicopter across an arbitrary axis equal to (0,0) (400,400)

you would replace a and b with the X and Y values of the first point. In this

case it is 0, but could be anything. The above formula is then calculated to

get the correct angle. In this example the calculation will look like the

following.

=ATAN((400-0)/(400-0)

This gives the angle:

Radians = 0.785398

Degrees = 45°

matrices to produce the following set.

The above set of matrices can then all be multiplied together to create 1

final matrix. This final matrix is then multiplied by each part of the

helicopter to achieve the transformed helicopter. The image below is proof

of this example working. The turquoise line shows the arbitrary axis.

3. 3D Transformations

see the following transformations being implemented:

• 1 Point Perspective

• 2 Point Perspective

• 3 Point Perspective

• General Perspective

• Orthographic

• Scaling

• Shearing

• Rotation around an axis

• Rotation around an arbitrary axis

• Reflection in an arbitrary plane

achieved each transformation. In the screenshots, the blue structure will

represent the original position, whereas the red structure will represent

the structure with the transformation applied.

The first 5 transformations in this section will be methods to achieve

different perspectives and ways to view a 3D object.

3a. 1 Point Perspective

The first type of perspective is 1 point perspective. A fundamental

characteristic of this perspective is that it only has 1 vanishing point.

There are 2 matrices involved to achieve this perspective. One is a

translation matrix which moves the object around the X, Y and Z axis. The

second is the projection matrix which creates the perspective. The

required matrices are shown below.

Where: d = Distance

x & y = Translation variables for the X and Y axis

Example

If I wanted to show my 3D object in 1 point perspective at a distance of 40

and position it 10 units along the X and Y axis I would substitute the d, x

and y placeholders with these numbers accordingly. The matrices would

then look like below.

matrix. When all points of the 3D object are multiplied by this final matrix

the result will be like the image below.

3a(i). Vanishing Points

To find out where the vanishing points are, a few more calculations are

required on top of the original perspective matrices. The final matrix

needs to be multiplied by a vanishing point matrix 4*3 in size. The matrix

is shown below.

The result of multiplying the above matrix by the final matrix will produce

a result in the format shown below.

following calculations are performed.

Y = d/g

Y = e/h

Y = f/i

3 vanishing points in 3 point perspective. Therefore, only calculate the

vanishing points that you require. The vanishing point for the 1 point

perspective example was worked out to be:

• (0,0).

3b. 2 Point Perspective

The second type of perspective is 2 point perspective. This type of

perspective has 2 vanishing points. There are 3 matrices involved to

achieve this perspective. One is a translation matrix which moves the

object around the X, Y and Z axis. The second is a rotation around the Y

axis. This is what adds the 2nd vanishing point. The 3rd and final matrix

required is the projection matrix. The matrices described above are shown

below.

Where: d = Distance

x & y = Translation variables for the X and Y axis

θ = Angle to rotate object around the Y axis

(Radians)

Example

If I wanted to show my 3D object in 2 point perspective at a distance of 40 and

position it 10 units along the X and -100 units along the Y axis I would substitute

the d, x and y placeholders with these numbers accordingly. I would also enter

the value of 0.785398 Radians (45 Degrees) into the rotation matrix. I chose 45°

as I feel it best represents 2 point perspective. The matrices with the required

data would then look like below.

matrix. When all points of the 3D object are multiplied by this final matrix

the result will be like the image below.

Using the previous section to calculate the vanishing points, in this example the

2 vanishing points are:

• (40,0)

• (-40,0)

3c. 3 Point Perspective

The third type of perspective is 3 point perspective. This type of

perspective has 3 vanishing points. There are 4 matrices involved to

achieve this perspective, 1 more than 2 point perspective. This

perspective is exactly the same as 2 point perspective, apart from a

rotation around the X axis is also applied. Instead of showing the full blank

set of matrices, I will just show a blank X rotation matrix. The matrix that

is shown below will slot in just before the Y axis rotation in the final matrix

chain.

Example

If I wanted to show my 3D object in 3 point perspective at a distance of -100 and

position it 10 units along the X and Y axis I would substitute the d, x and y

placeholders with these numbers accordingly. I would also enter the value of

0.785398 Radians (45 Degrees) into the Y axis rotation matrix and 0.523599

Radians (30 Degrees) into the X axis rotation matrix. I chose 45° and 30° as I feel

it best represents 3 point perspective. The matrices with the required data would

then look like below.

matrix. When all points of the 3D object are multiplied by this final matrix

the result will be like the image below.

Using the section 3a(i) to calculate the vanishing points, this example gave the

following 3 vanishing points:

• (-115.47,-57.735)

• (0 ,173.2051)

• (115.4701,-57.735)

3d. General Perspective

The fourth type of perspective is general perspective. This is the main

type of perspective I have used throughout my assignment to display

most of the 3D transformations. The reason for this is that I feel it shows

the best viewpoint and does not look distorted like 1, 2 and 3 point

perspective. To achieve this type of perspective only one matrix is

needed. This 4x4 matrix contains 3 configurable parts which effectively

control where the viewpoint is positioned on the X, Y and Z axis. The

matrix below shows the layout and each configurable part.

y = Distance along the Y axis

z= Distance along the Z axis

Example

To view the 3D object I would substitute in the x, y and z distances of my

choice. For this example I will show general perspective with an x distance

of 50, a y distance of 100 and a z distance of -300. When all these values

are substituted into the x, y and z positions the matrix will appear like the

one below.

This matrix can then be multiplied by the various parts of the 3D object to

create the view perspective shown below.

3e. Orthographic

The fifth and final type of perspective is orthographic (parallel).

Orthographic perspective is often widely used in blue prints for various

structures. One of the main features of orthographic perspective is that it

keeps all angles and length in proportion. To show orthographic texture

there is only 1 matrix involved. This matrix is used to rotate around the X

axis. When the angle of rotation is 90°, the view will be top down. When the

angle of rotation is 0, the view will be side on. The matrix below shows the X axis

rotation matrix.

Example

Top down View:

The view the 3D structure top down, a rotation angle of 90° (1.570796

Radians) will be entered into the matrix above. This matrix will then be

multiplied by each part of the 3D structure. The result is shown below.

Side View:

The view the 3D structure side on, a rotation angle of 0° (Identity Matrix)

will be entered into the matrix above. As this will produce an identity

matrix, side on view is the default view for orthographic. This matrix will

then be multiplied by each part of the 3D structure. The result is shown

below.

3f. Scaling

The first transformation after perspectives I applied was scaling. Scaling is

used to expand or shrink and object. The matrix to achieve scaling in 3D is

very similar to the 2D scaling matrix. Apart from it is 4x4 in size, and has

an extra variable, the Z axis. Te matrix to scale in 3D is shown below.

y=scaling along the Y axis

z=scaling along the Z axis

Like in 2D, scaling in 3D is also factor based.

Example

If I entered the value of 2 into both x and z and 0.5 into z both the length

and depth of the 3D object would be multiplied by 2. However, the height

of the 3D object would be divided by 2 due to the 0.5. This would create a

3D object twice as big as the original along the X and Z axis, but half the

size along the Y axis. The matrix to achieve this is shown below.

3g. Shearing

In 3D, shearing produces a distortion of the object along a specific plane

proportional to the opposite planes/axis. There are 3 different matrices to

perform 3D shearing, 1 for each plane.

Plane Plane Plane

y=shearing along the Y axis

z=shearing along the Z axis

Example

XY Shearing:

To show an example of shearing along the XY plane I shall substitute the x

and y values in the first matrix to create a matrix that will shear by a

specified factor.

This matrix is then multiplied together with the projection matrix which

produces the following object.

XZ Shearing:

To show an example of shearing along the XZ plane I shall substitute the x

and z values in the first matrix to create a matrix that will shear by a

specified factor.

This matrix is then multiplied together with the projection matrix which

produces the following object.

YZ Shearing:

To show an example of shearing along the YZ plane I shall substitute the y

and z values in the first matrix to create a matrix that will shear by a

specified factor.

This matrix is then multiplied together with the projection matrix which

produces the following object.

3h. Rotation around an axis

In 3D, rotation around the X, Y or Z axis is relatively easy to achieve. To

perform all 3 at once, it requires 3 different matrices. Each fed with a

specific angle in radians. Below are the 3 different rotation matrices.

axis axis axis

Example

X Rotation:

To show an example of rotation around the X axis I shall substitute an

angle into the matrix. I shall enter 45° (0.785398 Radians). Below is the

result.

Y Rotation:

To show an example of rotation around the Y axis I shall substitute an

angle into the matrix. I shall enter 45° (0.785398 Radians). Below is the

result.

Z Rotation:

To show an example of rotation around the Z axis I shall substitute an

angle into the matrix. I shall enter 45° (0.785398 Radians). Below is the

result.

3i. Rotation around an arbitrary axis

Rotation around an arbitrary axis is where 3D transformations begin to get

hard and quite long. It requires 8 matrices, 6 of which are relatively

similar. These matrices perform the following.

1. Translate the arbitrary axis so it passes through the origin

2. Rotate the arbitrary axis around the Y axis so it lies in the YZ plane

3. Rotate the arbitrary axis around the X axis so it lies on the Y axis

4. Perform the main rotation around the z axis

5. Rotate the arbitrary axis around the X axis back to its original

position

6. Rotate the arbitrary axis around the Y axis back to its original

position

7. Translate the arbitrary axis back to its original position

8. Project everything

example using real data.

Example

For this example, I shall rotate around the line (0,0,0)(100,100,100) by 45°

(0.785398 Radians).

Step 1:

To perform step 1 a translation matrix is required which will translate the

line down to the origin. To do this the first coordinates will be inserted into

the following matrix.

Due to the first coordinates being (0,0,0) this translation matrix just

becomes a identity matrix, however if the line was anything other than

(0,0,0) this matrix would make the arbitrary axis pass through the origin.

Step 2:

The next step is to rotate the arbitrary axis so it lies on the YZ plane.

However, the angle to do this rotation is unknown. To calculate the angle

the following calculation is performed.

First the dot product needs to be found for the 2nd set of coordinates

for the arbitrary axis (100,100,100) and the Z axis. The image below

shows the calculation that is performed.

A B

In this example A.B = 1000

The reason the Y value for the A set of coordinates is set to 0 is because

the line needs to be projected onto the XZ plane for the correct angle to

be found.

Next the modulus for both A and B needs to be found. This can be

calculated in excel with the following formula.

|A| = SQRT(Ax^2+Ay^2+Az^2) = 141.4214

|B| = SQRT(Bx^2+By^2+Bz^2) = 10

calculation in excel.

= 0.785398 Radians or 45°

This angle can then be substituted into the correct rotation matrix. The

correct rotation matrix for this step is a rotation around the Y axis like

shown below.

Step 3:

In this step, the exact same is done that is done in step 2 apart from 2

small changes. These changes are that instead of reaping the calculations

with A and B, the calculation needs to be done with the arbitrary axis in

the new position after the Y axis rotation (let’s call it D). Also this time,

instead of using the Z axis to find the dot product, the Y axis is used this

time like shown below.

D C

In this example D.C = 1000

The rest of the calculation can now be performed just like in step 2

|D| = SQRT(Dx^2+Dy^2+Dz^2) = 173.2051

|C| = SQRT(Cx^2+Cy^2+Cz^2) = 10

calculation in excel.

= -0.95532 Radians or -54.7356°

This angle can then be substituted into the correct rotation matrix. The

correct rotation matrix for this step is a rotation around the X axis like

shown below.

Step 4:

Step 4 is a very simple step and just involved choosing how much you

want to rotate the 3D object around the arbitrary axis. In this example I

have chosen 0.785398 Radians or 45°. The correct rotation matrix for this

step is a rotation around the Y axis like shown below.

Step 5:

Step 5 basically performs the inverse of step 3, there is no calculation

involved. A (-) sign is added to the front of the values that are entered into

the X axis rotation matrix. Due to all the values within this matrix being

negative, they instantly become positive inverting the result of the matrix.

The matrix for this step is shown below.

Step 6:

This step is exactly the same as step 5, but instead performs the inverse

for the matrix used in step 2 to rotate around the Y axis. The matrix for

this step is shown below.

Step 7:

This step performs the inverse of step 1 to translate the arbitrary axis

back up to its original position. However, because like in step 1 the

arbitrary axis already crosses the origin this matrix does nothing and

becomes an identity matrix. Due to this, I will not show the matrix used

for this step.

Step 8:

The final step is to project the result into a suitable perspective. In this

example I used the general perspective matrix described in section 3d.

Next, all 8 of the matrices used to perform this transformation

needed to be multiplied together in reverse order, starting with the

projection matrix and ending with the first translation matrix. This created

the final matrix as shown below.

This matrix can then be multiplied with the various parts of my 3D object

to perform the following transformation.

3j. Reflection in an arbitrary plane

Reflection in an arbitrary plane is very similar to rotation around an

arbitrary axis. However there are 2 main differences. The first difference is

that the normal of the arbitrary plane becomes the arbitrary axis.

However, there is a relatively long process in calculating the normal of a

plane. The second difference is that instead of rotating around the Y axis

like in step 4, you simply reflect the object in the Y axis.

As this process is very similar to section 3i, I will only explain how to

calculate these 2 differences.

A plane has to consist of at least 3 points positioned anywhere in 3d

space. Once 3 points have been defined, the normal of this plane can be

found.

First, one of the points of the arbitrary plane must pass through the

origin. To do this it is translated down to the origin. This process is

described many times in the sections above, so will not be described this

time. Once the plane is lying on the origin there should now be 2 other

vectors coming from the origin to points in 3D space.

For the sake of this example let’s label the first vertex A and the 2nd

vertex B. To find the normal the following calculation must be done.

The result of the above calculation should give a new vector consisting of

3 numbers in terms of i, j and k. This vector can then be imported to the

set of matrices in section 3i to achieve the desired result.

Example:

Now for a proper example with real numbers, let’s use the following

coordinates for the plane.

Due to this plane already having a point on the origin there is no need to

translate it, therefore we can move straight onto finding the normal. By

applying the method shown above the image and formula below show

how it works with real numbers.

((0*30)-(0*0))i – ((30*30)-(0*0))j + ((30*30)-(0*0))k

=

0i -900j 900k

As described in the introduction to section 3j, it mentioned that step 4

from section 3i needed to be replaced with a reflection in the Y axis for the

reflection in an arbitrary plane to work correctly. The correct matrix to

achieve this is shown below.

With all the calculations and matrices correctly made from both section 3i

and 3j the reflection in an arbitrary plane should correctly work. The

image below shows it successfully working with the 3 coordinates of the

plane as

• (0,0,0)

• (30,0,0)

• (0,30,30)

- Pallin DromeUploaded byAE06 Avionics
- Tetris Tutorial in C++ Platform Independent Focused in Game Logic for Beginners _ JavilopUploaded byziedus
- C# (Nishant Orignal Copy)Uploaded byNishant Kumaria
- MatrixUploaded byDeny Doank
- quiz on plotting and translationUploaded byapi-312540278
- SKC mosesConventionUploaded byradityaak
- norman rockwell 751Uploaded bysingingman
- KinematicsUploaded bymuthupecmec4908
- 241031852 Kinematics of RobotsUploaded byEric Kerr
- Math Resarch paperUploaded byVineeth Bhaskara
- GE KKTanks Interactive LIO PDFUploaded byFrank Villari
- Affinity DiagramUploaded by5landers
- 14nopakitl Maths InvestigationUploaded byNopakit Lerthirunvibul
- DistanceMatrix.javaUploaded byYudha Agung Wirawan
- Bussines StatisticsUploaded byMahendran Kaliyathangam
- Visualizing MathsUploaded byAfwanilhuda Nst
- CG_MRUploaded bysomnathghoshal85
- rotation_matrix_representations.pdfUploaded bygireesh_star
- 3 d Arbitrary RotateUploaded bymahesh
- Tutoriais Do AutoCAD 2010 Para Iniciantes, Como Aprender o Trabalho Mais Fácil GTUploaded byArnaldoAzevedo
- Getting Started with MatlabUploaded bykc_renji85
- 1A0_0051Uploaded byArun Kumar
- 4_StartingValuesInLISREL.pdfUploaded byRocio Gill
- Keccak-reference-3.0.pdfUploaded byaymencf
- Assignment 1Uploaded byGs1995
- cwcampUploaded byHaggard72
- Maths problemsUploaded byvijay9677
- Tutorial 1Uploaded byHemant Mayatra
- chalon_thumb_2011.pdfUploaded byern_43
- Algebra MatricialUploaded byIsa Codejon Alvarez

- university of california a-g course list copyUploaded byapi-240966173
- The Rich Boy.docxUploaded byAna Munteanu
- From “I Know Why the Caged Bird Sings” ByUploaded byemysameh
- Vlahii CatalaniUploaded byAnonymous 7isTmailHuse
- windowsUploaded byapi-115852884
- Self Compiled Plot - Step to Understanding - Ana Rink - Ronny ReichmannUploaded byana_rink9404
- Codex Sinaiticus Petropolitanus, The New Testament the Epistle of Barnabas and the Shepherd of Hermas, Kirsopp Lake (1911)Uploaded byDavid Bailey
- Jaws (1975)Uploaded byJebbBobbett
- ACIDRAINIA-2Uploaded byDanielle Lone
- faith-participUploaded byapi-331363468
- Management Lesson From MahabharatUploaded byravindrawankhede
- Prajay Water Front Cityvilla BrochureUploaded bycvkraj
- Artprice Contemporary 2012 2013 EnUploaded byAndreea Bara
- Writing AnalyticallyUploaded byYazan Zamel
- Burial Theme in Moche IconographyUploaded byGiovanni Colombo
- digital storytelling assignment description and rubricUploaded byapi-269800135
- 1E05 02 Structural GlassUploaded bySushanta Takhellambam
- Shear and Moment in Beams Ch No 4Uploaded byMaqsood
- archetype detective paper with rubricUploaded byapi-370708652
- printmaking rubricUploaded byapi-227874600
- List of analogies with difficult words meanings.Uploaded byMuhammad Nawaz
- john 4-6Uploaded byapi-364204613
- Main Masterclass LessonUploaded byVictor Bolindre
- Eddie BurksUploaded byDave van Bladel
- The Life of Sri Vasudeva SwaroopamUploaded byVISHNUMAYA N
- gbw154Uploaded bysilent0ne2000
- Blonde Ambition Marilyn Monroe & the Rise and Fall of the Hollywood Studio SystemUploaded byJo-B Sebastian
- Marriage in Huancayo.docxUploaded byErikaTiclla
- how shall.pdfUploaded byJessica
- final annotated bibliographyUploaded byapi-303156272