# psychopy.tools.mathtools.rotationMatrix¶

psychopy.tools.mathtools.rotationMatrix(angle, axis=(0.0, 0.0, - 1.0), out=None, dtype=None)[source]

Create a rotation matrix.

The resulting matrix will rotate points about axis by angle. The resulting matrix is similar to that produced by a glRotate call.

Parameters
• angle (float) – Rotation angle in degrees.

• axis (array_like or str) – Axis vector components or axis name. If a vector, input must be length 3. A string can be specified for rotations about world axes (eg. ‘+x’, ‘-z’, ‘+y’, etc.)

• out (ndarray, optional) – Optional output array. Must be same shape and dtype as the expected output if out was not specified.

• dtype (dtype or str, optional) – Data type for computations can either be ‘float32’ or ‘float64’. If out is specified, the data type of out is used and this argument is ignored. If out is not provided, ‘float64’ is used by default.

Returns

4x4 scaling matrix in row-major order. Will be the same array as out if specified, if not, a new array will be allocated.

Return type

ndarray

Notes

• Vector axis is normalized before creating the matrix.