Quaternion type: Difference between revisions
Content deleted Content added
m Use proper subscripts in problem description |
|||
Line 4: | Line 4: | ||
A complex number has a real and complex part written sometimes as <code>a + bi</code>, where a and b stand for real numbers and i stands for the square root of minus 1. An example of a complex number might be <code>-3 + 2i</code>, where the real part, a is -3.0 and the complex part, b is +2.0. |
A complex number has a real and complex part written sometimes as <code>a + bi</code>, where a and b stand for real numbers and i stands for the square root of minus 1. An example of a complex number might be <code>-3 + 2i</code>, where the real part, a is -3.0 and the complex part, b is +2.0. |
||
A quaternion has one real part and ''three'' imaginary parts, i, j, and k. A quaternion might be written as <code>a + bi + cj + dk</code>. In this numbering system, <code>ii = jj = kk = ijk = -1</code>. The order of multiplication is important, as, in general, for two quaternions |
A quaternion has one real part and ''three'' imaginary parts, i, j, and k. A quaternion might be written as <code>a + bi + cj + dk</code>. In this numbering system, <code>ii = jj = kk = ijk = -1</code>. The order of multiplication is important, as, in general, for two quaternions q<sub>1</sub> and q<sub>2</sub>; <code>q<sub>1</sub>q<sub>2</sub> != q<sub>2</sub>q<sub>1</sub></code>. An example of a quaternion might be <code>1 +2i +3j +4k</code> |
||
There is a list form of notation where just the numbers are shown and the imaginary multipliers i, j, and k are assumed by position. So the example above would be written as (1, 2, 3, 4) |
There is a list form of notation where just the numbers are shown and the imaginary multipliers i, j, and k are assumed by position. So the example above would be written as (1, 2, 3, 4) |
||
'''Task Description'''<br> |
|||
Given the three quaternions and their components: |
Given the three quaternions and their components: |
||
q = (1, 2, 3, 4) = (a, b, c, d ) |
q = (1, 2, 3, 4) = (a, b, c, d ) |
||
q<sub>1</sub> = (2, 3, 4, 5) = (a<sub>1</sub>, b<sub>1</sub>, c<sub>1</sub>, d<sub>1</sub>) |
|||
q<sub>2</sub> = (3, 4, 5, 6) = (a<sub>2</sub>, b<sub>2</sub>, c<sub>2</sub>, d<sub>2</sub>) |
|||
And a wholly real number <code>r = 7</code>. |
And a wholly real number <code>r = 7</code>. |
||
Line 20: | Line 20: | ||
# The conjugate of a quaternion:<br><code>=( a, -b, -c, -d)</code> |
# The conjugate of a quaternion:<br><code>=( a, -b, -c, -d)</code> |
||
# Addition of a real number r and a quaternion q:<br><code>r + q = q + r = (a+r, b, c, d)</code> |
# Addition of a real number r and a quaternion q:<br><code>r + q = q + r = (a+r, b, c, d)</code> |
||
# Addition of two quaternions:<br><code> |
# Addition of two quaternions:<br><code>q<sub>1</sub> + q<sub>2</sub> = (a<sub>1</sub>+a<sub>2</sub>, b<sub>1</sub>+b<sub>2</sub>, c<sub>1</sub>+c<sub>2</sub>, d<sub>1</sub>+d<sub>2</sub>)</code> |
||
# Multiplication of a real number and a quaternion:<br><code>qr = rq = (ar, br, cr, dr)</code> |
# Multiplication of a real number and a quaternion:<br><code>qr = rq = (ar, br, cr, dr)</code> |
||
# Multiplication of two quaternions |
# Multiplication of two quaternions q<sub>1</sub> and q<sub>2</sub> is given by:<br><code>( a<sub>1</sub>a<sub>2</sub> − b<sub>1</sub>b<sub>2</sub> − c<sub>1</sub>c<sub>2</sub> − d<sub>1</sub>d<sub>2</sub>,</code><br><code> a<sub>1</sub>b<sub>2</sub> + b<sub>1</sub>a<sub>2</sub> + c<sub>1</sub>d<sub>2</sub> − d<sub>1</sub>c<sub>2</sub>,</code><br><code> a<sub>1</sub>c<sub>2</sub> − b<sub>1</sub>d<sub>2</sub> + c<sub>1</sub>a<sub>2</sub> + d<sub>1</sub>b<sub>2</sub>,</code><br><code> a<sub>1</sub>d<sub>2</sub> + b<sub>1</sub>c<sub>2</sub> − c<sub>1</sub>b<sub>2</sub> + d<sub>1</sub>a<sub>2</sub> )</code> |
||
# Show that, for the two quaternions |
# Show that, for the two quaternions q<sub>1</sub> and q<sub>2</sub>:<br><code>q<sub>1</sub>q<sub>2</sub> != q<sub>2</sub>q<sub>1</sub></code> |
||
If your language has built-in support for quaternions then use it. |
If your language has built-in support for quaternions then use it. |
||