org.openimaj.math.geometry.point

## Class PointListConnections

• ```public class PointListConnections
extends Object```
Class to model the connections between points in a `PointList`. The connections are based on the indices of the points in the model, so it is easy to apply the connections to any variant of a `PointList` representing a given geometry.
Author:
Jonathon Hare (jsh2@ecs.soton.ac.uk)
• ### Constructor Summary

Constructors
Constructor and Description
`PointListConnections()`
Default constructor.
```PointListConnections(PointList pl, List<Line2d> lines)```
Construct with a `PointList` and a list of lines between points in the `PointList`.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`void` ```addConnection(int from, int to)```
Add a connection between points with the given indices.
`void` ```addConnection(PointList pl, Line2d line)```
Add a connection between the two end points of the given line in the given `PointList`.
`void` ```addConnection(PointList pl, Point2d from, Point2d to)```
Add a connection between two points in the given `PointList`.
`Point2dImpl` ```calculateNormal(int id, PointList pointList)```
Calculate the normal vector at a given vertex id.
`Point2dImpl` ```calculateNormal(Point2d pt, PointList pointList)```
Calculate the normal vector at a given vertex.
`Line2d` ```calculateNormalLine(int idx, PointList pointList, float scale)```
Calculate a normal line for a given vertex.
`Line2d` ```calculateNormalLine(Point2d pt, PointList pointList, float scale)```
Calculate a normal line for a given vertex.
`int[]` `getConnections(int id)`
Get the indices of all the points connected to the point with the given index.
`Point2d[]` ```getConnections(Point2d pt, PointList pl)```
Get the points connected to the given point.
`List<Line2d>` `getLines(PointList pointList)`
Get the connections as a list of lines based on the points in the given `PointList`.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### PointListConnections

`public PointListConnections()`
Default constructor. Makes an empty list of connections.
• ### Method Detail

```public void addConnection(int from,
int to)```
Add a connection between points with the given indices.
Parameters:
`from` - first point
`to` - second point

```public void addConnection(PointList pl,
Point2d from,
Point2d to)```
Add a connection between two points in the given `PointList`.
Parameters:
`pl` - the `PointList`
`from` - the first point
`to` - the second point

```public void addConnection(PointList pl,
Line2d line)```
Add a connection between the two end points of the given line in the given `PointList`.
Parameters:
`pl` - the `PointList`
`line` - the line
• #### getConnections

```public Point2d[] getConnections(Point2d pt,
PointList pl)```
Get the points connected to the given point.
Parameters:
`pt` - The target point.
`pl` - The `PointList` in whioch to search.
Returns:
the connected points.
• #### getConnections

`public int[] getConnections(int id)`
Get the indices of all the points connected to the point with the given index.
Parameters:
`id` - The point to search for
Returns:
the indices of the connected points.
• #### calculateNormalLine

```public Line2d calculateNormalLine(Point2d pt,
PointList pointList,
float scale)```
Calculate a normal line for a given vertex.
Parameters:
`pt` - the vertex
`pointList` - the `PointList` in which to search/
`scale` - The scaling to apply to the line; a scale of 1.0 will lead to a line that is 2.0 units long (1.0 either side of the vertex).
Returns:
the normal line.
• #### calculateNormalLine

```public Line2d calculateNormalLine(int idx,
PointList pointList,
float scale)```
Calculate a normal line for a given vertex.
Parameters:
`idx` - the vertex index
`pointList` - the `PointList` in which to search/
`scale` - The scaling to apply to the line; a scale of 1.0 will lead to a line that is 2.0 units long (1.0 either side of the vertex).
Returns:
the normal line.
• #### calculateNormal

```public Point2dImpl calculateNormal(Point2d pt,
PointList pointList)```
Calculate the normal vector at a given vertex.
Parameters:
`pt` - the vertex.
`pointList` - the `PointList` in which to search.
Returns:
the unit normal vector of the vertex.
• #### calculateNormal

```public Point2dImpl calculateNormal(int id,
PointList pointList)```
Calculate the normal vector at a given vertex id.
Parameters:
`id` - the vertex id.
`pointList` - the `PointList` in which to search.
Returns:
the unit normal vector of the vertex.
• #### getLines

`public List<Line2d> getLines(PointList pointList)`
Get the connections as a list of lines based on the points in the given `PointList`.
Parameters:
`pointList` - the `PointList`.
Returns:
the lines.