Primitive solids
ConstructiveGeometry.jl
supports two basic families of objects: two-dimensional shapes and three-dimensional volumes.
Two-dimensional shapes
Square
ConstructiveGeometry.square
— Functionsquare(size; origin, center=false)
square(width, height; origin, center=false)
An axis-parallel square or rectangle with given size
(scalar or vector of length 2).
julia> s = square(20,15);
square([20,15])
also works; square(20)
produces a real square.
Circle
ConstructiveGeometry.circle
— Functioncircle(r::Real, [circumscribed = false])
A circle with diameter r
, centered at the origin.
The corresponding mesh is a regular polygon, which is circumscribed to the ideal circle if circumscribed == true
and inscribed otherwise.
julia> s = circle(20);
Stroke path
ConstructiveGeometry.stroke
— Functionstroke(points, width; kwargs)
ends = :loop|:butt|:square|:round
join = :round|:square|:miter
miter_limit = 2.0
Draws a path of given width.
julia> s = stroke([[0,0], [100,0],[100,100],[50,150],[0,100]],10);
julia> s1 = [120,0]+ stroke([[0,0], [100,0],[100,100],[50,150],[0,100]],10;ends=:loop,join=:square);
Polygon
ConstructiveGeometry.polygon
— Functionpolygon(path)
Filled polygon delimitated by the given vertices.
TODO: allow several paths and simplify crossing paths.
julia> s = polygon([[0,0], [100,0],[100,100],[50,150],[0,100]]);
Three-dimensional volumes
Cube
ConstructiveGeometry.cube
— Functioncube(size; origin, center=false)
cube(size_x, size_y, size_z; origin, center=false)
An axis-parallel cube (or sett) with given size
(scalar or vector of length 3).
The first vertex is at the origin and all vertices have positive coordinates. If center
is true
then the cube is centered.
julia> s = cube(10,20,30);
Cone
ConstructiveGeometry.cone
— Functioncone(h, shape)
cone(h)*shape
cone(apex, shape)
cone(apex)*shape
Cone with arbitrary base.
cone(h, r; circumscribed=false)
Circular right cone with basis centered at the origin, radius r
, and height h
. Equivalent to cone([0,0,h])*circle(r)
.
cone(apex, r; circumscribed=false)
Circular, possibly oblique, cone with given apex point and radius r
around the origin.
julia> s = cone(50,10);
Cylinder
ConstructiveGeometry.cylinder
— Functioncylinder(h, r , [center=false], [circumscribed=false])
cylinder(h, r1, r2 , [center=false], [circumscribed=false])
A cylinder (or cone frustum) with basis centered at the origin, lower radius r1
, upper radius r2
, and height h
.
Warning:cylinder(h,r)
is interpreted as cylinder(h,r,r)
, not (h,r,0)
as in OpenSCAD. For a cone, using (cone(h,r))
instead is recommended.
The mesh is a regular prism, circumscribed to the cylinder if circumscribed == true
and inscribed otherwise.
julia> s = cylinder(50,10);
Sphere
ConstructiveGeometry.sphere
— Functionsphere(r::Real)
A sphere with diameter r
, centered at the origin.
julia> s = sphere(50);
Surface
MakieCore.surface
— Methodsurface(vertices, faces)
Produces a surface with the given vertices. faces
is a list of n-uples of indices into vertices
.
Non-triangular faces are triangulated (by being first projected on the least-square fit plane).
julia> s = surface([[0,0,0],[10,0,0],[10,10,0],[0,10,0],[5,5,2]],
[(1,2,5),(2,3,5),(3,4,5),(4,1,5),(4,3,2,1)]);