Sphere

class Sphere(val radius: Double, val sides: Int) : Shape3d

A sphere. Like all shapes in FooCAD, the sphere is approximated using a number of triangles. You can let FooCAD determine the number of triangles by omitting sides.

sides is the number of sides of the circular cross section through the equator.

Constructors

Link copied to clipboard
constructor(radius: Double)
constructor(radius: Double, sides: Int)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open val back: Double

Maximum Y value of the axis aligned bounding box (from corner and size)

Link copied to clipboard
open val bottom: Double

Minimum Z value of the axis aligned bounding box (from corner and size)

Link copied to clipboard
open override val color: Color?
Link copied to clipboard
open val convexity: Int?

An optional value, which can help OpenSCAD render shapes correctly in preview mode. The stated convexity make NO DIFFERENCE to the final rendering. If the convexity is set to low (or set to null), then the preview mode may not display correctly. A large convexity may cause the OpenSCAD to update slowly / suboptimally. See OpenSCAD documentation for the definition of convexity.

Link copied to clipboard
open override val corner: Vector3

The bottom front left corner. In association with size determines the axis aligned bounding box.

Link copied to clipboard
open val corners: List<Vector3>

A list of the 8 corners which make up the axis aligned bounding box. (from corner and size.

Link copied to clipboard
open override val faces: List<List<Int>>

A face is a list of indices into the points array.

Link copied to clipboard
open val front: Double

Minimum Y value of the axis aligned bounding box (from corner and size)

Link copied to clipboard
open val left: Double

Minimum x value of the axis aligned bounding box (from corner and size)

Link copied to clipboard
open val middle: Vector3

The middle of the axis aligned bounding box (from corner and size)

Link copied to clipboard
open override val points: List<Vector3>

A list of the vertices.

Link copied to clipboard
Link copied to clipboard
open val right: Double

Maximum x value of the axis aligned bounding box (from corner and size)

Link copied to clipboard
val sides: Int
Link copied to clipboard
open override val size: Vector3

The size of the axis aligned bounding box. Note, the bounding box may grow larger than you imagine. For example, if you rotate a shape, and then rotate it back again, the bounding box will have grown.

Link copied to clipboard
open val top: Double

Maximum Z value of the axis aligned bounding box (from corner and size)

Functions

Link copied to clipboard
infix fun Shape3d.and(other: Shape3d): Shape3d

Combine two shapes, so that the solid parts and cavities are both considered. If you use the more normal Shape3d.union method instead (or the plus operator), then the cavity won't be treated in a special way, and the result will be the same as if remove was not used.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The axis aligned cube which encloses this shape.

Link copied to clipboard
open fun brighter(): Shape3d

Adjusts the colour of the shape.

Link copied to clipboard
open fun center(): Shape3d

Uses corner and size to center the object to (0,0,0)

Link copied to clipboard

Moves the center of this shape to xyz.

Link copied to clipboard
open fun centerX(): Shape3d

Uses corner and size to center the object about the X=0 plane only.

Link copied to clipboard
Link copied to clipboard

Uses corner and size to center the object about the X=0 plane and Y=0 plane, but leaving Z unaltered.

Link copied to clipboard

Uses corner and size to center the object about the Y=0 plane only.

Link copied to clipboard
Link copied to clipboard

Uses corner and size to center the object about the Z=0 plane only.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun color(str: String): Shape3d
open fun color(str: String, opacity: Float): Shape3d
open fun color(r: Float, g: Float, b: Float): Shape3d
open fun color(r: Float, g: Float, b: Float, opacity: Float): Shape3d

open fun color(color: Color?): Shape3d

Sets the colour of this shape (used only by OpenSCAD's preview mode). As with all FooCAD transformations, this returns a NEW shape, it does not modify this shape.

Link copied to clipboard
open fun cutZ(toCut: Shape3d, z: Double): Shape3d

Takes shape toCut and removes it from this shape (using difference). toCut is moved along the Z axis by z units.

open fun cutZ(toCut: Shape3d, z: Double, alignment: Double): Shape3d

Takes shape toCut and removes it from this shape (using difference). toCut is moved along the Z axis by z units, and also by toCut.size.x * alignment.

Link copied to clipboard
open fun cutZRatio(toCut: Shape3d, zRatio: Double): Shape3d

Takes shape toCut and removes it from this shape (using difference). toCut is moved along the Z axis according to zRatio, which is a ratio of the height of this shape. e.g. a zRatio of 0.5 will move toCut halfway up this object's height.

Link copied to clipboard
open fun darker(): Shape3d
Link copied to clipboard
open fun debug()

Prints details of this shape, and the tree of its dependencies.

open fun debug(indent: Int)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun difference(other: Shape3d?): Shape3d

Wherever this and other overlap there is a void. The rest of this shape remains unchanged. other does not appear in the result.

Link copied to clipboard
open fun disable(): Shape3d

Equivalent to OpenSCAD's '*' modifier.

Link copied to clipboard
open operator fun div(other: Shape3d?): Shape3d

An operator which is the same as intersection.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun highlight(): Shape3d

Equivalent to OpenSCAD's '#' modifier.

Link copied to clipboard
open fun hull(other: Shape3d): Hull3d
Link copied to clipboard

Similar to and, but if other overlaps cavities in this shape, then cavity will be filled.

Link copied to clipboard
open fun intersection(other: Shape3d?): Shape3d

Combines this shape and the other shape, such that only the places that the two shapes overlap are present in the result.

Link copied to clipboard
Link copied to clipboard
open fun label(name: String): Labelled3d

Labels a shape, so that we can collect all the important labelled shapes, and ignore the others. The PlanTarget in the construction module uses label to know which items to add to the plan.

open fun label(name: String, type: String): Labelled3d

Labels a shape, so that we can collect all the important labelled shapes, and ignore the others.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun margin(xyz: Double): Shape3d
open fun margin(margin: Vector3): Shape3d
open fun margin(x: Double, y: Double, z: Double): Shape3d

open fun margin(leftFrontBottom: Vector3, rightBackTop: Vector3): Shape3d

Does not change the shape, only the axis aligned bounding box defined by corner and size.

Link copied to clipboard
open fun minkowski(other: Shape3d): Minkowski3d
Link copied to clipboard
open operator fun minus(other: Shape3d?): Shape3d

An operator which is the same as difference.

Link copied to clipboard
open fun mirror(normal: Vector3): Transformation3d
Link copied to clipboard
open fun mirrorAbout(normal: Vector3, about: Vector3): Transformation3d
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun only(): Shape3d

Equivalent to OpenSCAD's '!' modifier.

Link copied to clipboard
open fun opacity(opacity: Float): Shape3d

Adjusts the colour of the shape.

Link copied to clipboard
open operator fun plus(other: Shape3d?): Shape3d

An operator which is the same as union.

Link copied to clipboard
open fun previewOnly(): Shape3d

Shows as transparent in OpenSCAD's preview mode, but is NOT included in the final rendered version, and therefore will NOT be printed.

Link copied to clipboard
Link copied to clipboard
infix fun Shape3d.remove(cavity: Shape3d): Shape3d

Make a cavity within another shape.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Rotate by v.x degrees, then by v.y degrees, then v.z degrees.

Rotate by x degrees, then by y degrees, then z degrees.

Link copied to clipboard
open fun rotateAxis(degrees: Double, axis: Vector3): Transformation3d

Rotate about the origin around the given axis, the angle is given in degrees.

Link copied to clipboard
open fun rotateAxisAbout(degrees: Double, axis: Vector3, about: Vector3): Transformation3d

Rotate about the given point (about) around the given axis.

Link copied to clipboard
open fun rotateX(degrees: Double): Transformation3d

Rotate by degrees around the X axis.

Link copied to clipboard
open fun rotateXAbout(degrees: Double, about: Vector3): Transformation3d

A rotation about the X axis, but translating by -about first, and then translating back by about. Note that about.x is ignored.

Link copied to clipboard
open fun rotateY(degrees: Double): Transformation3d

Rotate by degrees around the Y axis.

Link copied to clipboard
open fun rotateYAbout(degrees: Double, about: Vector3): Transformation3d

A rotation about the Y axis, but translating by -about first, and then translating back. Note that about.y is ignored.

Link copied to clipboard
open fun rotateZ(degrees: Double): Transformation3d

Rotate by degrees around the Z axis.

Link copied to clipboard
open fun rotateZAbout(degrees: Double, about: Vector3): Transformation3d

A rotation about the Z axis, but translating by -about first, and then translating back. Note that about.z is ignored.

Link copied to clipboard
open fun scale(scale: Double): Transformation3d
open fun scale(x: Double, y: Double, z: Double): Transformation3d

open fun scale(scale: Vector3): Transformation3d

Scales this shape (enlarges or shrinks). Note, you should not scale by zero. Scaling by negative values is also not encouraged, as this may lead the unexpected behaviour. Use mirrorX, mirrorY, mirrorZ or mirror instead of negative scale factors.

Link copied to clipboard

Scales along the X direction only. See scale.

Link copied to clipboard

Scales along the Y direction only. See scale.

Link copied to clipboard

Scales along the Z direction only. See scale.

Link copied to clipboard
fun sides(sides: Int): Sphere

Returns a new Sphere with the same radius, but a different number of sides. Note, you can specify the number of sides in the constructor, which is easier to use than this method. I keep this here for consistency with Circle and Cylinder.

Link copied to clipboard
open operator fun times(matrix: Matrix3d): Shape3d

Applies an arbitrary transformation. This is equivalent to OpenSCAD's 'multmatrix'. Identical to transform, but as this is a times operator can be used like to :

Link copied to clipboard

Uses corner to move the object to the origin.

Link copied to clipboard

Uses corner to move the object so that it's X value is 0 (i.e. it is just touching the X=0 plane). This is the same as leftToOrigin unless this shape has been scaled by a negative amount! See also rightToOrigin.

Link copied to clipboard

Uses corner to move the object so that it's Y value is 0 (i.e. it is just touching the Y=0 plane). This is the same as frontToOrigin unless this shape has been scaled by a negative amount! See also backToOrigin.

Link copied to clipboard
open fun toOriginZ(): Shape3d

Uses corner to move the object so that it's Z value is 0 (i.e. it is just touching the Z=0 plane). This is the same as bottomToOrigin unless this shape has been scaled by a negative amount! See also topToOrigin.

Link copied to clipboard

Creates a plain Polyhedron from points and faces.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun toScad(config: ScadOutputConfig)
Link copied to clipboard
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open fun transform(transform: Transform3d): Shape3d

Applies an arbitrary transformation, which does NOT have to be an affine transformation. OpenSCAD has no equivalent, and therefore the result is always a nasty polyhedron, (or a compound of lots of polyhedrons), which makes the resulting .scad file even more unreadable than usual!

Applies an arbitrary transformation. This is equivalent to OpenSCAD's 'multmatrix'. NOTE, there is a times operator which does the same thing, which may be more readable.

Link copied to clipboard
open fun transformParts(transformation: (Shape3d) -> Shape3d): Shape3d

Some transformations require the points and faces data. This isn't available for Union3d, Difference3d and Intersection3d, so it may seem impossible to transform a union, difference or intersection. We can though. If we pull the component parts out of the union/difference/intersection, apply the transformation to those shapes, and then recombine the results.

Link copied to clipboard
open fun translate(translation: Vector3): Transformation3d

Translates this shape. There are lots of "syntactic sugar" variations which perform translations : translateX, translateY, translateZ, leftTo, rightTo, frontTo, backTo, topTo, bottomTo, center, centerX, centerY, centerZ, centerXY, centerXTo, centerYTo, centerZTo They all perform a translation, but can make you scripts easier to read.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun union(other: Shape3d?): Shape3d

Combines two shapes together to form a single Shape3d.