Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg]] == Constructive Solid Geometry [[toc:]] === Description 3D Solid modeling using combining and transforming primite shapes. The solids can be exported as ''stl'' files. The source code is hosted on [[https://codeberg.org/her01n/constructive-solid-geometry]]. === Example <enscript highlight=scheme> (import constructive-solid-geometry) (export-stl "example.stl" (difference (box 5 4 1) (translate (vector 5 0 0) (cylinder 2 1)))) </enscript> === Reference All identifiers are imported from {{constructive-solid-geometry}} module. <enscript highlight="scheme"> (import constructive-solid-geometry) </enscript> Points and vectors in 3D space are represented as standard {{vector}}, with three elements for x, y, z coordinates. ==== Primitives <procedure>(box width length height)</procedure> An orthogonal cuboid with one corner at origin and the other at ''[width, length, height]'' coordinates. <procedure>(box u v)</procedure> An orthogonal cuboid with one corner at {{u}} and the other at {{v}}. <procedure>(box? value)</procedure> True if value is a box. <procedure>(width box)</procedure> <procedure>(box-length box)</procedure> <procedure>(height box)</procedure> Returns the parameters of the box. {{box-length}} is chosen to not conflict with base scheme function {{length}}. <procedure>(cylinder radius height)</procedure> Constructs a cylinder primitive. The cylinder extends in z-axis direction, with the base center at origin, and the other base center at ''[0, 0, height]''. <procedure>(cylinder? value)</procedure> True if the value is a cylinder. <procedure>(radius cylinder)</procedure> <procedure>(height cylinder)</procedure> Returns the parameters of the cylinder primitive. <procedure>(sphere radius)</procedure> Returns a sphere solid with the center at origin and the given radius. <procedure>(sphere? value)</procedure> True, if the value is a sphere. <procedure>(radius sphere)</procedure> Return the sphere's radius. <procedure>(cone bottom-radius top-radius height)</procedure> Construct a truncated cone - a frustum. One base is at ''z = 0'' plane with the center at the origin and radius {{bottom-radius}}. Cone extends for {{height}} in positive z direction, ending with the other base with {{top-radius}}. One of {{bottom-radius}} or {{top-radius}} may be zero. When equal, the shape is identical to {{cylinder}}. <procedure>(cone? value)</procedure> Checks if the value is cone. <procedure>(bottom-radius cone)</procedure> <procedure>(top-radius cone)</procedure> <procedure>(height cone)</procedure> Extracts the cone's parameters. ==== Transformations <procedure>(rotate axis angle child)</procedure> Rotate the child around the axis. The axis is specified as a vector of three coordinates, the amplitude of the vector is ignored. Angle is expressed in radians. <procedure>(rotate? value)</procedure> True if the value is a rotation transformation. <procedure>(axis rotation)</procedure> <procedure>(angle rotation)</procedure> <procedure>(child rotation)</procedure> Access rotation parameters. <procedure>(translate translation child)</procedure> Move the child in the coordinate system. {{translation}} is a vector of three numbers. <procedure>(translate? value)</procedure> Check if the value is translation transformation. <procedure>(translation translate)</procedure> <procedure>(child translate)</procedure> Get the parameters of translation transformation. ==== Operations <procedure>(union child ...)</procedure> Merge children. This is a boolean ''or'' operation. <procedure>(union? value)</procedure> True if the value is an union operation. <procedure>(children union)</procedure> Returns the children of the union. <procedure>(difference upper lower)</procedure> Subtract {{lower}} solid from {{upper}} solid. Returns a part of {{upper}} that is not part of {{lower}}. <procedure>(difference? value)</procedure> Checks if value is a difference operation. <procedure>(upper difference)</procedure> <procedure>(lower difference)</procedure> Get the operands of the difference operation. <procedure>(intersection child ...)</procedure> Construct an intersection of all the children. This is a boolean ''and'' operation. <procedure>(intersection? value)</procedure> Checks if the value is an intersection operation. <procedure>(children intersection)</procedure> Returns the children of the intersection. ==== Export <procedure>(export-stl filename solid)</procedure> Calculates the triangular surface mesh, and writes it in ''STL'' format to a file. ==== Other <procedure>(solid? value)</procedure> Returns true if the value is a solid: either primitive, transformation or operation. <procedure>(inside? point solid)</procedure> Returns true if the point is inside a solid. If it point lies on the surface of the solid, the return value is unspecified. === Author Michal Herko === License This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A full copy of the GPL license can be found at <http://www.gnu.org/licenses/>.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 22 to 17?