ЪДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДї
               і Т     В ТДДї ЦДДї ЦДТДї ЦДДї ТДДї ЦДДДДДїі
               і є     і ЗД   є      є   є  і ЗДВЩ є      і
               і У·   ЪЩ РДДЩ УДДЩ   Р   УДДЩ Р Б  УДДДДДїі
               і  є   і Tutorial by Richard Nichols      іі
               і  УДДДЩ                            УДДДДДЩі
               АДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДЩ
                        (c)1996 Richard Nichols
ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
Hi! You are reading a tutorial in vectors by Richard Nichols of Australia...

This document is not to be reproduced in any other form than this original.
ie. don't cut bits of it up etc. Also this MUST be distributed free of charge.

The only charge from me for your use of it is that you come visit my website
at 'http://bip.concept.se/user/rich/index.htm' and tell me what you think...

Okay enough crap, let's get on to the main bit:
ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
Part One.

In part one of this tutorial we will go over the very basic act
of adding two vectors together in a variety of ways. I will give a
few ways because, although methods used in programming are often
faster and simpler, they usually don't give a good understanding of
what you are doing.

ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
What are vectors?
ДДДДДДДДДДДДДДДДД
Vectors are units which have both magnitude and direction.
For example 500 metres at 57ш is a vector.
The opposite of a vector is a scalar which is a unit with only
a magnitude. eg. 500 m.
Vectors are written in a few ways. If we assign a letter to a
vector we could write (for example): ѓ or Ї or i
                                          i    ~  .
This isn't very important though. For the purposes of this tute 
you can assume that any alphanumeretic I use is a vector.

We will mainly be dealing with direction vectors. ie. A distance
or force and a bearing eg. 134N @ 45ш. I may also refer to position
vectors which are the same as normal ones but originate from the 
origin.

ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
Vector Addition : Cartesian (rectangular coordinates)
ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
Vector Addition on our rectangular plane is easy. I will demonstrate:

Let Point A = (5, 2) and B = (-4, 1).
                                  
                                  і
                                  і
                                  і
                                  і
                                 2і             ъA
                        Bъ       1і
            <ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД>
                        -4        і             5
     Imagine a line coming from   і
     the origin and going to each і
     A & B. These are our vectors.і
                                  і
     So A + B is somewhere in     і
     between these.               

All we have to do is add the respective x and y coords together:
        x coords: (+5) + (-4) = 1
        y coords: (+2) + (+1) = 3

So A + B = (1, 3).

Easy huh? Well on to polar coordinates then...

ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
Vector Addition : Method A - Least complex - Least Understanding
ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
For those of you not familiar with polar coordinates, imagine a
plane with concentric circles as shown:
                         - |  -  
                    /      |        \
                 /         |           \
              /            |              \
           /               |                 \
        /                  |                   \
      /        More circles|here (sorry:Ascii)   \
     /                     |
    /                      |                       \
---------------------------+------------------------------
    \                      |                       / 
     \                     |
      \                    |                     /
        \                  |                    
          \                |                  /
             \             |               /
                \          |            / 
                    \      |       /    
Instead of giving an (x, y) coordinate we give a radius and degrees:
        (13, 45ш). This says a line of 13 units 45ш around from 0ш
        (and of course originating from the origin).
Where 0ш is depends on what you are doing. In Maths usually we use
to the right horizontally (-->) as 0 but in Physics it is more common
to use bearings so that upwards is 0ш (under this system we say something
travelling at 0ш is going straight ahead).

The method I am about to show here simply uses what you have already
learnt. We convert the Polar coordinates to rectangular and then add them.
We then convert them back.

We convert them like this:
                          /|
                         / |   We know what r (radius) and й (angle) are
                      r /  |   so we have to change them into x, y as shown.
                       /   |y
                      /й   |
                     +-----+
                        x
This is _very_ simple trig that everyone should know:
        x = r.cos.й
        y = r.sin.й

