org.openimaj.math.geometry.point

## Class PointList

• All Implemented Interfaces:
Cloneable, Iterable<Point2d>, GeometricObject2d
Direct Known Subclasses:
Polygon, Polyline

```public class PointList
extends Object
implements GeometricObject2d, Iterable<Point2d>, Cloneable```
A base implementation of a `GeometricObject2d` that is a set of points in space. Even though the points are backed by a list, the class itself does not make any assumptions about the order of the points (i.e. to determine connectedness), however, subclasses might.
Author:
Jonathon Hare (jsh2@ecs.soton.ac.uk)
• ### Field Summary

Fields
Modifier and Type Field and Description
`List<Point2d>` `points`
The points in the `PointList`
• ### Constructor Summary

Constructors
Constructor and Description
`PointList(Collection<? extends Point2d> points)`
Construct a `PointList` from points
```PointList(Collection<? extends Point2d> points, boolean copy)```
Construct a `PointList` from the points, possibly copying the points first
`PointList(Point2d... points)`
Construct a `PointList` from points
• ### Method Summary

All Methods
Modifier and Type Method and Description
`Point2d` `calculateCentroid()`
Get the centre of gravity of the `PointList`
`Polygon` `calculateConvexHull()`
Calculate the convex hull of the points using the Graham Scan algorithm.
`Rectangle` `calculateRegularBoundingBox()`
Compute the regular (oriented to the axes) bounding box of the `PointList`.
`PointList` `clone()`
`float` `computeIntrinsicScale()`
Calculate the intrinsic scale of the shape.
`static PointList` `computeMean(Collection<PointList> shapes)`
Compute the mean of a set of `PointList`s.
`Point2d` `get(int i)`
Get the ith point
`double` `getHeight()`
`List<Line2d>` `getLines()`
`List<Line2d>` `getLines(PointListConnections conns)`
`double` `getWidth()`
`Iterator<Point2d>` `iterator()`
`double` `maxX()`
`double` `maxY()`
`double` `minX()`
`double` `minY()`
`void` `rotate(double angle)`
Rotate the `PointList` about (0,0) with the given angle (in radians)
`void` ```rotate(Point2d origin, double angle)```
Rotate the `PointList` about the given origin with the given angle (in radians)
`void` `scale(float sc)`
Scale the `PointList` by the given amount about (0,0).
`void` ```scale(Point2d centre, float sc)```
Scale the `PointList` by the given amount about the given point.
`void` `scaleCentroid(float sc)`
Scale the `PointList` about its centre of gravity.
`PointList` `scaleX(float sc)`
Scale the `PointList` only in the x-direction by the given amount about (0,0).
`PointList` ```scaleXY(float scx, float scy)```
Scale the `PointList` by the given amount about (0,0).
`PointList` `scaleY(float sc)`
Scale the `PointList` only in the y-direction by the given amount about (0,0).
`int` `size()`
`String` `toString()`
`PointList` `transform(Jama.Matrix transform)`
Apply a 3x3 transform matrix to a copy of the `PointList` and return it
`void` ```translate(float x, float y)```
Translate the `PointList`s position
• ### Methods inherited from class java.lang.Object

`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`
• ### Field Detail

• #### points

`public List<Point2d> points`
The points in the `PointList`
• ### Constructor Detail

• #### PointList

`public PointList(Point2d... points)`
Construct a `PointList` from points
Parameters:
`points` - the points
• #### PointList

`public PointList(Collection<? extends Point2d> points)`
Construct a `PointList` from points
Parameters:
`points` - the points
• #### PointList

```public PointList(Collection<? extends Point2d> points,
boolean copy)```
Construct a `PointList` from the points, possibly copying the points first
Parameters:
`points` - the points
`copy` - should the points be copied
• ### Method Detail

• #### rotate

```public void rotate(Point2d origin,
double angle)```
Rotate the `PointList` about the given origin with the given angle (in radians)
Parameters:
`origin` - the origin of the rotation
`angle` - the angle in radians
• #### rotate

`public void rotate(double angle)`
Rotate the `PointList` about (0,0) with the given angle (in radians)
Parameters:
`angle` - the angle in radians
• #### calculateRegularBoundingBox

