interface Edge {

addPath(context): void;

chordError(): number;

distanceToEdge(edge): number;

distanceToLine(p_body): number;

distanceToPoint(p_body): number;

findVertexContact(v, p_body, distTol): null | RigidBodyCollision;

forgetPosition(): void;

getBody(): RigidBody;

getBottomBody(): number;

getCentroidBody(): Vector;

getCentroidRadius(): number;

getCentroidWorld(): Vector;

getCurvature(p_body): number;

getDecoratedVertexes(): Vertex[];

getIndex(): number;

getLeftBody(): number;

getNormalBody(p_body): Vector;

getPointOnEdge(p_body): Vector[];

getRightBody(): number;

getTopBody(): number;

getVertex1(): Vertex;

getVertex2(): Vertex;

highlight(): void;

improveAccuracyEdge(rbc, edge): void;

intersection(p1_body, p2_body): null | Vector[];

intersectionPossible(edge, swellage): boolean;

isStraight(): boolean;

maxDistanceTo(p_body): number;

pointOffset(p_body, length): Vector;

setCentroidRadius(value): void;

setVertex2(vertex): void;

testCollisionEdge(collisions, edge, time): void;

toStringShort(): string;

}

addPath(context): void;

chordError(): number;

distanceToEdge(edge): number;

distanceToLine(p_body): number;

distanceToPoint(p_body): number;

findVertexContact(v, p_body, distTol): null | RigidBodyCollision;

forgetPosition(): void;

getBody(): RigidBody;

getBottomBody(): number;

getCentroidBody(): Vector;

getCentroidRadius(): number;

getCentroidWorld(): Vector;

getCurvature(p_body): number;

getDecoratedVertexes(): Vertex[];

getIndex(): number;

getLeftBody(): number;

getNormalBody(p_body): Vector;

getPointOnEdge(p_body): Vector[];

getRightBody(): number;

getTopBody(): number;

getVertex1(): Vertex;

getVertex2(): Vertex;

highlight(): void;

improveAccuracyEdge(rbc, edge): void;

intersection(p1_body, p2_body): null | Vector[];

intersectionPossible(edge, swellage): boolean;

isStraight(): boolean;

maxDistanceTo(p_body): number;

pointOffset(p_body, length): Vector;

setCentroidRadius(value): void;

setVertex2(vertex): void;

testCollisionEdge(collisions, edge, time): void;

toStringShort(): string;

}

addPath
chordError
distanceToEdge
distanceToLine
distanceToPoint
findVertexContact
forgetPosition
getBody
getBottomBody
getCentroidBody
getCentroidRadius
getCentroidWorld
getCurvature
getDecoratedVertexes
getIndex
getLeftBody
getNormalBody
getPointOnEdge
getRightBody
getTopBody
getVertex1
getVertex2
highlight
improveAccuracyEdge
intersection
intersectionPossible
isStraight
maxDistanceTo
pointOffset
setCentroidRadius
setVertex2
testCollisionEdge
toStringShort

- chord
Error (): number Returns the maximum distance between this Edge and any chord between Vertexes on this Edge (including decorated mid-point Vertexes). A chord is the straight line between two adjacent Vertexes.

Here is a picture of a curved Edge, the chord between two Vertexes, V1, V2, and the

*chord error*is the maximum distance between the chord and curved Edge.Note that having more decorated mid-point Vertexes results in a smaller chord error, because the chords are closer to the curve.

See Vertex for more about decorated mid-point Vertexes

#### Returns number

the maximum distance between this Edge and a chord between any Vertexes on this Edge

- distance
To (edge): numberEdge Returns smallest distance between this Edge and the given Edge. Returns

`NaN`

in cases where the calculation can't be done. One of the Edges must be curved.**TO DO**distanceToEdge is not used currently... delete it? or use it in places like`CircleStraight.testCollision`

and`CircleCircle.testCollision`

?#### Parameters

##### edge: Edge

the Edge to measure distance to

#### Returns number

smallest distance between this Edge and the given Edge, or

`NaN`

