matrix_from_axis_and_angle
- compas.geometry.matrix_from_axis_and_angle(axis, angle, point=None)[source]
Calculates a rotation matrix from an rotation axis, an angle and an optional point of rotation.
- Parameters
axis ([float, float, float]) – Three numbers that represent the axis of rotation.
angle (float) – The rotation angle in radians.
point ([float, float, float] |
compas.geometry.Point
, optional) – A point to perform a rotation around an origin other than [0, 0, 0].
- Returns
list[list[float]] – A 4x4 transformation matrix representing a rotation.
Notes
The rotation is based on the right hand rule, i.e. anti-clockwise if the axis of rotation points towards the observer.
Examples
>>> axis1 = normalize_vector([-0.043, -0.254, 0.617]) >>> angle1 = 0.1 >>> R = matrix_from_axis_and_angle(axis1, angle1) >>> axis2, angle2 = axis_and_angle_from_matrix(R) >>> allclose(axis1, axis2) True >>> allclose([angle1], [angle2]) True