diff --git a/docs/images/lib-m_rotation-1.JPG b/docs/images/lib-m_rotation-1.JPG new file mode 100644 index 00000000..d6626180 Binary files /dev/null and b/docs/images/lib-m_rotation-1.JPG differ diff --git a/docs/images/lib-m_rotation-2.JPG b/docs/images/lib-m_rotation-2.JPG new file mode 100644 index 00000000..7a4e0061 Binary files /dev/null and b/docs/images/lib-m_rotation-2.JPG differ diff --git a/docs/lib-m_rotation.md b/docs/lib-m_rotation.md new file mode 100644 index 00000000..9c7d0771 --- /dev/null +++ b/docs/lib-m_rotation.md @@ -0,0 +1,43 @@ +# m_rotation + +Generate a 4x4 transformation matrix which can pass into `multmatrix` to rotate the child element about the axis of the coordinate system or around an arbitrary axis. + +## Parameters + +- `a` : If it's `[deg_x, deg_y, deg_z]`, the rotation is applied in the order `x`, `y`, `z`. If it's `[deg_x, deg_y]`, the rotation is applied in the order `x`, `y`. If it's`[deg_x]`, the rotation is only applied to the `x` axis. If it's an number, the rotation is only applied to the `z` axis or an arbitrary axis. +- `v`: A vector allows you to set an arbitrary axis about which the object will be rotated. When `a` is an array, the `v` argument is ignored. + +## Examples + + include ; + + point = [20, 0, 0]; + a = [0, -45, 45]; + + hull() { + sphere(1); + multmatrix(m_rotation(a)) + translate(point) + sphere(1); + } + +![m_rotation](images/lib-m_rotation-1.JPG) + + include ; + + v = [10, 10, 10]; + + hull() { + sphere(1); + translate(v) + sphere(1); + } + + p = [10, 10, 0]; + for(i = [0:20:340]) { + multmatrix(m_rotation(a = i, v = v)) + translate(p) + sphere(1); + } + +![m_rotation](images/lib-m_rotation-2.JPG) \ No newline at end of file