when the calculation cannot be done#### Throws

if both Edges are StraightEdges.

- distance
To (p_body): numberLine Returns distance from the given point (in body coordinates) to the extended line of this Edge, where the extensions continue beyond the endpoints of this Edge. For a CircularEdge the extended line is taken to be the full circle. Positive distance means the point is outside of this Edge, negative means inside.

#### Parameters

##### p_body: Vector

the point to find distance from, in body coords

#### Returns number

distance from the given point to the extended line of this Edge

- distance
To (p_body): numberPoint Returns signed distance of the given point (in body coordinates) to this Edge along a line that is normal to this Edge, or infinity if beyond an endpoint of this Edge. Distance is positive if it is on the side of the line that the normal points towards, otherwise negative.

#### Parameters

##### p_body: Vector

the point to find distance from, in body coords

#### Returns number

signed distance from the given point to this Edge (positive if point is on side the normal points towards) or infinity if beyond the endpoint of this Edge

- find
Vertex (v, p_body, distTol): null | RigidBodyCollisionContact Returns a RigidBodyCollision representing the contact point if the given Vertex is close to this Edge. Closeness is specified by the given distance tolerance. Note that this

**does not consider velocity tests**for a contact. If the point does not lie along any normal to this Edge, then it is not close; this occurs when the point is past the endpoints of this Edge.If the point is near, then the returned RigidBodyCollision will have the following information set:

`body`

is set to the RigidBody of the Vertex`normalBody`

is set to the RigidBody of this Edge- impact point is set to the nearest point on this Edge, in world coords
- distance is set to the distance of Vertex from this Edge; negative distance means penetration into this Edge.
- normal is set to the unit normal vector at the nearest point on this Edge, in world coords
`r2`

is based on current position of this Edge's RigidBody

Additionally, if this Edge is curved, the following are also set:

`ballNormal, radius2, u2`

.#### Parameters

#### Returns null | RigidBodyCollision

a RigidBodyCollision representing the contact point, or

`null`

if not close enough.

- get
Centroid (): VectorBody Returns the center of the circle to use for proximity testing, in body coordinates. A circle centered at this centroid with radius

`getCentroidRadius()`

should encompass this Edge. See getCentroidRadius and getCentroidWorld.#### Returns Vector

the center of the circle to use for proximity testing, in body coordinates

- get
Centroid (): numberRadius Returns the radius of the circle to use for proximity testing. A circle centered at

`getCentroidWorld()`

with this radius should encompass this Edge. See setCentroidRadius, getCentroidRadius and getCentroidWorld.#### Returns number

the radius of the circle to use for proximity testing

- get
Centroid (): VectorWorld Returns the center of the circle to use for proximity testing, in world coordinates. A circle centered at this point with radius

`getCentroidRadius()`

should encompass this Edge. See getCentroidRadius and getCentroidBody.#### Returns Vector

the center of the circle to use for proximity testing, in world coordinates

- get
Curvature (p_body): number Returns radius of curvature at the given point on this Edge. Radius of curvature is the radius of a circle that would give equivalent curvature at a given point on an Edge. Negative curvature means the Edge is concave at that point.

For a circle, every point on the circle has the same center and radius of curvature. But for any other curve (an oval for instance), each point on the edge can have a different center and radius of curvature.

#### Parameters

##### p_body: Vector

the point on this Edge, in body coordinates

#### Returns number

the radius of curvature; negative means concave; returns positive infinity if this is a straight edge

#### Throws

if the point is not close to this Edge

- get
Normal (p_body): VectorBody Returns unit normal vector in body coordinates, at the given body coordinates point. Normal points outwards from the RigidBody.

**TO DO**what if the point is not on this Edge?#### Parameters

##### p_body: Vector

the point on this Edge in body coordinates

#### Returns Vector

the outwards pointing unit normal vector at the given point, in body coordinates

- get
Point (p_body): Vector[]On Edge Finds the nearest point on this Edge to the given point, returns that nearest point and the unit normal vector there. Returns

`null`

