UNPKG

1.64 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function rotationMatrix
4
5Create a 2-dimensional counter-clockwise rotation matrix (2x2) for a given angle (expressed in radians).
6Create a 2-dimensional counter-clockwise rotation matrix (3x3) by a given angle (expressed in radians) around a given axis (1x3).
7
8
9## Syntax
10
11```js
12math.rotationMatrix(theta)
13math.rotationMatrix(theta, format)
14math.rotationMatrix(theta, [v])
15math.rotationMatrix(theta, [v], format)
16```
17
18### Parameters
19
20Parameter | Type | Description
21--------- | ---- | -----------
22`theta` | number &#124; BigNumber &#124; Complex &#124; Unit | Rotation angle
23`v` | Array &#124; Matrix | Rotation axis
24`format` | string | Result Matrix storage format
25
26### Returns
27
28Type | Description
29---- | -----------
30Array &#124; Matrix | Rotation matrix
31
32
33## Examples
34
35```js
36math.rotationMatrix(math.pi / 2) // returns [[0, -1], [1, 0]]
37math.rotationMatrix(math.bignumber(1)) // returns [[bignumber(cos(1)), bignumber(-sin(1))], [bignumber(sin(1)), bignumber(cos(1))]]
38math.rotationMatrix(math.complex(1 + i)) // returns [[cos(1 + i), -sin(1 + i)], [sin(1 + i), cos(1 + i)]]
39math.rotationMatrix(math.unit('1rad')) // returns [[cos(1), -sin(1)], [sin(1), cos(1)]]
40
41math.rotationMatrix(math.pi / 2, [0, 1, 0]) // returns [[0, 0, 1], [0, 1, 0], [-1, 0, 0]]
42math.rotationMatrix(math.pi / 2, matrix([0, 1, 0])) // returns matrix([[0, 0, 1], [0, 1, 0], [-1, 0, 0]])
43
44```
45
46
47## See also
48
49[matrix](matrix.md),
50[cos](cos.md),
51[sin](sin.md)