Composition Nodes - MacCurdyLab/OpenVCAD-Public GitHub Wiki

Overview

Composition nodes modify the geometry of their children. They can be used to combine multiple geometric primitives into a single object, transform shapes, and subtract volumes. Composition nodes can be nested to create complex objects. Depending on the node, they support different number of children.


Translate

The translate node translates the geometry of children node by the specified amount in X,Y,Z.

translate can have any number of children.

Syntax

translate(x_value, y_value, z_value){ <child node(s)> }, where x,y, & z values are the translation amounts in each direction.

Examples

translate(3, 0, 0){ sphere(3, "red"); } translates the sphere by 3 in the x direction.

translate(3, 2, 1)
{
    sphere(3, "red");
    sphere(10, "blue");
}

Translates two spheres in X,Y & Z


Rotate

The rotate node rotates the geometry of children node by the specified amount using pitch, yaw, and roll.

rotate can have any number of children.

Syntax

rotate(pitch, yaw, roll){ <child node(s)> }, where pitch, yaw, & roll are the rotation amounts in each direction.

Examples

rotate(0, 0, 90){ sphere(3, "red"); } rotates the sphere by 90 degrees in the z direction.

rotate(0, 90, 45)
{
    sphere(3, "red");
    sphere(10, "blue");
}

Scale

The scale node scales the geometry of children node by the specified amount in X,Y,Z.

scale can have any number of children.

Syntax

scale(x_value, y_value, z_value){ <child node(s)> }, where x,y, & z values are the scale amounts in each direction.

Examples

scale(3, 0, 0){ sphere(3, "red"); } scales the sphere by 3 in the x direction.

scale(3, 2, 1)
{
    sphere(3, "red");
    sphere(10, "blue");
}

Union

The union node combines the geometry of its children into a single object.

union can have any number of children.

Syntax

union(){ <child node>; <child node>; ... }

Examples

union()
{
    sphere(3, "red");
    sphere(10, "blue");
}

Difference

The difference node subtracts the geometry of its second child from the first child.

difference must have exactly two children.

Syntax

difference(){ <left hand side child>; <right hand side child>; }

Examples

difference()
{
    sphere(3, "red");
    sphere(10, "blue");
}

Intersection

The intersection node computes regions of child geometry that overlap.

intersection can have any number of children.

Syntax

intersection(){ <child node>; <child node>; ... }

Examples

intersection()
{
    sphere(3, "red");
    sphere(10, "blue");
}

Not

The not node inverts the geometry of its child.

not must only have one child.

Syntax

not(){ <child node>; }

not can have at most one child.

Examples

not()
{
    sphere(3, "blue");
}
⚠️ **GitHub.com Fallback** ⚠️