# IC Python API:RLPy RQuaternion

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Main article: Modules.

## Detailed Description

This class represent the quaternion in math. Quaternions represent orientations as a single rotation, just as rectangular co- ordinates represent position as a single vector.

## Operators

This class supports the following operators:

Member Operation Syntax Description Example
__add__ Addition a + b Adds values on either side of the operator. a + b = 30
__sub__ Subtraction a - b Subtracts right hand operand from left hand operand. a – b = -10
__mul__ Multiplication a * b Multiplies values on either side of the operator. a * b = 200
__truediv__ Division a / b Divides left hand operand by right hand operand. b / a = 2
__neg__ Negation -a Return the value negated. a = -b
__eq__ Equality a == b If the values of two operands are equal, then the condition becomes true. (a == b) is not true.
__ne__ Difference a != b If values of two operands are not equal, then condition becomes true. (a != b) is true.
__gt__ Greater Than a > b If the value of left operand is greater than the value of right operand, then condition becomes true. (a > b) is not true.
__lt__ Less Than a < b If the value of left operand is less than the value of right operand, then condition becomes true. (a < b) is true.
__ge__ Greater Than or Equal a >= b If the value of left operand is greater than or equal to the value of right operand, then condition becomes true. (a >= b) is not true.
__le__ Less or Equal a <= b If the value of left operand is less than or equal to the value of right operand, then condition becomes true. (a <= b) is true.
__iadd__ Addition (Inplace) a += b It adds right operand to the left operand and assign the result to left operand. c += a is equivalent to c = c + a
__isub__ Subtraction (Inplace) a -= b It subtracts right operand from the left operand and assign the result to left operand. c -= a is equivalent to c = c - a
__imul__ Multiply (Inplace) a *= b It multiplies right operand with the left operand and assign the result to left operand. c *= a is equivalent to c = c * a
__itruediv__ Divide (Inplace) a /= b It divides left operand with the right operand and assign the result to left operand. c /= a is equivalent to c = c / ac /= a is equivalent to c = c / a

## Member Functions

### AlmostEquel

```RLPy.RQuaternion.AlmostEquel ( self, qQ )
```

Equality test.

#### Parameters

qQ [IN] The quaternion - RLPy.RQuaternion

#### Returns

True if each of the elements of the quaternion is almost equal to the corresponding element in the second matrix - bool

### Conjugate

```RLPy.RQuaternion.Conjugate ( self )
```

Conjugate this quaternion.

#### Returns

The conjugated quaternion. The result is a quaternion whose x, y, and z values have been negated - RLPy.RQuaternion

### Dot

```RLPy.RQuaternion.Dot ( self, qQ )
```

Calculate dot production of the two quaternion.

#### Parameters

qQ [IN] The quaternion - RLPy.RQuaternion

#### Returns

The value of the dot production - float

### FromAxisAngle

```RLPy.RQuaternion.FromAxisAngle ( self, rkAxis, fAngle )
```

Quaternion from a axis angle.

#### Parameters

rkAxis [IN] axis vector - RLPy.RVector3

fAngle [IN] angle in radians - float

#### Returns

Return a new quaternion from a axis angle - RLPy.RQuaternion

### FromRotationMatrix

```RLPy.RQuaternion.FromRotationMatrix ( self, rkRot )
```

Quaternion from a rotation matrix.

#### Parameters

rkRot [IN] Rotation matrix - RLPy.RMatrix3

#### Returns

Return a new quaternion from a rotation matrix - RLPy.RQuaternion

### Inverse

```RLPy.RQuaternion.Inverse ( self )
```

Inverse this quaternion.

#### Returns

The inversed quaternion - RLPy.RQuaternion

### Multiply

```RLPy.RQuaternion.Multiply ( self, qQ )
```

Multiply quaternion.

#### Returns

The multiplied quaternion - RLPy.RQuaternion

### MultiplyEqual

```RLPy.RQuaternion.MultiplyEqual ( self, qQ )
```

Multiply quaternion.

#### Returns

The multiplied quaternion - RLPy.RQuaternion

### Normalize

```RLPy.RQuaternion.Normalize ( self )
```

Normalizes this quaternion.

#### Returns

The normalized quaternion - RLPy.RQuaternion

### Rotate180

```RLPy.RQuaternion.Rotate180 ( self )
```

Rotate 180 degree of this quaternion.

#### Returns

The rotated quaternion - RLPy.RQuaternion

### SetW

```RLPy.RQuaternion.SetW ( self, tW )
```

Set the w value of the quaternion.

#### Returns

The value of the w - RLPy.void

### SetX

```RLPy.RQuaternion.SetX ( self, tX )
```

Set the x value of the quaternion.

#### Returns

The value of the x - RLPy.void

### SetY

```RLPy.RQuaternion.SetY ( self, tY )
```

Set the y value of the quaternion.

#### Returns

The value of the y - RLPy.void

### SetZ

```RLPy.RQuaternion.SetZ ( self, tZ )
```

Set the z value of the quaternion.

#### Returns

The value of the z - RLPy.void

### ToAxisAngle

```RLPy.RQuaternion.ToAxisAngle ( self, rkAxis, rfAngle )
```

Convert quaternion to axis angle.

#### Parameters

rkAxis [OUT] Returns axis vector - RLPy.RVector3

fAngle [OUT] Returns angle in radians.

### ToRotationMatrix

```RLPy.RQuaternion.ToRotationMatrix ( self )
```

Convert quaternion to a rotation matrix.

#### Returns

Return a new 3x3 matrix from a quaternion - RLPy.RMatrix3

### W

```RLPy.RQuaternion.W ( self, args )
```

Get the w value of the quaternion.

#### Returns

The value of the w - float

### X

```RLPy.RQuaternion.X ( self, args )
```

Get the x value of the quaternion.

#### Returns

The value of the x - float

### Y

```RLPy.RQuaternion.Y ( self, args )
```

Get the y value of the quaternion.

#### Returns

The value of the y - float

### Z

```RLPy.RQuaternion.Z ( self, args )
```

Get the z value of the quaternion.

#### Returns

The value of the z - float