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 q1 and q2; <code>q1q2 != q2q1</code>. An example of a quaternion might be <code>1 +2i +3j +4k</code>
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)


<br>'''Task Description'''<br>
'''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 )
q1 = (2, 3, 4, 5) = (a1, b1, c1, d1)
q<sub>1</sub> = (2, 3, 4, 5) = (a<sub>1</sub>, b<sub>1</sub>, c<sub>1</sub>, d<sub>1</sub>)
q2 = (3, 4, 5, 6) = (a2, b2, c2, d2)
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>q1 + q2 = (a1+a2, b1+b2, c1+c2, d1+d2)</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 q1 and q2 is given by:<br><code>( a1a2b1b2c1c2d1d2,</code><br><code>&nbsp; a1b2 + b1a2 + c1d2d1c2,</code><br><code>&nbsp; a1c2b1d2 + c1a2 + d1b2,</code><br><code>&nbsp; a1d2 + b1c2c1b2 + d1a2 )</code>
# 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>&nbsp; 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>&nbsp; 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>&nbsp; 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 q1 and q2:<br><code>q1q2 != q2q1</code>
# 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.