`public Rectangle calculateRegularBoundingBox()`
Compute the regular (oriented to the axes) bounding box of the `PointList`.
Specified by:
`calculateRegularBoundingBox` in interface `GeometricObject2d`
Returns:
the regular bounding box
• #### translate

```public void translate(float x,
float y)```
Translate the `PointList`s position
Specified by:
`translate` in interface `GeometricObject2d`
Parameters:
`x` - x-translation
`y` - y-translation
• #### scale

`public void scale(float sc)`
Scale the `PointList` by the given amount about (0,0). Scalefactors between 0 and 1 shrink the `PointList`.
Specified by:
`scale` in interface `GeometricObject2d`
Parameters:
`sc` - the scale factor.
• #### scaleXY

```public PointList scaleXY(float scx,
float scy)```
Scale the `PointList` by the given amount about (0,0). Scale factors between 0 and 1 shrink the `PointList`.
Parameters:
`scx` - the scale factor in the x direction
`scy` - the scale factor in the y direction.
Returns:
this `PointList`
• #### scale

```public void scale(Point2d centre,
float sc)```
Scale the `PointList` by the given amount about the given point. Scalefactors between 0 and 1 shrink the `PointList`.
Specified by:
`scale` in interface `GeometricObject2d`
Parameters:
`centre` - the centre of the scaling operation
`sc` - the scale factor
• #### scaleCentroid

`public void scaleCentroid(float sc)`
Scale the `PointList` about its centre of gravity. Scalefactors between 0 and 1 shrink the `PointList`.
Specified by:
`scaleCentroid` in interface `GeometricObject2d`
Parameters:
`sc` - the scale factor
• #### calculateCentroid

`public Point2d calculateCentroid()`
Get the centre of gravity of the `PointList`
Specified by:
`calculateCentroid` in interface `GeometricObject2d`
Returns:
the centre of gravity of the `PointList`
• #### minX

`public double minX()`
Specified by:
`minX` in interface `GeometricObject2d`
Returns:
the minimum x-ordinate of all vertices
• #### minY

`public double minY()`
Specified by:
`minY` in interface `GeometricObject2d`
Returns:
the minimum y-ordinate of all vertices
• #### maxX

`public double maxX()`
Specified by:
`maxX` in interface `GeometricObject2d`
Returns:
the maximum x-ordinate of all vertices
• #### maxY

`public double maxY()`
Specified by:
`maxY` in interface `GeometricObject2d`
Returns:
the maximum y-ordinate of all vertices
• #### getWidth

`public double getWidth()`
Specified by:
`getWidth` in interface `GeometricObject2d`
Returns:
the width of the regular bounding box
• #### getHeight

`public double getHeight()`
Specified by:
`getHeight` in interface `GeometricObject2d`
Returns:
the height of the regular bounding box
• #### transform

`public PointList transform(Jama.Matrix transform)`
Apply a 3x3 transform matrix to a copy of the `PointList` and return it
Specified by:
`transform` in interface `GeometricObject2d`
Parameters:
`transform` - 3x3 transform matrix
Returns:
the transformed `PointList`
• #### iterator

`public Iterator<Point2d> iterator()`
Specified by:
`iterator` in interface `Iterable<Point2d>`
`Iterable.iterator()`
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`
• #### computeMean

`public static PointList computeMean(Collection<PointList> shapes)`
Compute the mean of a set of `PointList`s. It is assumed that the number of points in the `PointList`s is equal, and that their is a one-to-one correspondance between the ith point in each list.
Parameters:
`shapes` - the shapes to average
Returns:
the average shape
• #### size

`public int size()`
Returns:
the number of points in the list
• #### computeIntrinsicScale

`public float computeIntrinsicScale()`
Calculate the intrinsic scale of the shape. This is the RMS distance of all the points from the centroid.
Returns:
the scale of the object.
• #### get

`public Point2d get(int i)`
Get the ith point
Parameters:
`i` - the index of the point
Returns:
the ith point
• #### getLines

`public List<Line2d> getLines()`
Returns:
A list of `Line2d` assuming the points in this list are connected in order
• #### clone

`public PointList clone()`
Overrides:
`clone` in class `Object`
• #### calculateConvexHull

`public Polygon calculateConvexHull()`
Calculate the convex hull of the points using the Graham Scan algorithm.
Returns:
the convex hull
`GrahamScan`