Minkowski2d

See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#minkowski

Constructors

Link copied to clipboard
constructor(a: Shape2d, b: Shape2d)

Properties

Link copied to clipboard
val a: Shape2d
Link copied to clipboard
val b: Shape2d
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 override val color: Color?
Link copied to clipboard
open val convexity: Int?

Imagine travelling in a straight line cutting through the shape. The convexity is the maximum number of times your will enter the shape. For square and circle, this is 1. For a convex shape with a hole, it is 2. For a shape with a single concave part, such as a banana, it is also 2.

Link copied to clipboard
open override val corner: Vector2

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

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

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

Link copied to clipboard
override val dependencies2d: List<Shape2d>
Link copied to clipboard
open val firstPath: Path2d

Most Shape2d have exactly one path within paths, this is a convenience method which returns that path.

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: Vector2

The middle of the axis aligned bounding box (from corner and size). This may differ from the middle according to paths's points. For example, consider a circle with a chunk cut out of it :

Link copied to clipboard
open override val paths: List<Path2d>

The 2D points which define the lines around the shape. This is a list of Path2d because a shape can have holes (so there's one path for the exterior, and one path for each hole). Also, a shape can be a compound of more than one exterior shape. e.g. If we have 2 circles (like a 'colon' symbol) we can define it using a single Shape2d with two paths.

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
open override val size: Vector2

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.

Functions

Link copied to clipboard
infix fun Shape2d.and(other: Shape2d): Shape2d
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Shape2d.beginWorm(position: Vector3, bendX: Double, bendY: Double): Worm
fun Shape2d.beginWorm(position: Vector3, bendX: Double, bendY: Double, twist: Double): Worm
Link copied to clipboard
Link copied to clipboard
open fun brighter(): Shape2d
Link copied to clipboard

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

Link copied to clipboard

Moves the center of this shape to xy.

Link copied to clipboard

Uses corner and size to center the object about the X axis only.

Link copied to clipboard
Link copied to clipboard

Uses corner and size to center the object about the Y axis only.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun color(str: String): Shape2d
open fun color(color: Color?): Shape2d
open fun color(str: String, opacity: Float): Shape2d
open fun color(r: Float, g: Float, b: Float): Shape2d
open fun color(r: Float, g: Float, b: Float, opacity: Float): Shape2d
Link copied to clipboard
open fun combine(other: Shape2d): Polygon

Creates a single complex Polygon from the two shapes. This only differs from hole because hole reverses the order of the other shape's points.

Link copied to clipboard
open fun convexity(convexity: Int): Shape2d
Link copied to clipboard
open fun darker(): Shape2d
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun difference(other: Shape2d?): Shape2d

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 operator fun div(other: Shape2d?): Shape2d

An operator which is the same as intersection.

Link copied to clipboard

Checks that this shape's paths are ordered correctly. All paths are tests to see how many of the other paths contain it. If the answer is odd, it is assumed to be a hole, and the order of the points is made clockwise. If the answer is even, then the order of the points is made anticlockwise.

Link copied to clipboard
open fun extrude(height: Double): Extrusion

Extrude a 2D shape upwards (in the Z direction) to form a 3D shape (an extrusion).

open fun extrude(alongPath: Path2d): Polyhedron
open fun extrude(alongPath: Path3d): Polyhedron
open fun extrude(aroundShape: Shape2d): Shape3d
open fun extrude(height: Double, scale: Double): Extrusion
open fun extrude(height: Double, scale: Vector2): Extrusion
open fun extrude(alongPath: Path2d, autoScale: Boolean): Polyhedron
open fun extrude(alongPath: Path2d, autoScale: Boolean, convexity: Int?): Polyhedron
open fun extrude(alongPath: Path3d, autoScale: Boolean, convexity: Int?): Polyhedron

open fun extrude(alongPath: Path3d, autoScale: Boolean): Polyhedron

Extrude this 2D shape along a 3D path.

open fun extrude(aroundShape: Shape2d, autoScale: Boolean): Shape3d
open fun extrude(aroundShape: Shape2d, autoScale: Boolean, convexity: Int?): Shape3d

Extrude this 2D shape around the edge of another Shape2d (aroundShape).

Link copied to clipboard
open fun extrudeToPoint(height: Double): Shape3d
Link copied to clipboard

Mirror along the line X=Y. i.e. the X and Y values are switched over.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun hole(other: Shape2d): Polygon

Creates a single complex Polygon from the two shapes. This only differs from and by reversing the order of the other shape's points.

Link copied to clipboard
open fun hull(other: Shape2d): Hull2d
Link copied to clipboard
Link copied to clipboard
open fun intersection(other: Shape2d?): Shape2d

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
open fun label(name: String): Labelled2d
open fun label(name: String, type: String): Labelled2d

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
open fun margin(xy: Double): Shape2d
open fun margin(margin: Vector2): Shape2d
open fun margin(x: Double, y: Double): Shape2d

open fun margin(leftFront: Vector2, rightBack: Vector2): Shape2d

Does not change the shape, only the axis aligned bounding box defined by corner and size. This will alter how methods such as toOrigin and 'tileX' in the 'layout' extension.

Link copied to clipboard
open fun minkowski(other: Shape2d): Minkowski2d
Link copied to clipboard
open operator fun minus(other: Shape2d?): Shape2d

An operator which is the same as difference.

Link copied to clipboard
open fun mirror(normal: Vector2): Transformation2d
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun offset(delta: Double): Shape2d
open fun offset(delta: Double, chamfer: Boolean = false): Shape2d

Uses OpedSCAD's built-in offset module to grow/shrink this 2d shape.

Link copied to clipboard
open fun offsetRounded(radius: Double): Shape2d

Uses OpedSCAD's built-in offset module to grow/shrink this 2d shape.

Link copied to clipboard
open fun opacity(opacity: Float): Shape2d
Link copied to clipboard
open operator fun plus(other: Shape2d?): Shape2d

An operator which is the same as union.

Link copied to clipboard
open fun pointIndexNear(point: Vector2): Int

Finds the index into the firstPath's points list of the corner nearest to the given point. This assumes paths is defined, and contains a single list (i.e. is a simple polygon, with no holes).

open fun pointIndexNear(x: Double, y: Double): Int

Finds the index into the firstPath's points list of the corner nearest to (x, y). This assumes paths is defined, and contains a single list (i.e. is a simple polygon, with no holes).

Link copied to clipboard
open fun previewOnly(): Shape2d

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
infix fun Shape2d.remove(cavity: Shape2d): Shape2d

Similar to Shape2d.difference (or the minus operator), but the cavity remains as a 1st class object, which will remain as a cavity after using two or more shapes via the and method.

Link copied to clipboard
open fun resolution(res: Double): Shape2d

Adds additional points, so that the difference between adjacent points is no more than res. This is useful with some transforms.

Link copied to clipboard
open fun resolutionX(res: Double): Shape2d

Adds additional points, so that the difference between adjacent points is no more than res. This is useful with some transforms.

Link copied to clipboard
open fun resolutionY(res: Double): Shape2d

Adds additional points, so that the difference between adjacent points is no more than res. This is useful with some transforms.

Link copied to clipboard
open fun revolve(): Revolution

Create a solid of revolution. Take this object, stand it up, so that it is on the plane Y=0, and then spin it around the Z axis.

open fun revolve(angle: Double): Revolution

Create a solid of revolution. Take this object, stand it up, so that it is on the plane Y=0, and then spin it angle degrees around the Z axis.

Link copied to clipboard
Link copied to clipboard
open fun rotate(angle: Double): Transformation2d
Link copied to clipboard
open fun rotateAbout(angle: Double, about: Vector2): Transformation2d
Link copied to clipboard
open fun roundAllCorners(radius: Double): Shape2d

Similar to roundCorner, but rounds all corners.

open fun roundAllCorners(radius: Double, sides: Int): Shape2d
Link copied to clipboard
open fun roundCorner(cornerIndex: Int, radius: Double): Polygon

Creates a new shape, rounding a single corner. This assumes paths is defined, and contains a single list (i.e. is a simple polygon, with no holes).

open fun roundCorner(cornerIndex: Int, radius: Double, sides: Int): Polygon
Link copied to clipboard
open fun roundCornerNear(point: Vector2, radius: Double): Polygon
open fun roundCornerNear(x: Double, y: Double, radius: Double): Polygon
open fun roundCornerNear(point: Vector2, radius: Double, sides: Int): Polygon
open fun roundCornerNear(x: Double, y: Double, radius: Double, sides: Int): Polygon
Link copied to clipboard
open fun roundCorners(corners: List<Int>, radius: Double): Polygon

Similar to roundCorner, but rounds any number of corners.

open fun roundCorners(corners: List<Int>, radius: Double, sides: Int): Polygon
Link copied to clipboard
open fun scale(scale: Double): Transformation2d
open fun scale(scale: Vector2): Transformation2d
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open operator fun times(matrix: Matrix2d): Shape2d

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
fun Shape2d.toJTSGeometry(): Geometry

Convert a FooCAD Shape2d into jts Geometry.

Link copied to clipboard
fun Shape2d.toJTSMultiLineString(): MultiLineString

This is here only for completeness, at time of writing, this wasn't being used.

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 touching the Y axis).

Link copied to clipboard
open fun toOriginY(): Shape2d

Uses corner to move the object so that it's Y value is 0 (i.e. it is touching the X axis). 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 toPolygon(): Polygon

Converts to a Polygon using this shapes paths data. Useful for debugging, and in some instances, the generated scad file will be smaller (but even more inscrutable).

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: Transform2d): Shape2d

open fun transform(matrix: Matrix2d): Shape2d

Applies an arbitrary transformation. This is equivalent to OpenSCAD's 'multmatrix'. Beware that using negative scales can change the order of the points. Which will leave the shape mal-formed.

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

Some operations, such as transform require the paths data. This isn't available for Union2d, Difference2d and Intersection2d, 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, everything works out fine.

Link copied to clipboard
open fun translate(translation: Vector2): Transformation2d
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun union(other: Shape2d?): Shape2d

Combines two shapes together to form a single Shape2d.