1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-22 08:32:54 +01:00
dotSCAD/docs/lib2-m_rotation.md

47 lines
1.2 KiB
Markdown
Raw Normal View History

2019-05-02 10:07:52 +08:00
# m_rotation
2019-06-24 07:29:42 +08:00
The dir changed since 2.0.
2019-05-02 10:07:52 +08:00
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.
2019-05-02 10:44:19 +08:00
**Since:** 1.1
2019-05-02 10:07:52 +08:00
## 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
2019-06-22 14:15:18 +08:00
include <matrix/m_rotation.scad>;
2019-05-02 10:07:52 +08:00
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 <m_rotation.scad>;
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)