# Polygon

trait Polygon extends Shape with BoundedElem with Approx[Double] with PolygonLike[Pt2]

A mathematical closed polygon. The general case can be instantiated with PolygonGen, but it provides the interface for particular sub sets of polygons such as triangles and square. Mathematically a closed polygon made up of straight line segments. The default convention is to number the vertices in a clockwise direction, with vertex 1 the first vertex that is clockwise from 12 O'Clock. Sides are numbered in a corresponding manner with then end point of side n sdn at vertex n.

Companion:
object
trait Approx[Double]
trait Equals
trait Shape
trait Fillable
trait Drawable
trait GeomElem
class Object
trait Matchable
class Any

## Type members

### Types

override type SideT

## Value members

### Abstract methods

def foreachVertPairTail[U](f: (Double, Double) => U): Unit

Foreach vertex excluding vertex 1, perform the side effecting function on the Tuple2 of the x and y values of the vertex.

Foreach vertex excluding vertex 1, perform the side effecting function on the Tuple2 of the x and y values of the vertex.

def foreachVertTail[U](f: Pt2 => U): Unit

Performs the side effecting function on the Pt2 value of each vertex, excluding vertex v1.

Performs the side effecting function on the Pt2 value of each vertex, excluding vertex v1.

def unsafeVert(index: Int): Pt2

Returns the vertex of the given index. Throws if the index is out of range, if it less than 1 or greater than the number of vertices.

Returns the vertex of the given index. Throws if the index is out of range, if it less than 1 or greater than the number of vertices.

def v0: Pt2

Vertex v0, will throw on a 0 vertices polygon.

Vertex v0, will throw on a 0 vertices polygon.

def v0x: Double

The X component of vertex v0, will throw on a 0 vertices polygon.

The X component of vertex v0, will throw on a 0 vertices polygon.

def v0y: Double

The Y component of vertex v1, will throw on a 0 vertices polygon.

The Y component of vertex v1, will throw on a 0 vertices polygon.

def vertsArray: Array[Double]

The vertices of this Polygon in an Array of Doubles.

The vertices of this Polygon in an Array of Doubles.

def vertsArrayX: Array[Double]

The X component of the vertices of this Polygon in an Array of Doubles.

The X component of the vertices of this Polygon in an Array of Doubles.

def vertsArrayY: Array[Double]

The Y component of the vertices of this Polygon in an Array of Doubles.

The Y component of the vertices of this Polygon in an Array of Doubles.

def vertsForeach[U](f: Pt2 => U): Unit

Performs the side effecting function on the Pt2 value of each vertex.

Performs the side effecting function on the Pt2 value of each vertex.

def xVert(index: Int): Double

Returns the X component of the vertex of the given number. Will throw an exception if the vertex index is out of range.

Returns the X component of the vertex of the given number. Will throw an exception if the vertex index is out of range.

def yVert(index: Int): Double

Returns the Y component of the vertex of the given number. Will throw an exception if the vertex index is out of range.

Returns the Y component of the vertex of the given number. Will throw an exception if the vertex index is out of range.

### Concrete methods

def active(id: AnyRef): PolygonActive
def activeChildren(id: AnyRef, children: GraphicElems): PolygonCompound
override def approx(that: Any, precision: Double): Boolean
Definition Classes
override def attribs: Arr[XANumeric]
Definition Classes
override def boundingRect

Currently throws, not sure if that is the correct behaviour. Creates a bounding rectangle for a collection of 2d points

Currently throws, not sure if that is the correct behaviour. Creates a bounding rectangle for a collection of 2d points

Definition Classes
def cenPt: Pt2

The centre point of this Polygon. The default centre for Polygons is the centre of the bounding rectangle.

The centre point of this Polygon. The default centre for Polygons is the centre of the bounding rectangle.

