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