mirror of
https://github.com/Haskell-Things/ImplicitCAD.git
synced 2024-09-17 16:08:01 +03:00
add multmatrix example
This commit is contained in:
parent
8ea479929f
commit
4b78445c1b
36
Examples/exampleMultmatrix.scad
Normal file
36
Examples/exampleMultmatrix.scad
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Examples from
|
||||||
|
// https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#multmatrix
|
||||||
|
// CC-BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/
|
||||||
|
|
||||||
|
angle=PI/4;
|
||||||
|
multmatrix(m = [ [cos(angle), -sin(angle), 0, 0],
|
||||||
|
[sin(angle), cos(angle), 0, 30],
|
||||||
|
[ 0, 0, 1, 0],
|
||||||
|
[ 0, 0, 0, 1]
|
||||||
|
] )
|
||||||
|
union() {
|
||||||
|
cylinder(r=10.0,h=10,center=false);
|
||||||
|
cube(size=[10,10,10],center=false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// skew
|
||||||
|
M = [ [ 1 , 0 , 0 , 0 ],
|
||||||
|
[ 0 , 1 , 0.7, 0 ], // The "0.7" is the skew value; pushed along the y axis as z changes.
|
||||||
|
[ 0 , 0 , 1 , 0 ],
|
||||||
|
[ 0 , 0 , 0 , 1 ] ] ;
|
||||||
|
translate([-20,0,0])
|
||||||
|
multmatrix(M) { union() {
|
||||||
|
cylinder(r=10.0,h=10,center=false);
|
||||||
|
cube(size=[10,10,10],center=false);
|
||||||
|
} }
|
||||||
|
|
||||||
|
// same as previous example but using 3x4 matrix
|
||||||
|
N = [ [ 1 , 0 , 0 , 0 ],
|
||||||
|
[ 0 , 1 , 0.7, 0 ], // The "0.7" is the skew value; pushed along the y axis as z changes.
|
||||||
|
[ 0 , 0 , 1 , 0 ] ] ;
|
||||||
|
translate([20,0,0])
|
||||||
|
multmatrix(N) { union() {
|
||||||
|
cylinder(r=10.0,h=10,center=false);
|
||||||
|
cube(size=[10,10,10],center=false);
|
||||||
|
} }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user