override def draw(lineColour: Colour, lineWidth: Double): PolygonDraw
Definition Classes
def drawActive(lineColour: Colour, lineWidth: Double, pointerID: AnyRef): PolygonCompound
def dropVert(v: Int): Polygon
override def fill(fillColour: Colour): PolygonFill
Definition Classes
def fillActive(fillColour: Colour, pointerID: AnyRef): PolygonCompound
def fillActiveDraw(fillColour: Colour, pointerID: AnyRef, lineColour: Colour, lineWidth: Double): PolygonCompound

Creates a PolygonCompound graphic that is active with a simple 1 colour fill and has a draw graphic for the Polygon. The default values for the draw area line width of 2 and a colour of Black.

Creates a PolygonCompound graphic that is active with a simple 1 colour fill and has a draw graphic for the Polygon. The default values for the draw area line width of 2 and a colour of Black.

override def fillDraw(fillColour: Colour, lineColour: Colour, lineWidth: Double): PolygonCompound
Definition Classes
def fillDrawActive(fillColour: Colour, pointerID: AnyRef, lineWidth: Double, lineColour: Colour): PolygonCompound
def fillDrawText(fillColour: Colour, str: String, fontSize: Int, lineColour: Colour, lineWidth: Double): PolygonCompound
def fillDrawTextActive(fillColour: Colour, pointerID: AnyRef, str: String, fontSize: Int, lineWidth: Double, lineColour: Colour, align: TextAlign): PolygonCompound
override def fillInt(intValue: Int): PolygonFill
Definition Classes
def fillText(fillColour: Colour, str: String, fontSize: Int, textColour: Colour, layer: Int): PolygonCompound
def fillTextActive(fillColour: Colour, pointerEv: AnyRef, str: String, fontSize: Int, fontColour: Colour, align: TextAlign): PolygonCompound
def iForeachSide(initCount: Int)(f: (LineSeg, Int) => Unit): Unit

foreachs over the sides or edges of the Polygon These are of type LineSeg.

foreachs over the sides or edges of the Polygon These are of type LineSeg.

def insVert(insertionPoint: Int, newVec: Pt2): Polygon

Insert vertex.

Insert vertex.

def insVerts(insertionPoint: Int, newVecs: Pt2*): Polygon

Insert vertices before the specified insertion vertex.

Insert vertices before the specified insertion vertex.

override def negX

Mirror, reflection transformation of Polygon across the Y axis, returns a Polygon.

Mirror, reflection transformation of Polygon across the Y axis, returns a Polygon.

Definition Classes
override def negY

Mirror, reflection transformation of a Polygon across the X axis, returns a Polygon.

Mirror, reflection transformation of a Polygon across the X axis, returns a Polygon.

Definition Classes
def parentFillText(pointerID: Any, fillColour: Colour, str: String, fontSize: Int, textColour: Colour, align: TextAlign): PolygonCompound
@inline
def precisionDefault: Double
override def prolign(matrix: ProlignMatrix): Polygon

Prolign 2d transformations, similar transformations that retain alignment with the axes.

Prolign 2d transformations, similar transformations that retain alignment with the axes.

Definition Classes
def ptInside(pt: Pt2): Boolean

Determines if the parameter point lies inside this Polygon.

Determines if the parameter point lies inside this Polygon.

override def reflect(lineLike: LineLike): Polygon

Reflect 2D geometric transformation across a line, line segment or ray on a polygon, returns a Polygon. The Return type will be narrowed in sub traits / classes.

Reflect 2D geometric transformation across a line, line segment or ray on a polygon, returns a Polygon. The Return type will be narrowed in sub traits / classes.

Definition Classes
override def rotate(angle: AngleVec): Polygon

Rotation 2D geometric transformation on a Polygon, taking the rotation as a scalar measured in radians, returns a Polygon. The Return type will be narrowed in some but not all sub traits / classes.

Rotation 2D geometric transformation on a Polygon, taking the rotation as a scalar measured in radians, returns a Polygon. The Return type will be narrowed in some but not all sub traits / classes.

Definition Classes
override def rotate180
Definition Classes
override def rotate270
Definition Classes
override def rotate90
Definition Classes
override def scale(operand: Double): Polygon