If you don't get it do a few equations and you should see the significance.
Convert the two vectors as above and then add them like in the first part.
Converting them back is a little more difficult:
  1st get й:  й = arctan(y/x)
  now get r:  r =   x
                 ДДДДДДД
                  cos.й
  or alternatively use pythagoras: r = ы(xэ + yэ)

Again if you're not sure do a few examples.

If that's as far into this as you want to go then you can skip past
the next two methods.

ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
Vector Addition : Method B - Intermediate - Reasonable Understanding
ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
But real men like trig. :)

This method uses what are known as the Sine and Cosine rules. This was
the first method I was taught (in Physics). It would not be particularly
useful in a programming situation.

On a triangle we must name the sides in a certain way eg.
              +
             /C\
            /   \               Where A, B, C are angles (must use caps)
        a  /     \ b            and where a, b, c are the sides.
          /       \
         /         \
        /B         A\
       +-------------+
              c
The point of this Ascii picture is that the angles have a corresponding
side of the _same_ letter. This is essential while working out using this
method. As long as you get this right it is plain sailing.

Okay here are the rules. I won't bother with the proofs for them for two
reasons a) I can't think of the top of my head b) It would take too long!

 Cosine Rule: aэ = bэ + cэ - 2bc.cos.A

 Sine Rule: sin.A = sin.B = sin.C
            ДДДДД   ДДДДД   ДДДДД
              a       b       c
