Math Moments – Solving Real-World Problems

Alright, let’s start with a problem that you might want to solve if you were driving a “space shuttle” in the middle of deep space (perhaps in a video game). You have 5 orbs floating in space at the same locations of the 5 points picked in the “Building a Curved Path” (cubic splines) post a few weeks ago.

The problem is: You want to fly through the same 5 points and catch the orbs in your net as you pass by them.  You want to minimize the fuel that it takes to “accelerate” your shuttle along a curved path passing through the 5 points.  What would be your optimum path?

You can set the speed and direction you will be traveling as you fly by each of the points.  It is obvious that the speed and directions we picked in the original “Curved Path” would not give you the optimal path, it even makes a “curlycue” loop.  So how would you figure out the optimal speeds and directions that will give you an optimal curve for the shuttle?

One way is to follow a straight line between points, stopping at each point, then turning toward the next point and speeding up again. You would have to speed up, then slow to a stop and pick up an orb at each point.  To conserve fuel, you would not be able to speed up very fast between points and would end up slowly “coasting” along the lines between each of the points and you must use your fuel to stop again.  This would work, but it might be slow and boring, especially if the points are spread far apart.

The way that would be most fun is to build up some speed and figure out the optimal way to change direction so that your net will scoop up the orbs on the fly as you pass by them.  Keep in mind that every time you change direction, or accelerate, you are using fuel.  Coasting in a straight line, with zero acceleration, does not cost you any fuel.

So, the idea is to minimize your acceleration along your whole path (x(t), y(t)).  Recall that your direction and speed (velocity “v”) is determined by the derivatives of your position along the path:

  (vx(t), vy(t)) = (dx/dt, dy/dt)

Your acceleration “a” is determined by how fast your velocity is changing.  And so, the derivative of your velocity is your acceleration:

(ax(t), ay(t)) = (dvx/dt, dvy/dt).

Now comes the key innovation: to save time and typing, we are going to start using the notation of “linear algebra” to solve the problem.  We will use bold-faced letters (p, v, a) (position, velocity, acceleration) to denote these “vector” entities, with the understanding that these bolded letters represent the whole “vector” consisting of all the components:

p(t) = (x(t), y(t))
v(t) = (vx, vy)
a(t) = (ax, ay)

Now we take this a step further, we will use the same “cubic” basis we used in “Building a Curved Path” to write out the curve, we will express this as the vector “b”:

b(t) = (1, t, t2, t3)

and using the “dot product” notation we write the equations:

x(t) = (cx1, cx2, cx3, cx4).(1, t, t2, t3) = cx.b(t)
y(t) = (cy1, cy2, cy3, cy4).(1, t, t2, t3) = cy.b(t)

where the “cx, and cy” vectors of coefficients that determine the shape of the curve. Please refer back to the “Building a Curved Path” post for clarity.  So, the shortened notation for the equations of the curve is:

p(t) = (x(t), y(t)) = (cx.b(t), cy.b(t)) = [cx, cy].b(t)

There is conserved complexity in this simplified notation.  First of all, the [cx, cy] is a vector of vectors, representing both the 4 coefficients for the x(t) (cx) and the 4 coefficients for the y(t) (cy) functions. (8 coefficients in all).  Now you can see why we save a lot of typing with this notation.

[cx, cy] (a vector of vectors) is also referred to as a “matrix” the 4 cx coefficients are sometimes written as the first row and the 4 cy coefficients as the second row, so this “matrix” is referred to as a 2×4 matrix (C).  And again, by conservation of complexity, we can also write matrixes as bold capital letters:

C =  [cx, cy]

Thus, the equation for the curve can be written in matrix form simply as:

p(t) = [cx, cy].b(t) = C.b(t)

and we just need to find the 8 coefficients in the C matrix to completely determine the curve.

C is a 2×4 matrix and b(t) is a 4×1 vector.  This notation not only makes things easier to write down, but it turns out to be very helpful (similar to the reason we used the “dot product” notation).

Another reason this is so helpful, is because if you want to take derivatives you just need to find the derivatives of b(t), which is more simple than taking derivatives of x(t) or y(t):

b(t) = (1, t, t2, t3)
db/dt = (0, 1, 2*t, 3*t2)
d2b/dt2 = (0, 0, 2, 6*t)

The expression d2b/dt2 means the “second derivative” of b, or the derivative of the derivative.

So, since the C matrix does not change when you take derivatives only on the b(t) vector,

p(t) = (x(t), y(t)) = C.b(t)
v(t) = (vx, vy) = C.(db/dt)(t)
a(t) = (ax, ay) = C.(d2b/dt2)(t)

and we have found the linear-algebra equations for three important characteristics of this curve, the position, velocity, and acceleration at every point “t” along the curve.

Note that we have not changed the equations, just how we write them down. Believe it or not, this notation makes it much easier to find the unknown coefficients in the matrix C that defines the curve.  First we must specify where we want the curve to go.

Again, we set the condition that when t=0, the curve starts at the point (x0, y0).  we also set the velocity at t=0 to be (vx0, vy0).  Now we then have these 4 known numbers, we need 8 unknown numbers (in the matrix C).  From the principles of “linear algebra” if we have 8 known numbers, we can find the 8 unknown numbers in C. We still need 4 more known numbers.

We can now set the ending point to be (x1, y1) and the velocity to be (vx1, vy1) when t =1.  These are the 4 more conditions (known numbers) that we need.  These conditions at the “endpoints” are called the boundary conditions.  If we have 8 boundary conditions, then we generally can solve for the 8 unknown coefficients.

Here is how: First, write down the equations for the boundary conditions:

p(0) = (x(0), y(0)) = (x0, y0) = C.b(0)
p(1) = (x(1), y(1)) = (x1, y1) =  C.b(1)
v(0) = (vx0, vy0) = C.(db/dt)(0)
v(1) = (vx1, vy1) = C.(db/dt)(1)

Then write these boundary points (Bp) in matrix form:

Bp = [(x0, x1, vx0 vx1), (y0, y1, vy0, vy1)]
=  C.[b(0), b(1),  db/dt(0),  db/dt(1)]    (substitute for t)
= C.[(1,0,0,0), (1,1,1,1), (0,1,0,0), (0,1,2,3)]
= C.B (where B is the matrix […] above)

So these boundary conditions boil down to an equation of matrixes:

Bp =  C.B

We know Bp, it is a 2×4 matrix of boundary points and velocities.  We know B, it is a 4×4 matrix of basis functions and their derivatives at the boundary endpoints (t=0, t=1).  We just need to find the C matrix (2×4).  It wouldn’t it be nice if we could somehow “divide” by B so we can determine what the C matrix is.

It turns out that linear algebra gives us a way to do this by finding the inverse matrix of B, called B-1.  Inverse matrixes can be found on many calculators and computers. If you “dot” a matrix by its own inverse you get the “identity” matrix Id (we discussed earlier).  Dotting anything with the identity matrix is just like multiplying by number 1, anything dotted with the identity matrix just returns itself:

