Professional Documents
Culture Documents
Contents:
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:
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.
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.
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.
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:
=ATAN((b1-b)/(a1-a)
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°
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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
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
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.
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