Skip to content
davidson16807 edited this page Oct 16, 2014 · 2 revisions

ball is intended as a replacement for the sphere module.

module ball(size, d, r, anchor=$inward)

parameters d, and r are equivalent to their counterparts within the sphere module. Ball also offers an additional parameter, size that operates much like the size parameter of the box module. The size parameter lets you define seperate diameters for each of the 3 axes. This is done in order to standardize parameters across the relativity.scad primitives.

Alignment

ball offers all the existing functionality of sphere, but unlike sphere, ball renders any child module passed to it:

ball(d=10)
sphere(d=15);

By default, child modules will render with their origins at the center of their parent module. This can be changed using standard built-in modules like transform. ball exposes a special variable, $parent_size, that allows translation relative to the size of the parent.

ball(d=10)
translate([0,0,$parent_size.x/2])
sphere(d=15);

relativity.scad also offers a wrapper for the translate module, called align. Statements such as the one above can be streamlined using the align module:

ball(d=10)
align([0,0,1])
sphere(d=15);

Centering

ball also streamlines its own translation. Consider a statement such as this:

sphere_height = 10;
translate([0,0,sphere_height/2])
sphere(d=10, h=sphere_height, center=true);

ball offers a parameter, anchor, that defines where you want the origin to be relative to ball. The statement above is equivalent to the following:

ball(d=10, anchor=[0,0,-1]);

anchor acts as a complete replacement for the center parameter exposed by sphere. The following statements are equivalent:

ball(d=10, anchor=[0,0,0]);
sphere(d=10, center=true);
sphere(d=10, center=false);

Also, unlike the center parameter that's exposed by sphere, anchor is actually good for something :)

Clone this wiki locally