B.B-1 = Id = [(1,0,0,0), (0,1,0,0), (0,0,1,0), (0,0,0,1)]

In this case the calculator shows (check it out):

When
B = [(1,0,0,0), (1,1,1,1), (0,1,0,0), (0,1,2,3)]
then
B-1 = [(1,0,-3,2), (0,0,3,-2), (0,1,-2,1), (0,0,-1,1)]

And

C.Id = C

So dotting the above equation (Bp =  C.B with B-1) on both sides gives you the C matrix:

Bp.B-1 = C.B.B-1 = C.Id = C

We have found C, so now we can now write the equation for the curve:

(x(t), y(t)) = C.b(t)
= (Bp.B-1).b(t)
= Bp.(B-1.b(t))
= Bp.g(t)

And yet again we have defined a new vector:

g(t) = B-1.b(t)

called a “Green’s Function”.  Once we have this Green’s Function g(t), we just “dot” it with the Boundary matrix Bp and get the curve that fits these boundary conditions.  Let that soak in for a while.  All you have to do is change the Boundary conditions matrix Bp (the beginning and ending points and velocities) dot it with g(t) and you will automatically get the equations for the curve that “magically” matches these boundary conditions (at t=0 and t=1).  All of the “hard work” needed to find the C coefficients is contained in the Green’s function.  This makes drawing and hooking together the curves easy, if we know what the points and velocities are at the endpoints of the curve.  Let’s list out the Green’s function:

g(t) = (1-3*t2+2*t3, 3*t2-2*t3, t-2*t2+t3, -t2+t3)

This same Green’s Function works for all dimensions. It is easy to see how to extend this to 3-Dimensions, just put the “z” boundary conditions into the Bp matrix and it solves for z(t).

Up to this point, in solving our problem, we have made some great progress with linear algebra notation, but we still have not found the optimal velocities (speed and direction) through the points that will minimize the acceleration along the path.  However, I think that this is enough for now.  Let’s take a breather.  It might take a while for the “linear algebra” notation we have learned to make sense.

I encourage you to write out the matrixes and see specifically how these dot products work. We will continue to solve the optimal curve in our next post.

Standard

Math Moments – Kinematics

While we are here, it might be fun and instructive to work out the math for the trajectory of a falling object using the calculus tools we have developed.

Experiment has shown that if you drop an object, it starts out at 0 velocity and starts moving downward so that after 1 second it is traveling at 9.8 meters per second (m/s) downward, after 2 seconds it is traveling at 19.6 m/s downward (exactly twice as fast).  And so, the velocity in the downward direction (negative y-direction) is

  vy(t) = -(9.8 m/s/s) * t

where “t” is the time it has been dropping.

We often use the letter “g” to be the acceleration of gravity g=9.8m/s/s to show how fast things speed up when they are dropped. It is measured in meters per second per second.

Thus, when we drop an object, we then can calculate the speed that it will be falling at every moment “t”:

vy(t) = -g * t

We want to find the position of how far it has dropped at every moment “t”:

vy(t) = dy/dt = -g * t
y(t) = ?

We can use differentials and the Integral function from the previous post to figure this out, we drop the object at some height when t=0, “y(0)”, and want to know the height at any time “t”, “y(t)”:

dy = -g * t * dt

Iy(0)y(t)(dy) = I0t(-g*t*dt)

y(t) – y(0) = I0t(-g*t*dt)

We can find this Integral if we know the Anti-Derivative of -g*t:

AD(-g*t) = -g*t2/2 + C

Which you can check by taking its derivative again.  And so, we can solve the integral I0t(-g*t*dt):

y(t) – y(0) = AD(-g*t)(t) – AD(-g*t)(0)

y(t) – y(0) = (-g*t2/2 + C) – (0 + C)
y(t) – y(0) = -g*t2/2     or
y(t) = y(0) – g*t2/2

which gives you the y(t) coordinate of the object that you dropped from a height y(0) at all values of “t”.  This is proven out by experiment.

Let us figure out Newton’s problem of finding the trajectory (x(t), y(t)) of a cannon ball that is shot in a direction (Dx, Dy) at a speed “S” at the time “t=0”.  We set up the coordinate so that “y” is pointing in the upward direction and “x” is pointing horizontally in the direction the cannon is fired.  We know the velocity at t=0, and the position of the cannon is (0, 0):

(vx(0), vy(0)) = (Dx, Dy)*S
(x(0), y(0)) = (0, 0)

So since

(vx(t), vy(t)) = (dx/dt, dy/dt)

And the velocity in the x-direction “vx” does not change vx(t) = vx(0) and the velocity in the y-direction is always decreasing vy(t) = vy(0)-g*t:

(dx, dy) = (vx(0)*dt, (vy(0)-g*t)*dt)

We integrate both sides to get:

(x(t)-x(0), y(t)-y(0)) = (vx(0)*t, vy(0)*t–g*t2/2)

(x(t), y(t)) = (x(0)+vx(0)*t,  y(0)+vy(0)*t–g*t2/2)

Finally substituting in our starting values from above:

(x(t), y(t)) = (Dx*S*t,  Dy*S*t – g*t2/2)

We have arrived at the trajectory of the cannon ball at every time “t”.  It is a simple formula that depends only on simple math that is easy to calculate.

At this point, you might sense that we can in theory solve for the trajectory of any object if we know the acceleration that is acting on it at any point in space.  This field of study is called kinematics, and it is used to figure out the trajectory of planets in orbit, or trajectories of rocket ships floating through space, or basically the path of any other object in the universe.  This is also what must have been floating through Newton’s head when he realized that these principles were universal.

Standard

Math Moments – Building a Curved Path

Finally, we have all the tools laid out and ready, we can focus on doing something constructive, or at least interesting, with the math we have learned.

Often in architecture, engineering, physics, math, chemistry, design, artwork, or any number of creative fields, we need to build paths (lines and curves) to describe motion or outline objects.

We already have drawn lines and hooked them together to make straight “angular paths”, like we did in orienteering, going in straight lines from point to point.

We start with a bunch of points placed in the order that we want our path to go through, P0, P1, P2, P3, P4.  We listed 5 here, but there could be any number of points on our path.  We will also start by looking at just the “x” coordinate of the first segment between the first two points, P0 and P1.  As we have seen, we can expand this into more dimensions (x, y, z) later.

Let’s look at the, now familiar, equation for the x coordinate of a line between the first two points P0:(x0, y0) and P1:(x1, y1):

    x(S) = x0 + Dx0*S

The independent variable “S” marks the distance traveled along this segment from P0, and the Dx0 is the x-direction of this segment between P0 and P1.  “S” starts at S=0 (at P0) and goes to S=S1 (at P1), where “S1“ is the distance of the line segment between P0 and P1.

Since this first segment of the path stops when the line reaches the end point (x1, y1) after traveling the distance between them, S1:

     x1 = x(S1) = x0 + Dx0*S1