This sine rule can also be inverted so that the top is the bottom and vice
versa (it's a ratio after all). It just depends on what sort of numbers
you want to work with...

Anyway on to the main bit:

The difference with this method is that we are using polar coords all the 
time. This means we must add the vectors correctly, that is end to end.
The true representation of (5, 0ш) + (3, 90ш) for example would be like this:
                                  3
                              ДДДДДДД>
                              іЩ    /
                              і    /
                            5 і   / R         O = Origin
                              і /
                              і/
                 - - - - - - -O- - - - - - - - -

Where the diagonal vector R is the resultant vector. It is now much easier
to see what is going on isn't it?

I will point out now that we will hardly ever have a right angle but I used
one to make the diagram clearer okay?

We must now name our sides like so:
                                  
                                  c
                              ДДДДДДД>
                              іЩA   B/
                              і    /
                            b і   / a         O = Origin
                              іC/
                              і/
                 - - - - - - -O- - - - - - - - -
Yeah, I know it's a spas diagram but its the best I can do with ascii.
So what do we know? We know c = 3 and b = 5 and that A = 90ш ( (3, 90ш) ).
Ah! We can use the cosine rule to work it out:
                aэ = bэ + cэ - 2bc.cos.A
substitute:     aэ = 5э + 3э - 2x5x3xcos(90)
                   = 25 + 9  - 2x5x3x0
                   = 34                 therefore:
                a  = ы34
                   = 5.830951895.......
So we now have the vector's magnitude but what about the angle? This is where
the sine rule comes in:
           sin.A = sin.C
           ДДДДД   ДДДДД
             a       c
     sin(90)/5.83= sin(c)/3
            0.172= sin(c)/3           (*3)
            0.515= sin(c)             therefore:
              c  = arcsin(.515)
                 = 31ш

Only one more thing: We want a bearing from 0ш. This is easy we can see that
all we have to do is subtract 31 from 90 which equals 59.

That's it! Now we have our resultant:  5.83 @ 59ш.

ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
Vector Addition : Method C - Expert - Excellent Understanding
ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
Personally I don't like this method; it is too much like hard work. :)
I learnt this in Maths C. It works well but is pretty useless where
computers are concerned but you should learn how to do it just to do it
for the sake of better understanding.

Suposing we had two vectors a and b. a=(10, 45ш) and b=(5, 100ш)
                                    
                                    0ш
                                            -\
   a & b are the vectors            |      /  -
                                       a  /    \ b
                                    |    /      -
                                        /        \
                                    |  /
                                      /
                                    |/
270ш- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -90ш
                                    |
                                    
Basically this method entails drawing two triangles from the two vectors:
                                    
                                    0ш
                                            -\
   a & b are the vectors            |      /|Z-
                                       a  / x  \ b     I just chucked w,x,y,z
                                    |    /  |Є  -      on there so you would
   we know a, b and а.                  /   |-z- \     be able to reference
                                    |  /    |          the next bit....
                                      /а   ©y
                                    |/------|
270ш- - - - - - - - - - - - - - - - - - -w- - - - - - - - - - - - - - - - -90ш
                                    |
What we have to do is to resovle the vectors into their respective
horizontal and vertical coords and then add them together...

Horizontal= a.cos.а + b.sin.Z
 
 If you can see that then have a lok at the diagram. It's just
 basic trig.

Now we have a problem: We don't know angle Z. We find it like so:
                                            |
                                    0ш      |Є
                                     - - -  -\- - - - - -
                                    |      /|Z\10ш     If b = 100ш then
                                       a  / |  \       the angle shown must
                                    |    /  |Є  \      be 10ш which means
                                        /   |--- \     Z=80ш.
                                    |  /    |          
                                      /45ш ©|
                                    |/------|
270ш- - - - - - - - - - - - - - - - - - -w- - - - - - - - - - - - - - - - -90ш
Great! now we can work out the horizontal distance.

Horizontal= a.cos.а    + b.sin.Z
          = 10.cos.45ш + 5.sin.80ш
          = 7.071      + 4.924
          = 12                  (near enuf)
Now we do the vertical:
Vertical  = a.sin.а    - b.cos.Z   (we are finding side y on the 1st diagram)
          = 10.sin.45ш - 5.cos.80ш
          = 7.071      - 0.868
          = 6.2

Okay now we have that lets draw our resultant diagram:
                              0ш
                              |          +
                              |        -/|      We can put out horiz & vert
                              |      -/  |      nos on here now...
                              |    -/    |6.2
                              |  -/      |
                              |-/        |
------------------------------------12--------------------------------90ш

We get the length of the vector by just using pythagoras:
        aэ = bэ  + cэ
           = 12э + 6.2э
           = 144 + 38.44
           = 182.44
         a = 13.5
                              0ш
                              |          +
                              |        -/|      
                              |  13.5-/  |      
                              |    -/    |6.2
                              |  -/      |
                              |-/A       |
------------------------------------12--------------------------------90ш

Now to get the angle is easy...We could cos, sin or tan..I'll use tan.
        tan.A = OP/AD
              = 6.2/12
              = .51666...
            A = arctan(.5166..)
              = 27.324ш
                              0ш
                              |          +
                              |        -/|      
                              |  13.5-/  |      
                              |    -/    |6.2
                              |  -/      |
                              |-/27.324ш |
------------------------------------12--------------------------------90ш

Now just to finish off make it a bearing:  90-27.324 = 62.676ш

So the answer = 13.5 @ 62.7ш

---------------------------------------------------------------------------
Sooo..That concludes the tutorial. This should be simple stuff for most
people but if you do have any trouble mail 'tiberius@mailhost.net'
for help.

Here are some questions for you. Use whichever method suits you:

1. Add (4, 10ш) and (5, 60ш)
2. Add (9, 100ш) and (12, 170ш)
3. A boat is travelling along a river at 3 knots with bearing of 39ш.
   An easterly wind is blowing at 1 knot. What is the boat's true heading
   and speed?

4. A bit more thought:

Say I have a traffic light spanning a road joined to two buildings by two
ropes as shown:   -----------------------------------
                           \60ш      60ш/
                            \          /
                             \        /
                              \      /
                               \    /     The light's weight is 150 newtons.
                                +--+
                                |[]|
                                |[]|
                                +--+

Work out the tension (or pull) in the ropes....
----------------------------------------------------------------------------
Check the answers with the vector addition program attached to this.........
----------------------------------------------------------------------------
This tutorial is (c)1996 Richard Nichols.
I take no responsibility for the feasability or correctness of this document,
or any damage it could do.

Remeber to check out my cool website at:
             'http://bip.concept.se/user/rich/index.htm/'

Byee, byee

May, 1996 - Richard Nichols