Cross Product: Difference between revisions

From Graal Bible
No edit summary
(Replacing page with '{{antiunix}}')
Line 1: Line 1:
The Cross Product is a property of [[Vectors|vectors]]. The cross product takes two vectors and returns a third, which is perpendicular, or orthogonal, to the passed vectors. This vector is referred to as the normal vector, which normally is corrected to have a total magnitude of one in mathematics.
{{antiunix}}
 
== Definition ==
If vectors u and v are crossed ("u cross v"), the magnitude of the normal vector is equal to |u||v|sin(θ). Thus,
|u × v| = |u||v||sin(θ)||'''n'''|
|u × v| = |u||v||sin(θ)|
In other applications, this magnitude has been found to be equal to the area of the parallelogram whose vertecies are at '''0''', '''u''', '''u'''+'''v''', and '''v'''.
 
In addition,
u × '''0''' = '''0'''
u × v = -(v × u)
(ru) × (sv) = (rs) u × v (where r and s are scalars)
 
== General Application of the Cross Product ==
It is common practice in mathematics to write vecotrs as sums of th unti vectors, '''i''', '''j''', and '''k'''. These each have a magnitude of one and, from the origin, move precisely 1 unit on the x, y, and z axes respectively.
 
Say, then, that we have two vectors, u and v.
u = &lt;u<sub>1</sub>,u<sub>2</sub>,u<sub>3</sub>&gt;
v = &lt;v<sub>1</sub>,v<sub>2</sub>,v<sub>3</sub>&gt;
We can rewrite these vectors in terms of '''i''', '''j''', and '''k'''.
u = u<sub>1</sub>'''i''' + u<sub>2</sub>'''j''' + u<sub>3</sub>'''k'''
v = v<sub>1</sub>'''i''' + v<sub>2</sub>'''j''' + v<sub>3</sub>'''k'''
We can then "multiply" them in an algebraic manner.
u &times; v = (u<sub>1</sub>v<sub>1</sub>)'''i''' &times; '''i''' + (u<sub>1</sub>v<sub>2</sub>)'''i''' &times; '''j''' + (u<sub>1</sub>v<sub>3</sub>)'''i''' &times; '''k''' + (u<sub>2</sub>v<sub>1</sub>)'''j''' &times; '''i''' + (u<sub>2</sub>v<sub>2</sub>)'''j''' &times; '''j''' +
        (u<sub>2</sub>v<sub>3</sub>)'''j''' &times; '''k''' + (u<sub>3</sub>v<sub>1</sub>)'''k''' &times; '''i''' + (u<sub>3</sub>v<sub>2</sub>)'''k''' &times; '''j''' + (u<sub>3</sub>v<sub>3</sub>)'''k''' &times; '''k'''
We can remove immediately any terms where the vector is crossing itself. The angle between two parallel vectors, a and b, is 0, thus a &times; b = |a||b|sin(0)|n| = 0 . So, the above statement simplifies to
 
u &times; v = (u<sub>1</sub>v<sub>2</sub>)'''i''' &times; '''j''' + (u<sub>1</sub>v<sub>3</sub>)'''i''' &times; '''k''' + (u<sub>2</sub>v<sub>1</sub>)'''j''' &times; '''i''' + (u<sub>2</sub>v<sub>3</sub>)'''j''' &times; '''k''' + (u<sub>3</sub>v<sub>1</sub>)'''k''' &times; '''i''' + (u<sub>3</sub>v<sub>2</sub>)'''k''' &times; '''j'''
Because the cross product reflects the normal vector, the following hold:
i &times; j = -(j &times; i) = k
j &times; k = -(k &times; j) = i
k &times; i = -(i &times; k) = j
Then, we can simplify our equation further:
u &times; v = (u<sub>1</sub>v<sub>2</sub>)'''k''' + (u<sub>1</sub>v<sub>3</sub>)(-'''j''') + (u<sub>2</sub>v<sub>1</sub>)(-'''k''') + (u<sub>2</sub>v<sub>3</sub>)'''i''' + (u<sub>3</sub>v<sub>1</sub>)'''j''' + (u<sub>3</sub>v<sub>2</sub>)(-'''i''')
      = (u<sub>2</sub>v<sub>3</sub>-u<sub>3</sub>v<sub>2</sub>)'''i''' + (u<sub>3</sub>v<sub>1</sub>-u<sub>1</sub>v<sub>3</sub>)'''j''' + (u<sub>1</sub>v<sub>2</sub>-u<sub>2</sub>v<sub>1</sub>)'''k'''
      = (u<sub>2</sub>v<sub>3</sub>-u<sub>3</sub>v<sub>2</sub>)'''i''' - (u<sub>1</sub>v<sub>3</sub>-u<sub>3</sub>v<sub>1</sub>)'''j''' + (u<sub>1</sub>v<sub>2</sub>-u<sub>2</sub>v<sub>1</sub>)'''k''' (u-components are  in order)
This describes the direction of the normal vector to the vectors u and v. This sum can be expressed in [[Matrix|matricies]]
<table>
  <tr>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=</td>
    <td>
      <table frame="vsides" style="border: 1px solid black;">
        <tr>
          <td>u<sub>2</sub></td>
          <td>u<sub>3</sub></td>
        </tr>
        <tr>
          <td>v<sub>2</sub></td>
          <td>v<sub>3</sub></td>
        </tr>
      </table>
    </td>
    <td>'''i''' - </td>
    <td>
      <table frame="vsides" style="border: 1px solid black;">
        <tr>
          <td>u<sub>1</sub></td>
          <td>u<sub>3</sub></td>
        </tr>
        <tr>
          <td>v<sub>1</sub></td>
          <td>v<sub>3</sub></td>
        </tr>
      </table>
    </td>
    <td>'''j''' + </td>
    <td>
      <table frame="vsides" style="border: 1px solid black;">
        <tr>
          <td>u<sub>1</sub></td>
          <td>u<sub>2</sub></td>
        </tr>
        <tr>
          <td>v<sub>1</sub></td>
          <td>v<sub>2</sub></td>
        </tr>
      </table>
    </td>
    <td>'''k'''</td>
  </tr>
</table>
<table><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=</td><td><table frame="vsides" style="border: 1px solid black;"><tr> <td>'''i'''</td><td>'''j'''</td><td>'''k'''</td> </tr><tr> <td>u<sub>1</sub></td><td>u<sub>2</sub></td><td>u<sub>3</sub></td> </tr><tr> <td>v<sub>1</sub></td><td>v<sub>2</sub></td><td>v<sub>3</sub></td> </tr></table></td></tr></table>
 
== The Cross Product in GraalScript ==
The cross product of two vector arrays in Graal can be obtained through the vectorcross({{graycourier|u}},{{graycourier|v}}) function. It's return value is a vector, w<sub>1</sub>'''i''' + w<sub>2</sub>'''j''' + w<sub>3</sub>'''k''', where the vector w is calculated from the determinant of the above [[Matrix|matrix]].

Revision as of 09:44, 1 July 2007