2D shapes

rectangle()

Creates a rectangular closed wire from specified parameters.

Syntax

cadlib.rectangle(width, depth, center, dir);

Parameters

Name Type Description
width Number Width of the rectangle
depth Number Depth of the rectangle
center Point Center of mass
dir Vec3 Direction of the normal to the wire

Returns

Wire

Example


function build() {

    
    let width = 20, depth=20;

    //At origin
    let center = {x:0, y:0, z:0}; 

    //set wire orientation  along X-Z plane
    let dir = {x:0, y:0, z:0}; 

    //Create wire
    let w = cadlib.rectangle(width,depth, center, dir);

    //Create a face from the wire
    let f = cadlib.face([w]);

    //Extrude the face along +ve Y axis by 10
    let extrudeDirection = {x:0, y:1, z:0};

    let extrudeLength = 10;
    let solid = cadlib.extrude(f, extrudeDirection, extrudeLength);

    return solid;

    //TODO -  experiment with dir and extrudeDirection to understand how a rectangluar box will be oriented after extrusion.


}


circle()

Creates a circle.

Syntax

cadlib.circle(center, normal, radius);

Parameters

Name Type Description
center Point Center of the circle
normal Vec3 Normal to the circle
radius Number Radius of the circle

Returns

Wire


ellipse()

Creates an elliptical wire.

Syntax

cadlib.ellipse(center, normal, majorRadius, minorRadius);

Parameters

Name Type Description
center Point Center of the ellipse
normal Vec3 Direction of the ellipse
majorRadius Number Radius on the major axis
minorRadius Number Radius on the minor axis

Returns

Wire


ellipse2()

Creates an elliptical wire.

Syntax

cadlib.ellipse2(edges);

Parameters

Name Type Description
center Point Center of the ellipse
normal Vec3 Direction of the ellipse
xaxis Vec3 Rotation of the x-axis.
majorRadius Number Radius on the major axis
minorRadius Number Radius on the minor axis

Returns

Wire


hyperbola()

Creates an hyperbolic wire.

Syntax

cadlib.hyperbola(center, normal, majorRadius, minorRadius);

Parameters

Name Type Description
center Point Center of the ellipse
normal Vec3 Direction of the ellipse

| majorRadius | Number | Radius on the major axis| | minorRadius | Number | Radius on the minor axis|

Returns

Wire


polygoan()

creates a polygonal wire

Syntax

cadlib.face(edges);

Parameters

Name Type Description
points Array Array of Point objects

Returns

Wire