OpenSCAD User Manual/Transformations
The text in its current form is incomplete.
[edit] scale
Scales its child elements using the specified vector. The argument name is optional.
Usage Example:
scale(v = [x, y, z]) { ... }
[edit] rotate
Rotates its child a degrees about the origin of the coordinate system or around an arbitrary axis. The argument names are optional if the arguments are given in the same order as specified above.
When a rotation is specified for multiple axis' the rotation is applied in the following order: x, y, z.
Usage:
rotate(a = deg, v = [x, y, z]) { ... }
For example, to flip an object upside-down, you might do this:
rotate(a=[0,180,0]) { ... }
The above example will rotate your object 180 degrees around the 'y' axis.
The optional argument 'v' allows you to set an arbitrary axis about which the object will be rotated.
Example with arbitrary origin.
rotate(a=45, v=[1,1,0]) { ... }
This example will rotate your object 45 degrees around the axis defined by the vector [1,1,0].
[edit] translate
Translates (moves) its child elements along the specified vector. The argument name is optional.
Usage example:
translate(v = [x, y, z]) { ... }
[edit] mirror
Mirrors the child element on a plane through the origin. The argument to mirror() is the normal vector on that plane.
Usage example:
mirror([ 0, 1, 0 ]) { ... }
[edit] multmatrix
Multiplies the geometry of all child elements with the given 4x4 transformation matrix.
Usage: multmatrix(m = [...]) { ... }
Example (translates by [10, 20, 30]):
multmatrix(m = [ [1, 0, 0, 10],
[0, 1, 0, 20],
[0, 0, 1, 30],
[0, 0, 0, 1]
]) cylinder();
Example (rotates by 45 degrees in XY plane and translates by [10,20,30]):
angle=45;
multmatrix(m = [ [cos(angle), -sin(angle), 0, 10],
[sin(angle), cos(angle), 0, 20],
[0, 0, 1, 30],
[0, 0, 0, 1]
]) union() {
cylinder(r=10.0,h=10,center=false);
cube(size=[10,10,10],center=false);
}
[edit] color
Displays the child elements using the specified RGB color + alpha value. This is only used for the OpenCSG and Thrown Together display modes. The alpha value will default to 1.0 (opaque) if not specified.
Usage example:
color([r, g, b, a]) { ... }
Note that the r, g, b, a values are limited to floating point values in the range { 0.0 ... 1.0 } rather than the more traditional integers { 0 ... 255 }. However you can specify the values as fractions, e.g. for R,G,B integers in {0 ... 255} you can use:
color([ R/255, G/255, B/255 ]) { ... }
As of the 2011.12 version, colors can also be chosen by name. For example, to create a red sphere, you can use this code:
color("red") sphere(5);
Alpha is also available with named colors:
color("Blue",0.5) cube(5);
The available color names are taken from the World Wide Web consortium's SVG color list. A chart of the color names is as follows:
|
|
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Chart based on "Web Colors" from Wikipedia
[edit] minkowski
Displays the minkowski sum of child nodes.
Usage example:
Say you have a flat box, and you want a rounded edge. There are many ways to do this, but minkowski is very elegant. Take your box, and a cylinder:
$fn=50; cube([10,10,1]); cylinder(r=2,h=1);
Then, do a minkowski sum of them:
$fn=50;
minkowski()
{
cube([10,10,1]);
cylinder(r=2,h=1);
}
[edit] hull
Displays the convex hull of child nodes.
Usage example:
hull() {
translate([15,10,0]) circle(10);
circle(10);
}