Cross Product: Difference between revisions

From Graal Bible
(Replacing page with '{{antiunix}}')
m (Reverted edits by Anti-Up (Talk); changed back to last version by Stefan)
Line 1: Line 1:
{{antiunix}}
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.
 
== 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 11:38, 1 July 2007

The Cross Product is a property of 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.

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 = <u1,u2,u3>
v = <v1,v2,v3>

We can rewrite these vectors in terms of i, j, and k.

u = u1i + u2j + u3k
v = v1i + v2j + v3k

We can then "multiply" them in an algebraic manner.

u × v = (u1v1)i × i + (u1v2)i × j + (u1v3)i × k + (u2v1)j × i + (u2v2)j × j + 
        (u2v3)j × k + (u3v1)k × i + (u3v2)k × j + (u3v3)k × 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 × b = |a||b|sin(0)|n| = 0 . So, the above statement simplifies to

u × v = (u1v2)i × j + (u1v3)i × k + (u2v1)j × i + (u2v3)j × k + (u3v1)k × i + (u3v2)k × j

Because the cross product reflects the normal vector, the following hold:

i × j = -(j × i) = k
j × k = -(k × j) = i
k × i = -(i × k) = j

Then, we can simplify our equation further:

u × v = (u1v2)k + (u1v3)(-j) + (u2v1)(-k) + (u2v3)i + (u3v1)j + (u3v2)(-i)
      = (u2v3-u3v2)i + (u3v1-u1v3)j + (u1v2-u2v1)k
      = (u2v3-u3v2)i - (u1v3-u3v1)j + (u1v2-u2v1)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 matricies

        =
u2 u3
v2 v3
i -
u1 u3
v1 v3
j +
u1 u2
v1 v2
k
        =
ijk
u1u2u3
v1v2v3

The Cross Product in GraalScript

The cross product of two vector arrays in Graal can be obtained through the vectorcross(u,v) function. It's return value is a vector, w1i + w2j + w3k, where the vector w is calculated from the determinant of the above matrix.