Uniform scaling against both X and Y axes transformation on a polygon returning a Polygon. Use the xyScale method for differential scaling. The return type of this method will be narrowed further in descendant traits / classes.

Uniform scaling against both X and Y axes transformation on a polygon returning a Polygon. Use the xyScale method for differential scaling. The return type of this method will be narrowed further in descendant traits / classes.

Definition Classes
override def scaleXY(xOperand: Double, yOperand: Double): Polygon

XY scaling 2D geometric transformation on a Polygon returns a Polygon. This allows different scaling factors across X and Y dimensions. The return type will be narrowed in some, but not all descendant Polygon types.

XY scaling 2D geometric transformation on a Polygon returns a Polygon. This allows different scaling factors across X and Y dimensions. The return type will be narrowed in some, but not all descendant Polygon types.

Definition Classes
override def shearX(operand: Double): Polygon

Shear 2D geometric transformation along the X Axis on a Polygon, returns a Polygon. The return type will be narrowed in some but not all sub classes and traits.

Shear 2D geometric transformation along the X Axis on a Polygon, returns a Polygon. The return type will be narrowed in some but not all sub classes and traits.

Definition Classes
override def shearY(operand: Double): Polygon

Shear 2D geometric transformation along the Y Axis on a Polygon, returns a Polygon. The return type will be narrowed in sub classes and traits.

Shear 2D geometric transformation along the Y Axis on a Polygon, returns a Polygon. The return type will be narrowed in sub classes and traits.

Definition Classes
@inline
def side(index: Int): LineSeg
def sidesFold[A](init: A)(f: (A, LineSeg) => A): A
override def sidesForeach[U](f: LineSeg => U): Unit

foreachs over the sides or edges of the Polygon These are of type LineSeg.

foreachs over the sides or edges of the Polygon These are of type LineSeg.

Definition Classes
def sidesIFlatMap[AA <: SeqImut[_]](initCount: Int)(f: (LineSeg, Int) => AA)(implicit build: ArrFlatBuilder[AA]): AA

maps with a integer counter over the sides or edges of the Polygon These are of type LineSeg.

maps with a integer counter over the sides or edges of the Polygon These are of type LineSeg.

def sidesIMap[A, AA <: SeqImut[A]](initCount: Int)(f: (LineSeg, Int) => A)(implicit build: ArrBuilder[A, AA]): AA

maps with a integer counter over the sides or edges of the Polygon These are of type LineSeg.

maps with a integer counter over the sides or edges of the Polygon These are of type LineSeg.

def sidesMap[A, AA <: SeqImut[A]](f: LineSeg => A)(implicit build: ArrBuilder[A, AA]): AA

maps over the sides or edges of the Polygon These are of type LineSeg.

maps over the sides or edges of the Polygon These are of type LineSeg.

def slate(offset: Vec2Like): Polygon

Translate geometric transformation on a Polygon returns a Polygon. The return type of this method will be narrowed further in most descendant traits / classes. The exceptions being those classes where the centring of the geometry at the origin is part of the type.

Translate geometric transformation on a Polygon returns a Polygon. The return type of this method will be narrowed further in most descendant traits / classes. The exceptions being those classes where the centring of the geometry at the origin is part of the type.

override def slateXY(xDelta: Double, yDelta: Double): Polygon

Translate geometric transformation on a Polygon returns a Polygon. The return type of this method will be narrowed further in most descendant traits / classes. The exceptions being those classes where the centring of the geometry at the origin is part of the type.

Translate geometric transformation on a Polygon returns a Polygon. The return type of this method will be narrowed further in most descendant traits / classes. The exceptions being those classes where the centring of the geometry at the origin is part of the type.

Definition Classes
def sline(index: Int): LineSeg
def vLast: Pt2

The last vertex will throw an exception on a 0 vertices polygon.

The last vertex will throw an exception on a 0 vertices polygon.

final def vert(index: Int): Pt2