thus

     x1 – x0 = Dx0*S1        and
     Dx0 = (x1 – x0)/S1

Substituting this expression for Dx0 into the equation of the line we get:

     x(S) = x0 + (x1 – x0)*S/S1

Notice that the ratio S/S1 can be thought of as a percentage and ranges from 0 to 1 as S goes from 0 to S1.  To avoid calculating lengths of the segments, we can use the substitution:

        t = S/S1

into the equation for a line and we get:

       x(t) = x0 + (x1 – x0)*t     where t goes from 0 to 1.

This turns out to be a very convenient way to write the equation of a line between two points.  With this equation, x(0) = x0 and x(1) = x1, and “t” marks the “percentage” traveled along the line segment, from 0% (t=0) to 100% (t=1).

Expanding this into two dimensions we get the equations for all 4 segments between the 5 points:

Segment 1:      (x(t), y(t)) = (x0, y0) + (x1-x0, y1-y0)*t
Segment 2:      (x(t), y(t)) = (x1, y1) + (x2-x1, y2-y1)*t
Segment 3:      (x(t), y(t)) = (x2, y2) + (x3-x2, y3-y2)*t
Segment 4:      (x(t), y(t)) = (x3, y3) + (x4-x3, y4-y3)*t

In each case, “t” goes from 0 to 1.  This is written out in full detail to make sure that you can see the pattern.  In two dimensions you can find the length of Segment 1 by S12 = (x1-x0)2 + (y1-y0)2.  The others are not written out, the pattern should be obvious.

Alright, we can draw lines between the points. Now let’s look at drawing curves between the points.  This becomes a bit harder to pin down because there literally are an infinite number of curves that could be drawn between these same 5 points.  We will have to specify the kind of curves we want.

We will learn how to draw curve segments between the points and put them together smoothly to form any continuous path we desire.  We could even use this math to find an equation that describes the path of a fly walking around on the ceiling.

One common way of doing this is to use a method called “cubic splines”.  With this method the coordinates of each curve are written as a “cubic” equation in t:

    x(t) = c0 + c1*t + c2*t2 + c3*t3

where we can pick any numbers we want for c0, c1, c2, and c3.  The numbers we pick determine the shape and position of the curve. We can also write this expression using the “dot” product we have discussed before:

    x(t) = (c0, c1, c2, c3).(1, t, t2, t3)

The “c”s are called the coefficients and the powers of “t” are called the basis functions.  We can now take the derivative of the x-coordinate as we learned in the last post.

      dx/dt = (c0, c1, c2, c3).(0, 1, 2*t, 3*t2)

as you recall, we can use these derivatives to find the direction of the tangent line at any point “t” along the curve.  As it turns out, we now have all the tools necessary to draw a “cubic spline” curve between the points.

We can pick “t” to be a “percentage of the curve” where “t” starts at t=0, the beginning of the curve, and goes to t=1 at the end of the curve (similar to how we drew lines).  And so:

    x(0) = (c0, c1, c2, c3).(1, 0, 0, 0)  =  x0 (Substitute t=0 into the equations above)
    x(1) = (c0, c1, c2, c3).(1, 1, 1, 1)  =  x1 (Substitute t=1 into the equations above)

written out this means:

    c0 + 0  + 0 +  0  = x0           and
    c0 + c1 + c2 + c3 = x1

and we have found that the coefficient c0 = x0 (the x-coordinate of the starting point) and the sum of the coefficients must add to x1 (the x-coordinate of the ending point).  This meets the conditions that the curve will start at the beginning point and end at the ending point.  We still need some more conditions to determine what the other c’s will be.

It is natural to also place conditions on the direction that the curve leaves the starting point and the direction it arrives at the ending point.  This is determined by the tangent direction (derivatives) at these points:

dx/dt(0)   = (c0, c1, c2, c3).(0, 1, 0, 0) = S0*Dx0
dx/dt(1)   = (c0, c1, c2, c3).(0, 1, 2, 3) = S1*Dx1

We can set S0, S1 and the directions Dx0 and Dx1 to be whatever we want and we can immediately see:

                c1                = S0*Dx0
    c1 + 2*c2 + 3*c3 = S1*Dx1

We have determined c0 and c1 from the starting point and the direction of the tangent at that point.  We can use substitutions to find the rest.  We have 4 equations and 4 unknowns and so we do this:

      3*c0 + 3*c1 + 3*c2 + 3*c3 = 3*x1   (multiply the sum by 3)
                       c1 + 2*c2 + 3*c3 = S1*Dx1  (from above)

Subtracting the second equation from the first and making substitutions for c0 and c1:

      3*c0 +   2*c1 +   1*c2 + 0*c3 = 3*x1 – S1*Dx1  (making subs)
      3*x0 + 2*S1*Dx0 + c2              = 3*x1 – S1*Dx1   (solve for c2)

          c2 = 3*x1 – 3*x0 – S1*Dx1 – 2*S0*Dx0      or
         c2 = 3*(x1 – x0) – (S1*Dx1+2* S0*Dx0)

          c3 = x1 – (c0 + c1 + c2)     (rearranging the sum)
          c3 = x1 – [x0 + S0*Dx0 + 3*(x1 – x0) – (S1*Dx1 + 2*S0*Dx0)]
          c3 = -2*(x1 – x0) + S1*Dx1 + S0*Dx0

and now we have found all the “c” coefficients.

We can now draw the curves between the points if we know the starting point (x0, y0), the ending point (x1, y1), the starting direction (Dx0,Dy0) and the ending direction (Dx1, Dy1). The S0 and S1 variables are arbitrary and can be varied to taste.  We now plug all of these coefficients into our original curve:

      x(t) = (c0, c1, c2, c3).(1, t, t2, t3)
      dx/dt = (c0, c1, c2, c3).(0, 1, 2*t, 3*t2)   = S0*Dx0 (tangent direction)

the y(t) equation follows exactly the same pattern (just substitute “y” for “x” in all the equations).  Voila, we have found a “cubic” curve that passes through these points and has these tangent directions.

We can now do the same for all of the curves between each pair of points, drawing curves through all of the points.  There is a little bit of wiggle room in these curve equations.  The S0, S1, … and direction parameters for the tangents at the points can be set at will.  Since the direction vectors are the same at the points, the curve will smoothly pass through the points in the same direction.  These direction vectors show the “nose” direction (Dx,Dy) and “speed” (S) that a fly would be traveling if it were walking along the curve. It is fun to program these equations into a computer that draws them and watch the curves change as you change the location of the points and the directions and magnitudes of the tangents at the points.  This is how most modern, curve-fitting software works.

Of course, you can use another set of “basis functions” rather than just the powers of “t”, if you wish, to possibly get a better fit on your curves.  You might also want to impose other conditions, such as minimum curvature.  Just remember, if you use more basis functions, you will have more equations to solve for, you will need more conditions, and you might need some experience in “linear algebra” to solve for the coefficients.  Happy curving!

Standard

Math Moments – Derivatives