if the given point lies beyond the end point of this Edge, meaning that there is no perpendicular line to this Edge passing thru the given point.#### Parameters

##### p_body: Vector

a point near this Edge, in body coordinates

#### Returns Vector[]

a pair of Vectors: the nearest point on this Edge, and the unit normal vector at that point both in body coords; or

`null`

if there is no nearest point on this Edge.

- improve
Accuracy (rbc, edge): voidEdge Updates the EdgeEdgeCollision to have more accurate information based on current positions and velocities of the RigidBodys.

#### Parameters

##### rbc: RigidBodyCollision

the EdgeEdgeCollision to update

##### edge: Edge

the other Edge involved in the collision

#### Returns void

- intersection(p1_body, p2_body): null | Vector[]
Returns points on this Edge intersecting the straight line segment between the two given points (in body coordinates), or

`null`

if there is no intersection. There can be more than one point of intersection.#### Returns null | Vector[]

array of intersection points, in body coords, or

`null`

if no intersection.

- intersection
Possible (edge, swellage): boolean Rough proximity test that returns

`true`

if an intersection is possible between this Edge and the specified Edge. This is intended to do a quick rough test to eliminate obvious cases where no intersection is possible.`Swellage`

is a fudge factor which is added to the max radius of the Edges, to make the test easier to succeed.#### Parameters

##### edge: Edge

the other Edge

##### swellage: number

a fudge factor which is added to the max radius of the Edges

#### Returns boolean

whether an intersection between the Edges is possible

- max
Distance (p_body): numberTo Returns the maximum distance from the given point (in body coordinates) to any point on this Edge.

#### Parameters

##### p_body: Vector

a point in body coordinates

#### Returns number

the maximum distance from the given point (in body coordinates) to any point on this Edge

- point
Offset (p_body, length): Vector Returns the point offset in the direction of this Edge's normal. The normal is taken at the point on this Edge that is closest to the given point. The point is given and returned in body coordinates. Note that the returned point might be closer to this Edge when the starting point is on the inside of the RigidBody, because the normal points outwards.

#### Parameters

##### p_body: Vector

the point near this Edge, in body coordinates

##### length: number

the distance to move the point

#### Returns Vector

the point offset in the direction of this Edge's normal, in body coordinates

- set
Centroid (value): voidRadius Sets the radius of the circle to use for proximity testing. A circle centered at

`getCentroidWorld()`

with this radius should encompass this Edge. See getCentroidRadius, getCentroidBody and getCentroidWorld.#### Parameters

##### value: number

the radius of the circle to use for proximity testing

#### Returns void

- set
Vertex2 (vertex): void Sets the finish Vertex of this Edge. Should match the start Vertex of the next Edge in the RigidBody.

#### Parameters

##### vertex: Vertex

the finish Vertex of this Edge

#### Returns void

- test
Collision (collisions, edge, time): voidEdge If there is a collision between this Edge and the given Edge, adds a RigidBodyCollision to the list. This ignores collisions with Vertexes.

#### Parameters

##### collisions: RigidBodyCollision[]

list of collisions to add to

##### edge: Edge

the other Edge

##### time: number

current simulation time

#### Returns void

- to
String (): stringShort Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling

`toStringShort`

on that other object. For example, calling`toStringShort()`

on a DisplayShape might return something like this:`DisplayShape{polygon:Polygon{'chain3'}}`

#### Returns string

a minimal string representation of this object.

Generated using TypeDoc

An Edge of a RigidBody has a start and finish Vertex and belongs to a particular RigidBody. Vertex location is defined in body coordinates of the associated RigidBody. An Edge knows which side is outside or inside the RigidBody; the method getNormalBody returns a normal vector that points to the outside.

Edges are ordered in a RigidBody. For a given Edge, the start Vertex must be the same as the finish Vertex of the previous Edge of the RigidBody.

## Terminology

A

normal vectoris a perpendicular to an Edge, see https://en.wikipedia.org/wiki/Normal_(geometry).A

unit normalis a normal vector with length 1. Here 'normal vector' usually also implies that it is a unit normal vector.