Nicholas Chiasson - 100891716 - October 25, 2015
-
Task 1 - Using vector operations and transformations
-
Given a point P = (Px, Py, Pz) and an object, O = (Ox, Oy, Oz)... 1. First, translate P to the origin.
Note: since the rotational axis is the x axis, we only really need to transform P to the x axis.
Next, apply the rotation of angle ø to the object around the x axis. Lastly, translate P back to its original location.
We would start with the coordinate matrix, which would look like this:
Ox Oy Oz 1
The first translate matrix would look like this:
1 0 0 -Px 0 1 0 -Py 0 0 1 -Pz 0 0 0 1
The rotation matrix would look like this:
1 0 0 0 0 cos(ø) -sin(ø) 0 0 sin(ø) cos(ø) 0 0 0 0 1
The second translate matrix would look like this:
1 0 0 Px 0 1 0 Py 0 0 1 Pz 0 0 0 1
2. P = (1, 2, 3), O = (4, 5, 6), and a = 30 degrees.
```
| 1 0 0 1 | | 1 0 0 0 | | 1 0 0 -1 | | 4 | | 4 |
| 0 1 0 2 | | 0 cos(30) -sin(30) 0 | | 0 1 0 -2 | | 5 | | 3 |
| 0 0 1 3 | | 0 sin(30) cos(30) 0 | | 0 0 1 -3 | | 6 | | 7 |
| 0 0 0 1 | × | 0 0 0 1 | × | 0 0 0 1 | × | 1 | = | 1 |
```
-
v = (2, 3, 4) and u = (1, 5, 7). Find the angle ø between u and v...
To do this, we must divide the dot product of u and v by the product of their lengths, then take the inverse cosine of the resulting value.
Note: cos-1 = cosine inverse, |u| = length of a vector u, and sqrt(x) is the square root of a number x.
ø = cos-1((u • v) ÷ (|u| × |v|))
ø = cos-1((2 × 1 + 3 × 5 + 4 × 7) ÷ (sqrt(4 + 9 + 16) × sqrt(1 + 25 + 49)))
ø = cos-1(45 ÷ (sqrt(29) × sqrt(75))) = cos-1(45 ÷ 46.63688952)
ø = 15.2º
-
Given triangle T p0 = (1, 1, 1); p1 = (-1 ,-1, -1); p2 = (-1, 1, -1); 1. Find the normal, normalize it, and show figure for correctness (figure attached in Figure131.png).
Determine the plane with vectors p0p1 = (-2, -2, -2) and p0p2 = (-2, 0, -2)
The resulting cross product of p0p1 and p0p2 is the normal vector v to triangle T.
v = p0p1 × p0p2 = ((-2) × (-2) - (-2) × 0, (-2) × (-2) - (-2) × (-2), (-2) × 0 - (-2) × (-2)) = (4, 0, -4)
To normalize v, we divide its components by its length. So after normalization...
v = (4 ÷ sqrt(16 + 16), 0, (-4) ÷ sqrt(16 + 16)) = (4 ÷ 5.7, 0, (-4) ÷ 5.7) = (0.7, 0, -0.7)
2. To find the angle that is adjacent to p0, we need to divide the dot product of p0p1 and p0p2 by
the product of their lengths, and take the inverse cosine of the resulting value.
ø = cos-1((p0p1 • p0p2) ÷ (|p0p1| × |p0p2|))
ø = cos-1(8 ÷ (sqrt(12) × sqrt(8)))
ø = cos-1(0.82)
ø = 35.26º
3. The area a of triangle T is equal to half the length of the cross product of p0p1 and p0p2.
a = |p0p1 × p0p2| ÷ 2 = |((-2) × (-2) - (-2) × 0, (-2) × (-2) - (-2) × (-2), (-2) × 0 - (-2) × (-2))| ÷ 2
a = |(4, 0, -4)| ÷ 2
a = sqrt(32) ÷ 2
a = 2.828
-
Heroine must defend against a javelin with her shield.
Note: For this question, I have used the shield coordinates stated in the question, NOT the figure.
- Javelin velocity v = (0, -12, 11)
- Shield coordinates:
- s0 = (5, 1, 0)
- s1 = (5, 2, 5)
- s2 = (10, 3, 10)
- Point of impact p = (6.6, 2, 2.6)
- s0s1 = (0, 1, 5)
- s0s2 = (5, 2, 10)
First we will calculate the normalized cross product of s0s1 and s0s2 to find the normal vector of the shield. Then we will find the angle ø between that normal n and the normalized negative javelin velocity v'. If that angle is less than 30º, then that means that the angle between the javelin and the shield is greater than 60º, and so the shield will not successfully defend the heroine.
s0s1 × s0s2 = (10 - 10, 25 - 0, 0 - 5) = (0, 25, -5)
n = (s0s1 × s0s2) ÷ |s0s1 × s0s2| = (0, 25, -5) ÷ sqrt(650)
n = (0, 0.980580675, -0.196116135)
v' = -v ÷ |v| = (0, 12, -11) ÷ sqrt(265)
v' = (0, 0.73715414, -0.675724628)
ø = cos-1(n • v')
ø = cos-1(0.855359606)
ø = 31.2º
Since our angle ø is greater than 30º, the angle between the javelin contact and the shield surface is less than 60º. This means that the shield successfully defended against the javelin.
-
Find the transformation matrix which is required to rotate an object around the vector p1 - p0 where p0 = (1, 1, 1) and p1 = (2, 3, 4).
v = (p1 - p0) ÷ |p1 - p0|
v = (0.267261241, 0.534522483, 0.801783725)
What we first need to do is translate the point p0 to the origin. What we then need to do is rotate p1 such that it is aligned with a major axis, then after we rotate around that axis, apply the inverse rotation to p1, and translate p0 back to (1, 1, 1).
If we want to align with the z axis, we have to compute a couple angles. We need to find the dot product between v and the z, as well as the dot product between v and y with v's z value as 0. Using those two dot products, we can find the angles required to rotate v by to align it with the z axis. We will then add those rotation matrices to our multiplication.
Since v • (0, 1, 0) is just v's y value, we can ommit the dot product step, and just divide by v's length.
roll = cos-1(0.534522483 ÷ |(0.267261241, 0.534522483, 0)|)
roll = 26.565051134202º = 27º
Since v • (0, 0, 1) is just v's z value, we can ommit the dot product step, and just divide by v's length.
pitch = cos-1(0.801783725 ÷ |(0.267261241, 0.534522483, 0.801783725)|)
pitch = 36.699225173097º = 37º
Using the acquired roll angle, we will roll v about the z axis and align it with the y-z plane. All that's left from there is to pitch (rotate about the x axis) v so that it is aligned with the z axis.
| 1 0 0 0 | | cos(-27) -sin(-27) 0 0 | | 1 0 0 -1 | | x | | 0 cos(-37) -sin(-37) 0 | | sin(-27) cos(-27) 0 0 | | 0 1 0 -1 | | y | | 0 sin(-37) cos(-37) 0 | | 0 0 1 0 | | 0 0 1 -1 | | z | | 0 0 0 1 | × | 0 0 0 1 | × | 0 0 0 1 | × | 1 | Used to transform to align vector with z axis. | cos(ø) -sin(ø) 0 0 | | sin(ø) cos(ø) 0 0 | | 0 0 1 0 | | 0 0 0 1 | × (Aligned Matrix) Used for our main rotate operation (we rotate about z because we aligned our vector with the z axis). | 1 0 0 1 | | cos(27) -sin(27) 0 0 | | 1 0 0 0 | | 0 1 0 1 | | sin(27) cos(27) 0 0 | | 0 cos(37) -sin(37) 0 | | 0 0 1 1 | | 0 0 1 0 | | 0 sin(37) cos(37) 0 | | 0 0 0 1 | × | 0 0 0 1 | × | 0 0 0 1 | × (Rotated Matrix) Used to transform vector back to original position after the rotation operation.