We covered the concept of differential calculus in just the last post.  It is time to slow down just a bit, catch our breath, and explore more in depth what this all means.

First, we started out with the concept of a function.  We used the example of a curve in space where the x-coordinate (and all of the others) depend on an index “t” that indicates where each point is along this curve in space.

     x(t) = x-coordinate of a point at the index t

If you specify a “t” value, the function x(t) will give the x-coordinate of a point along the curve that corresponds to “t”.

It might not have been perfectly clear, but we assumed that the curve is made out of points that are infinitely close to each other (same as a line).  There are no gaps or kinks in the curve, such that when you increase “t” by an infinitesimally small amount “dt” it will return the coordinates of a point that is infinitesimally close along the curve.  This is the concept of a “smooth” or “continuous” function.

An example of this is a car traveling down a straight road.  Suppose the function x(t) shows how far the car has gone down the road at a time “t”.  At each time, “t”, the function x(t) will tell you the exact position of the car. Now since a car can’t instantaneously disappear from one point and appear in a new point, it always takes time to travel continuously between any two points, which means that if you look at the position of the car a billionth of a second later, the position will be very close to where it was before.

    As we discussed, “dt” is much smaller than a billionth of a second, it is the smallest amount possible without being zero.  If “t” has increased by a small amount, “t+dt”, then the x-coordinate also will have changed by a very small amount “dx”. This is what we mean by the expression:

           dx = x(t+dt) – x(t)

The derivative dx/dt is defined to be:

     dx/dt  = [x(t+dt) – x(t)]/dt

which indicates how fast “x” is changing in relation to a change in “t” at the point “t”.  We can now hopefully see why differential calculus is the mathematics of motion.  In the example of the car above, dx/dt is velocity of the car at any instant “t” along its path – it moves a distance dx in the time dt.

    In the example where:

    x(t)       =      t2
 x(t+dt)   =  (t+dt)2

   dx = x(t+dt) – x(t)
         =  (t+dt)2 –  t2
         = t2+2*t*dt + dt2 – t2   (the t2 cancels out)
         = 2*t*dt + dt2

and

    dx/dt = [x(t+dt) – x(t)]/dt
                 = 2*t       (when dt –> zero)

We say that the derivative of t2 is 2*t, which also indicates how fast x is changing in ratio to the change in t at every point along the curve.

This function and differential notation is very powerful, we can get the answers to some questions without even knowing the exact function.

Suppose that x(t) is the sum of two functions of t, f(t), g(t):

    x(t) = f(t) + g(t)    where f(t) and g(t) are smooth

     df = f(t+dt) – f(t)
     dg = g(t+dt) – g(t)

dx =         x(t+dt)                –       x(t)
         = f(t+dt) + g(t+dt)     –    (f(t) + g(t))
         = [f(t+dt) – f(t)] + [g(t+dt) – g(t)]
         =             df           +          dg

Thus the derivative is also the sum of the derivatives:

    dx/dt =  df/dt  + dg/dt.   

Suppose that x(t) is the product of two functions of t:

    x(t) = f(t)*g(t)    where f(t) and g(t) are smooth

   dx =           x(t+dt)          –       x(t)
         = f(t+dt)*g(t+dt)     –    f(t)*g(t)
         =[df + f(t)]*[dg + g(t)] – f(t)*g(t)
         = df*dg + df*g(t) + f(t)*dg + f(t)*g(t) – f(t)*g(t)
         = df*dg + df*g(t) + f(t)*dt

Thus the derivative is:

dx/dt = df*(dg/dt) + (df/dt)*g(t) + f(t)*(dg/dt)
            = (df/dt)*g(t) + f(t)*(dg/dt)     because df –> 0

dx/dt = (df/dt)*g(t) + f(t)*(dg/dt)

Notice that we must always divide differentials by differentials to get derivatives, and all differentials standing alone (dx, df, dg, dt) go to zero.

We can now use the product rule to get the derivative of:

    x(t) = t3 = t2 * t   {f(t) = t2,  g(t) = t}

we already know that df/dt = 2*t from above and

    dg/dt = [t+dt – t]/dt = 1

therefore since

dx/dt = (df/dt)*g(t) + f(t)*(dg/dt)

dx/dt =    (2*t)*t      +    t2*1
                  = 3*t2

By extending this we can show that for any power of t:

If x(t) = tn  =  t(n-1) * t

then

  dx/dt = n * t(n-1)

We can see where some of the derivative tables in your calculus book come from.