Returns the vertex of the given index. If the index is out of range, it will just circle round the vertices, so for a triangle -1 gives v2, -2 gives v1, 3 gives v0, 4 gives v1 etc. It will not throw unlike the unsafeVert method.

Returns the vertex of the given index. If the index is out of range, it will just circle round the vertices, so for a triangle -1 gives v2, -2 gives v1, 3 gives v0, 4 gives v1 etc. It will not throw unlike the unsafeVert method.

def vertsFlatMap[BB <: SeqImut[_]](f: Pt2 => BB)(implicit build: ArrFlatBuilder[BB]): BB

flatMap to an immutable Arr.

flatMap to an immutable Arr.

override def vertsFold[B](init: B)(f: (B, Pt2) => B): B
Definition Classes
def vertsIFlatMap[BB <: SeqImut[_]](iInit: Int)(f: (Pt2, Int) => BB)(implicit build: ArrFlatBuilder[BB]): BB

flatMap with index to an immutable Arr.

flatMap with index to an immutable Arr.

override def vertsIForeach[U](f: (Int, Pt2) => Any): Unit
Definition Classes
override def vertsMap[B, ArrB <: SeqImut[B]](f: Pt2 => B)(implicit build: ArrBuilder[B, ArrB]): ArrB
Definition Classes
override def vertsPrevForEach[U](f: (Pt2, Pt2) => U): Unit

This method does nothing if the vertNum < 2. Foreach vertex applies the side effecting function to the previous vertex with each vertex. The previous vertex to the first vertex is the last vertex of the PolygonLike. Note the function signature (previous, vertex) => U follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods'(accumulator, element) => B signature.

This method does nothing if the vertNum < 2. Foreach vertex applies the side effecting function to the previous vertex with each vertex. The previous vertex to the first vertex is the last vertex of the PolygonLike. Note the function signature (previous, vertex) => U follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods'(accumulator, element) => B signature.

Definition Classes

A function that takes a 2D geometric transformation on a Pt2 as a parameter and performs the transformation on all the vertices returning a new transformed Polygon

A function that takes a 2D geometric transformation on a Pt2 as a parameter and performs the transformation on all the vertices returning a new transformed Polygon

### Inherited methods

Inherited from:
BoundedElem
@inline
final def boundCen: Pt2

The centre of the bounding rectangle. consider also using cenDefault.

The centre of the bounding rectangle. consider also using cenDefault.

Inherited from:
BoundedElem
def boundingHeight: Double
Inherited from:
BoundedElem
def boundingWidth: Double

The width of the BoundingRect of this object.

The width of the BoundingRect of this object.

Inherited from:
BoundedElem
Inherited from:
BoundedElem
def canEqual(that: Any): Boolean

This canEqual override allow the comparison of Shapes.

This canEqual override allow the comparison of Shapes.

Inherited from:
Shape

If the geometric element has a defined centre then the cenDefault uses that, else it defaults to the centre of the bounding rectangle.

If the geometric element has a defined centre then the cenDefault uses that, else it defaults to the centre of the bounding rectangle.

Inherited from:
BoundedElem
def map[B <: ElemValueN, BB <: PolygonLike[B]](f: Pt2 => B)(implicit build: PolygonBuilder[B, BB]): BB

Map this collection of data elements to PolygonLike class of type BB.

Map this collection of data elements to PolygonLike class of type BB.

Inherited from:
PolygonLike
Inherited from:
BoundedElem
Inherited from:
BoundedElem
def vertsForAll(f: Pt2 => Boolean): Boolean

This method should be overridden in final classes.

This method should be overridden in final classes.

Inherited from:
PolygonLike
def vertsMin3: Boolean

Checks this polygon has at least 3 vertices.

Checks this polygon has at least 3 vertices.

Inherited from:
PolygonLike
def vertsNum: Int

The number of vertices and also the number of sides in this Polygon.

The number of vertices and also the number of sides in this Polygon.

Inherited from:
PolygonLike