We will end off by finding the derivative for a ratio of functions:

    x(t) = f(t)/g(t)

   dx/dt = [f(t+dt)/g(t+dt)        –    f(t)/g(t)]/dt
               = [(df+f(t))/(dg+g(t)) –    f(t)/g(t)]/dt
               = [[g(t)*(df+f(t))-f(t)*(dg+g(t))]/(g(t)*(dg+g(t))]/dt
  = [g(t)*(df/dt) + f(t)*g(t)/dt – f(t)*(dg/dt) – f(t)*g(t)/dt]/ (g(t)*dg + g(t)*g(t))

and when df and dg –> 0,

    dx/dt  = [g(t)*(df/dt) – f(t)*(dg/dt)]/(g(t)*g(t))

When we learn the “algebra” of differentials, we can find derivatives for a vast array of smooth functions.

As we have seen, when we know the derivatives of a curve, we can find the direction of the tangent line at any point along the curve. Recall from the last post in 2-D:

    (Dx, Dy) = (dx/dt, dy/dt)/((dx/dt)2+(dy/dt)2)1/2

The nice thing about this notation is that it is easy to go to 3-D, 4-D, and as many -D’s that you want just by continuing the pattern.

Standard

Math Moments – Differential Calculus

Calculus deals with the mathematics of movement. In order to move from a starting point (x(S), y(S)), in 2-D, to the point next to it, you need to know how to move a tiny distance “dS” in some direction (Dx, Dy).  If we are moving along a line, then we already have a way to express this.  If (x(S+dS), y(S+dS)) is the function notation for the adjacent point along the line

(x(S), y(S)) = (x0, y0) + (Dx, Dy)*S

(we are writing this in function notation) then the line segment that connects them can be written (it works out):

       (x(S+dS), y(S+dS)) = (x(S), y(S)) + (Dx, Dy)*dS

Looking at just the x-coordinate this means:

     x(S+dS) = x(S) + Dx*dS   or

     x(S+dS) – x(S) = Dx*dS

Now it is pretty easy to see that when dS goes to zero, the distance between the x-coordinate of the ending point and the starting point  “x(S+dS) – x(S)” also goes to zero.  We can use our differential notation to express this:

       dx = x(S+dS) – x(S)

where “dx” is defined as the difference between the x-coordinates.  We now can write the differential expression:

       dx = Dx*dS

Recall that the small “dx” means differential (the infinitesimal distance moved, and the large “Dx” means the direction it moves.  See the diagram above.

Now we are ready to make the leap.  Even though dx and dS get as close as possible to zero, their ratio in this example is fixed:

                    dx/dS = Dx

This is because the Direction of the line segment is fixed and does not depend on the distance between points, no matter how small.

The concept of calculus is used to travel a tiny distance “dS” to arrive at an adjoining point.  No matter how small dS is, you can always cut it in half (dS/2) to find a point that is closer.  Recall that this concept allows us to “zoom in” to a single point throughout all eternity and never get to the point.  In calculus “dS” is called a “differential” and it is “infinitesimally” small (as close as possible to zero, without being zero).  This is the concept that makes Calculus a bit strange but also makes it interesting.

We can use the same concepts to describe what happens along a smooth non-linear curve (x(t), y(t)).  If we then move along the curve by increasing “t” by “dt”, an infinitesimal amount to the point (x(t+dt), y(t+dt)) then these two points on the curve are infinitesimally close to one another.  We define the differentials:

     (dx, dy) = (x(t+dt)-x(t), y(t+dt)-y(t))  or

        dx = x(t+dt) – x(t)

        dy = y(t+dt) – y(t)

Note that the variable “t” no longer denotes a distance, it is just an “index” that determines the position of the point on the curve.

Let’s consider an example, with just the x-coordinate.  Suppose

     x(t) = 1+ t2   then

     x(t+dt) = 1+ (t+dt)2 = 1+ t2 +2*t*dt + dt2

      dx = x(t+dt) – x(t) = 2*t*dt + dt2

      dx/dt = 2*t + dt

as dt goes to zero, we can ignore the “dt” term.

        dx/dt = 2*t

The line between these two points can be written as:

       (x(t+dt), y(t+dt)) = (x(t), y(t)) + (Dx, Dy)*dS

      (x(t+dt)-x(t), y(t+dt)-y(t)) = (Dx, Dy)*dS

Or   (dx(t), dy(t)) = (Dx, Dy)*dS

now dS2 = dx(t)2 + dy(t)2 or

          dS2 = [(dx(t)/dt)2 + (dy(t)/dt)2]*dt2

which shows that “dS” also scales with “dt”.

Once we know these relationships then we can solve for the direction (Dx(t), Dy(t)) of the line that connects two infinitesimally close points on the curve (x(t), y(t)) at the index “t”.  We use the function notation for the direction parameters to indicate that the direction of this “tangent” line depends on where it is along the curve.

Just as in the case of a line, even if dS, dt, dx, and dy go to zero, as the points get closer together, they could have ratios between them that do not go to zero.  Everything depends on the shape of the curve.  Certainly, we expect that the direction of the line will not necessarily change as the points converge.  Such a curve is called “differentiable”.

Let’s look at an example.  Suppose:

   (x(t), y(t)) = (t, t2)              then

   (x(t+dt), y(t+dt)) = (t+dt, (t+dt)2) = (t+dt, t2+2*t*dt + dt2)

   (dx(t), dy(t)) = (x(t+dt)-x(t), y(t+dt)-y(t)) = (dt, 2*t*dt+dt2)

    dS2 = dx2 + dy2 = dt2+(2*t*dt)2 = [1+(2*t)2]*dt2

since    (dx(t), dy(t)) = (Dx, Dy)*dS

              (dt, 2*t*dt+dt2) = (Dx, Dy)* [1+(2*t)2]1/2*dt

So    (Dx, Dy) = (dt, 2*t*dt+ dt2)/ [1+(2*t)2]1/2*dt

and  (Dx, Dy) = (1, 2*t + dt)/ [1+(2*t)2]1/2

And so, the direction of the line is well defined when “dt” goes to zero, and we add function notation:

     (Dx(t), Dy(t)) = (1, 2*t)/ [1+(2*t)2]1/2

This line direction is called the tangent to the curve at the point (x(t), y(t)).  At this point, this line will only touch the curve at this one singular point.

Also

   dS/dt = [1+(2*t)2]1/2

and all is solved for every location “t” on the curve.  Perhaps there are many questions remaining.  One of them being, for example, how to calculate the distance along the curve “S” from one point to another.  These questions will be left for other posts.

Standard

Math Moments – Functional Curves

So far, we have only described lines where the distance between any two points on the line is well defined by a “metric”.  Before we look at how to draw curves, let’s remind ourselves what a line looks like in math language:

     (x, y) = (x0, y0) + (Dx, Dy)*S

The starting point on the line is (x0, y0) and the direction the line takes (Dx, Dy) in a cartesian coordinate system, and “S” is the distance from the starting point. Note that “S” serves as an index or indicator for every point on the line. In math language, “S” is known as the “independent variable”. It determines the exact point on a line a distance “S” from the starting point. Of course, we assume we already know the starting point (x0, y0) and direction (Dx, Dy) of the line.

In “function notation” we put the independent variable (S) next to the “dependent variables” (x and y) in parenthesis to remind ourselves that if we pick a number for “S”, it will give us an exact point (x(S), y(S)) on the line:

     (x(S), y(S)) = (x0, y0) + (Dx, Dy)*S

This “function” notation is extremely helpful. We can use this notation to replace the variable “S” with any number or symbol we wish. For example, let us replace the variable “S” with “t” (like a “cut-paste” of “S” with “t”):

     (x(t), y(t)) = (x0, y0) + (Dx, Dy)*t

We can even replace “S” with a mathematical statement:

     (x(S+3), y(S+3)) = (x0, y0) + (Dx, Dy)*(S+3)

The rule is that whatever goes in the parenthesis in function notation it is substituted into the “function” at the appropriate place.

Now we can start drawing curves by considering functions that are “non-linear” (they don’t draw a line).  We have already looked at how to draw a circle.  You may recall that we use the same equation for a line, but instead of varying the distance “S” we varied the direction (Dx, Dy) = (Cos(t), Sin(t)), where “t” is the angle off the x-axis.  So, the equation for a circle of radius S=1, centered at (x0, y0) = (0, 0) would be written:

        (x(t), y(t)) = (Cos(t), Sin(t))

where “t” goes from 0 to 360 degrees.  We could also draw just any arc of the circle by determining the range that the angle “t” spans, for example, a quarter circle is drawn when t goes from 0 to 90 degrees.  You get the idea.

We should mention at this point that we chose “t” as the “index” that indicates where any point is on the curve.  It doesn’t tell us how much distance traveled along the curve, or even the time that it takes for a point to travel along the curve.  It is just taken as a general parameter.  In the case of the circle of radius 1, we know that the circumference is 2*Pi over 360 degrees and so the distance traveled along the circle from 0 to the angle “t” is S = 2*Pi * (t/360).

Now we can have fun drawing a bunch of curves, using this function notation.

An oval that has major axis 3 and minor axis 2 has this equation:

        (x(t), y(t)) = (3*Cos(t), 2*Sin(t))

A spiral that starts at (0, 0) and goes to (1, 0) is drawn by this equation:

        (x(t), y(t)) = ((t/360)*Cos(t), (t/360)*Sin(t))

We can also draw curves in 3-dimensions just as easily; here is a spiral around a cone:

      (x(t), y(t), z(t)) = ((t/360)*Cos(t), (t/360)*Sin(t), t/360)

We can use any non-linear equation to draw a curve, like:

(x(t), y(t)) = (-2*t+3*t2, 2*t2-5*t3+4*t4)

We could keep going all day, curves are always visually interesting.

Later we will see how we can hook curves together to form any shape we want, but first we need another tool to analyze curves, differential calculus.  It really is not as difficult as you might think, so keep tuned.

Standard

Math Moments – Finding Directions in 4-D

As we enter dimensions beyond our physical experience, it might help our understanding to look back and see patterns in smaller dimensions that still apply in larger dimensions.  Is there such a pattern when finding directions (Dx, Dy, Dz, Dt) in 4 dimensions or larger.  One obvious pattern, as dimensions increase, is the way we measure distance:

   1-D:         Dx2 = 1
   2-D:         Dx2 + Dy2 = 1
   3-D:          Dx2 + Dy2 + Dz2 = 1
   4-D:          Dx2 + Dy2 + Dz2 + Dt2 = 1

The pattern for higher dimensions is obvious. We expect this pattern to continue to any number of dimensions; we just keep adding on perpendicular triangles.  See the diagram above.

There is one problem with setting directions in higher dimensions that is not so obvious. For example, in 1-D, Dx2 = 1 means that Dx = 1 or Dx = -1, this defines the directions to be along the positive or negative x-axis.  So far so good. In 2-D, however, when Dy2 = 1, it forces Dx2 = 0, which does not indicate either a positive or negative direction along the x-axis.  This ambiguity is due to the rotational symmetry of perpendicular lines, as we have mentioned before, you can “flip” negative and positive directions around a perpendicular direction, and nothing changes.

This ambiguity of direction exists whenever we add a new dimension.  In 3-D, for example, when Dz2 = 1, it forces Dx2 + Dy2 = 0 and there are ambiguities as to where to place the direction of both the x-axis and y-axis.  To a man standing exactly on the north pole, for example, every direction is south, there is no east and west.  I have also heard it said that no matter how you comb the fuzz flat on a tennis ball, there will always be a part (singularity).

To deal with these ambiguities when any of our direction parameters is zero, it is helpful to fix the angles of the x-axis, y-axis, z-axis, etc. so that directions will not be ambiguous when you pass through the “singularities” where one or more of the direction parameters are forced to be zero.  So a man standing on the north pole, where every direction is south, still knows which angle to face if he wants to point to Paris, France.  This makes defining directions consistent.

Let us look at a way to define directions as we are increasing dimensions. We defined the angle Axy to be the angle from the x-axis in the x-y plane.  Then we defined the angle Az to be the angle off of the x-y plane in the z direction.  Listing the direction parameters for the dimensions we know:

   2D: D2 = (D2x, D2y) = (Cos(Axy), Sin(Axy))
   3D: D3 = (D3x, D3y, D3z) = (D2x*Cos(Az), D2y*Cos(Az), Sin(Az))
                 = (D2x, D2y, 0)*Cos(Az) + (0, 0, 1)*Sin(Az)

We added the “2” and “3” subscripts to indicate the dimension.

It might take you a few minutes to see the pattern.  Expanding into 4-D, we define the angle At to be the angle off the x-y-z space toward the t-axis, then continuing the pattern, the direction in 4-D is:

    D4 = (D4x, D4y, D4z, D4t) = (D3x, D3y, D3z, 0)*Cos(At) + (0, 0, 0, 1)*Sin(At)

    So putting them together and stacking them we get:

         D4x = Cos(Axy)*Cos(Az)*Cos(At)
         D4y = Sin(Axy)*Cos(Az)*Cos(At)
         D4z =                   Sin(Az)*Cos(At)
         D4t =                                   Sin(At)

And we have found the Direction parameters in 4-D, and hopefully we can see the pattern that will allow us to use the same scheme to find directions in any dimension. An interesting side note: The angle in the t-direction, At, determines how close the 4-D direction is to the t-axis. When it gets close to 90 degrees, the direction is close to the t-axis and Cos(At) is close to zero, and D4x, D4y and D4z are close to zero, this restricts motion in the x-y-z space. The faster time is moving, the more restricted the motion is in 3-D space. How strange. We will see just how strange in the following post.

Standard

Math Moments – What do Dot Products Mean?

We have seen the power of the dot products between two direction vectors.  We have shown that the dot product between two perpendicular directions is zero.  We will review this in two dimensions, because it is easier to see. Using our head reference the nose direction in 2-D is N:(Dx, Dy) and the Left ear direction is L: (-Dy, Dx):

   N.N = (Dx, Dy).(Dx, Dy) = Dx2 + Dy2 = 1
   N.L = (Dx, Dy).(-Dy, Dx) = -Dx*Dy + Dy*Dx = 0

We have also seen that we can travel to any point in 2-D (x, y) by traveling in the N direction a distance SN and then turning left and traveling in the perpendicular L direction another distance SL:

    (x, y) = N*SN + L*SL

And then we used the power of the direction dot products to see what happens when we dot these direction vectors with any point (x, y) in the 2-D space:

   N.(x, y) = N.(N*SN + L*SL) = N.N*SN + N.L*SL = 1*SN + 0*SL
                  = SN

    L.(x, y) = L.(N*SN + L*SL) = L.N*SN + L.L*SL = 0*SN + 1*SL
                 = SL

Written in concise dot product notation:

      [N, L].(x, y) = (SN, SL)

This means that dotting these “head direction vectors” (N, L) with any point gives you back the coordinates of the point in the “head frame of reference” (SN, SL), the distance traveled in the Nose direction and the distance traveled in the Left direction to arrive at the point.  From the last post, in 3-D, we saw that SN is the distance from the Nose to the perpendicular View Plane where the point lives.

We can conclude that in any dimension, if we dot the Nose direction (N) with any point we get back the “nose coordinate” in the “nose frame of reference” (SN):

     N.(any point) = SN

It might take a few moments of thought for this to sink in, but when it does, we start to realize that we can convert any point into the “nose frame of reference” no matter where our nose is pointing.  It is like rotating the reference frame into any direction we want and converting the coordinates into this “nose frame of reference”.

We might ask what happens when we dot two direction vectors together that are not perpendicular.  Suppose we have two Nose directions (N1 and N2) in 2-D:

   N1 = (Dx1, Dy1)
   N2 = (Dx2, Dy2)

Since any point (x, y) can be expressed in the N1 frame of reference, (Dx2, Dy2) can also be written in the N1 frame:

  (x, y) = N1*SN + L1*SL
  N2 = (Dx2, Dy2) = N1*SN + L1*SL

Refer to the diagram above for clarification.  Now we can easily see what happens when we dot N1.N2:

    N1.N2 = N1.(N1*SN + L1*SL) = N1.N1*SN + N1.L1*SL
               = SN

Now from the diagram we also can see that SN is just the Cos(A) because the length of N2 is 1, where A is the angle between the two directions:

   N1.N2 = Cos(A)

So, when we dot two direction vectors together, we get the Cosine of the angle between them.  This is consistent with what we have seen, because when the two directions are the same, A = 0 degrees, and when they are perpendicular, A = 90 degrees. Cos(o) = 1 and Cos(90) = 0 this is consistent with what we have shown when dotting direction vectors together so far.

   I have earned some good money from knowing this.  On one occasion, a ship captain wanted me to find the distance between two points in the ocean given the longitude and latitude of each point.  Recall that the longitude and latitude is the same as the “head direction” as seen from the center of the earth. (Axy1, Az1 and Axy2, Az2).

I realized that if I could find the angle between these two “head” directions (A), I could find the distance between the two points along the surface of the earth.  Since I know that the circumference of the earth (CE), the distance between the points is CE*(A/360).  I found N1 (the direction vector to the first point) and N2 the direction to the second point, dotted them together to find the angle: N1.N2 = Cos(A), and took home a large check (he still uses it to navigate).  Could you fill in the details?

Standard

Math Moments – How to Project 3-D on a 2-D Flatscreen

No matter where we turn our head in our 3-D world, we see the world projected on the 2-D “screen” in the back of our eyes.  These days, flat screens and cell phones are everywhere, they can display 2-D images on a flat surface that our brain interprets as being projections into a 3-D world.  From the last post, we are now equipped with math language to describe how this projection works.

We can imagine that everything we see in front of our face is displayed on a big flat screen that is always a certain fixed distance in front of our nose and moves around with our head (it could be transparent).  Let’s call this screen the “View Plane” and say that it is always placed a fixed distance (SV) perpendicular to our Nose direction (N).  This is not hard to imagine, I see lots of people carrying their cell phones around like this in front of their face all the time.

Your personal reference point (0, 0, 0), the origin, is always between your ears, the Nose direction (N), always points straight out in front of your face, the Left Ear direction (L) always points in the direction of your left ear, and the Top of head direction (T) always points through the top of your head.  This personal reference frame moves as you change the orientation of your head.

Since the View Plane in front of you is 2-D, every point on this screen can be located on a 2-D “xv-yv plane”.  Let’s draw such Cartesian coordinates on our View Plane. We choose the origin of the View Plane (0, 0) to be where our Nose direction (N) passes through the plane. We can choose the xv-axis on the plane to point to the right (opposite the L direction), and then the yv-axis would point in the Top of Head direction (T).

A single point (pixel) on this 2-D view screen (xv, yv), with a color (cv), can also be located in the 3-D world.  Start at the origin (0, 0, 0), the middle of your head, then travel a distance Sv in the N direction to arrive at the origin of the View Plane (0, 0), then from there travel along the xv-axis (in the negative L direction) a distance xv, and then along the yv-axis (in the T direction) a distance yv.  From our orienteering days, we already know how find this 3-D point in math language:

    (x, y, z) = N*Sv + (-L)*xv + T*yv
                   = [N, L, T].(Sv,-xv,yv)

And so, we can find the 3-D coordinates for any point on the 2-D View screen (xv, yv) when we know the distance to the view screen (Sv) and the orientation of the head (N).  In review, the middle of the head is always at the origin (0, 0, 0) and you are looking in the Nose direction N:(Dx, Dy, Dz) in the 3-D world, the direction vectors of the head reference frame are:

         N = (Dx, Dy, Dz)
         L = (-Dy/Dr, Dx/Dr, 0)
         T = (-Dx*Dz/Dr, -Dy*Dz/Dr, Dr)

         Dr2 = Dx2 + Dy2

In the Cartesian frame of the 3-D world around us the orientation of our head can be determined by two angles (Axy and Az).  As you remember, Axy is the angle we have rotated our head left or right in the x-axis in the x-y plane, and Az is the angle that we have tilted our head up or down off the x-y plane.  In review, the direction vector of the head is found from the following:

       Dx = Cos(Axy)*Cos(Az)
       Dy = Sin(Axy)*Cos(Az)
       Dz = Sin(Az)

The dot products of the [N, L, T] head reference vectors are:

   N.N = L.L = T.T = 1
   N.L = N.T = L.T = 0

since they are all perpendicular to each other.
We also find that:

     N.(x, y, z) = N.( N*Sv + L*(-xv) + T*yv )
                        = N.N*Sv + N.L*(-xv) + N.T*yv
                        = 1*Sv + 0*(-xv) + 0*yv
                        = Sv

     L.(x, y, z) = L.( N*Sv + L*(-xv) + T*yv )
                        = L.N*Sv + L.L*(-xv) + L.T*yv
                        = 0*Sv + 1*(-xv) + 0*yv
                        = -xv

     T.(x, y, z) = T.( N*Sv + L*(-xv) + T*yv )
                        = T.N*Sv + T.L*(-xv) + T.T*yv
                        = 0*Sv + 0*(-xv) + 1*yv
                        = yv

Another way of writing these stacked equations with dot products is simply:

      [N, L, T].(x, y, z) = (Sv, -xv, yv)

So, we can see that with this miracle matrix [N, L, T] can map a point in 3-D space onto a point (xv, yv) on a View Plane that is a distance Sv away.

Let’s finish this idea off.  Suppose we have any point in 3-D space (x, y, z), then

[N, L, T].(x, y, z) = (SN, -xN, yN)

maps (x, y, z) onto a point (xN, yN) on 2-D view plane that is a distance SN away from your nose.  Using simple geometry, this point can be mapped onto a point (xv, yv) in any parallel View Plane that is a distance Sv away by using:

    (xv, yv) = (xN, yN)*Sv/SN

And so, we can map a 3-D world onto a 2-D view plane.  Our brain perceives these 2-D images from colored points (pixels) from our flat screens as 3-D images.

Standard

Math Moments – Navigating in 3-D Space

We can navigate in 3-D to any point (xR, yR, zR), in Cartesian Coordinates, by starting at the origin (0, 0, 0) and in the 2-D, x-y plane, walking in the x-direction (1, 0, 0) a distance xR, then turning left 90 degrees and walking a distance yR in the y-direction (0, 1, 0), still on the x-y plane.  This is the same as we did in 2-D except we put an extra ‘0’ in the third ‘z’ direction.  At this point we are still on the x-y plane at the point (xR, yR, 0).  The z-direction is straight up, so we would now need a ladder to climb up or a shovel to dig down, it is helpful to pretend we can fly (or dig).  From this point (xR, yR, 0) on the x-y “ground” plane, we fly straight up in the z-direction (0, 0, 1) a distance zR, and we successfully arrive at the point (xR, yR, zR).

We can express this journey with vectors, as we did in 2-D, by connecting (adding) lines together to form the path:

   (xR, yR, zR) = (1, 0, 0)*xR + (0, 1, 0)*yR + (0, 0, 1)*zR
                        = (xR, 0, 0) + (0, yR, 0) + (0, 0, zR)
                        = (xR, yR, zR)

        And using dot product notation, this can be written:

   (xR, yR, zR) = (1, 0, 0)*xR + (0, 1, 0)*yR + (0, 0, 1)*zR
                        = [(1, 0, 0), (0, 1, 0), (0, 0, 1)].(xR, yR, zR)

The [(1, 0, 0), (0, 1, 0), (0, 0, 1)] matrix is called the identity matrix.

We could also arrive faster by flying along a straight line connecting the two. Fly along a direction (Dx, Dy, Dz), from the origin directly to this point, (xR, yR, zR) a distance “R” away:

   (xR, yR, zR) = (Dx, Dy, Dz)*R

        Where the distance ‘R’ is found by:

    R2 = xR2 + yR2 + zR2

From the equation above for this line, we can easily find the direction vector from the origin to any point (xR, yR, zR), similar to what we did in 2-D.

      (Dx, Dy, Dz) = (xR/R, yR/R, zR/R)

Recall that the direction vector always has a distance of 1 unit, as seen in the diagram above.  In the diagram, we have attempted to show a 3-D path on a 2-D piece of paper.  Note that in the diagram, Dr is the distance from the origin to the point (Dx, Dy, 0) in the x-y plane. From the Pythagorean theorem, we find that the length:

      Dr2 = Dx2 + Dy2    and
      Dr2 + Dz2 = 1        thus combining these
      Dx2 + Dy2 + Dz2 = 1.

The total length of the distance vector is 1 unit, as required.  Everything is consistent.  Now we use the definition of the ‘Sin’ and ‘Cos’ and can see, from the diagram above, that:

     Cos(Axy) = Dx/Dr
     Sin(Axy) = Dy/Dr

      Cos(Az) = Dr/1
      Sin(Az) = Dz/1

    Thus

       Dx = Cos(Axy)*Dr = Cos(Axy)*Cos(Az)
       Dy = Sin(Axy)*Dr = Sin(Axy)*Cos(Az)
       Dz = Sin(Az)

And so, if we stand at the origin facing in the x-direction, and rotate our “head” an angle Axy to the left, and then tilt our head an angle Az off the x-y plane to look directly at the point (xR, yR, zR), we can find the direction vector pointing to this point using these angles:

   (Dx, Dy, Dz) = (Cos(Axy)*Cos(Az), Sin(Axy)*Cos(Az), Sin(Az))

       And then draw the line to this point:

    (xR, yR, zR) = (Dx, Dy, Dz)*R

Now that we are staring at a point in the sky, with our nose pointed directly at the point, we can ask about “reference frame” of our head.  What direction is our left ear pointing, for example.  Our left ear is pointing in the direction, still in the x-y plane, that is 90 to the left of the Axy angle we rotated our head (-Dy/Dr, Dx/Dr, 0). We divide by Dr because in 3-D we must make the length of the direction vector equal to 1.  If this seems vague, look back and review how to find 90 degree directions in the 2-D plane in the top diagram taken from previous posts.

When we tilt our head, we can ask what is the direction that the top of our head points, 90 degrees up from the angle Az. It perhaps takes a bit more imagination to see this, since we are facing in the x-y plane (Dx/Dr, Dy/Dr, 0) and have tilted our head up to look at Dz, we find that the “shadow” of our head is pointed behind us, in the x-y plane (-Dx/Dr, -Dy/Dr, 0), then looking at the elevation Dr (when rotated 90 degrees) we find that (-Dx*Dz/Dr, -Dy*Dz/Dr, Dr) is the direction of the top of our head.  So, in the reference frame of our head:

     Direction of our Nose:     (Dx, Dy, Dz)
     Direction of Left ear:         (-Dy/Dr, Dx/Dr, 0)
     Direction of Top of head:  (-Dx*Dz/Dr, -Dy*Dz/Dr, Dr)

Let us verify that these direction vectors all have a length of 1.  The Nose direction we have verified.  For the Left ear direction:

    L.L = (-Dy/Dr)2 + (Dx/Dr)2 + 02 = (Dy2 + Dx2)/Dr2 = 1

For the Top of head direction:

    T.T = (-Dx*Dz/Dr)2 + (-Dy*Dz/Dr)2 + Dr2 = (Dy2 + Dx2)*Dz2/Dr2 + Dr2
                                                                    = Dz2 + Dr2 = 1

Now let’s find what happens when we find the dot product of these direction vectors, we will call them the N, L, and T directions respectively.

N.N = (Dx, Dy, Dz).(Dx, Dy, Dz) = Dx2 + Dy2 + Dz2 = 1

N.L = (Dx, Dy, Dz).(-Dy/Dr, Dx/Dr, 0) = -Dx*Dy/Dr + Dy*Dx/Dr + 0
                                                                  = 0

N.T = (Dx, Dy, Dz).(-Dx*Dz/Dr, -Dy*Dz/Dr, Dr)
        = -Dx2*Dz/Dr + -Dy2*Dz/Dr + Dz*Dr
        = -(Dx2 + Dy2)*Dz/Dr + Dz*Dr
        = -Dr2*Dz/Dr + Dz*Dr
        = 0

L.T = (-Dy/Dr, Dx/Dr, 0).( -Dx*Dz/Dr, -Dy*Dz/Dr, Dr)
       = Dy*Dx*Dz/Dr2 + -Dx*Dy*Dz/Dr2 + 0
       = 0

We also verified that L.L = 1 and T.T = 1 above.  So, in general, if we dot any of these N, L, T direction vectors with themselves, we get ‘1’, but if we dot any of them with each other, we get ‘0’.  It turns out that this is a requirement for any three perpendicular direction vectors in a 3-D Cartesian reference frame.  I find the “head” reference frame to be more natural because we can relate to it better, so I use this reference frame for whatever direction I am looking.  It is also a great reference frame for video games.

We have already seen from perpendicular 2-D paths how we can convert between a reference frame to our “ground” x-y-z reference frame.  To understand this, let’s take a journey: Fly in the Nose direction a distance SN, then fly in the Left ear direction a distance SL, and then in the Top of head direction a distance ST.  Then we will arrive at the point:

    (x, y, z) = N*SN + L*SL + T*ST

       or in dot product notation:

     (x, y, z) = [N, L, T].(SN, SL, ST)

This amazing equation lets you convert any point in your “head frame” of reference (SN, SL, ST), when your Nose is pointing in a direction N:(Dx, Dy, Dz), to a point in the “ground” frame (x, y, z).  You might also want to do this the other way around.  Review how we did this in 2-D, by “dotting” each side by each of the direction vectors, we get:

    (SN, SL, ST) = [N, L, T].(x, y, z)

This is how video games convert a 3-D world, stored in “ground” (x, y, z) coordinates, into the perspective of the viewer’s head (SN, SL, ST) coordinates.  The details need to be worked out but using this equation we can map a 3-D world onto a 2-D screen in the viewer’s perspective, no matter the relative direction of the viewer’s head.  We will stop here, there is a lot to take in.

Standard