Ring

Ring

A class representing a ring.

Constructor

new Ring(members)

Source:
Properties:
Name Type Description
id Number

The id of this ring.

members Array.<Number>

An array containing the vertex ids of the ring members.

edges Array.<Number>

An array containing the edge ids of the edges between the ring members.

insiders Array.<Number>

An array containing the vertex ids of the vertices contained within the ring if it is a bridged ring.

neighbours Array.<Number>

An array containing the ids of neighbouring rings.

positioned Boolean

A boolean indicating whether or not this ring has been positioned.

center Vector2

The center of this ring.

rings Array.<Ring>

The rings contained within this ring if this ring is bridged.

isBridged Boolean

A boolean whether or not this ring is bridged.

isPartOfBridged Boolean

A boolean whether or not this ring is part of a bridge ring.

isSpiro Boolean

A boolean whether or not this ring is part of a spiro.

isFused Boolean

A boolean whether or not this ring is part of a fused ring.

centralAngle Number

The central angle of this ring.

canFlip Boolean

A boolean indicating whether or not this ring allows flipping of attached vertices to the inside of the ring.

The constructor for the class Ring.

Parameters:
Name Type Description
members Array.<Number>

An array containing the vertex ids of the members of the ring to be created.

Methods

clone() → {Ring}

Source:

Clones this ring and returns the clone.

Returns:

A clone of this ring.

Type
Ring

contains(vertexId) → {Boolean}

Source:

Checks whether or not this ring contains a member with a given vertex id.

Parameters:
Name Type Description
vertexId Number

A vertex id.

Returns:

A boolean indicating whether or not this ring contains a member with the given vertex id.

Type
Boolean

eachMember(vertices, callback, startVertexId, previousVertexId)

Source:

Loops over the members of this ring from a given start position in a direction opposite to the vertex id passed as the previousId.

Parameters:
Name Type Description
vertices Array.<Vertex>

The vertices associated with the current molecule.

callback function

A callback with the current vertex id as a parameter.

startVertexId Number

The vertex id of the start vertex.

previousVertexId Number

The vertex id of the previous vertex (the loop calling the callback function will run in the opposite direction of this vertex).

getAngle() → {Number}

Source:

Returns the angle of this ring in relation to the coordinate system.

Returns:

The angle in radians.

Type
Number

getDoubleBondCount(vertices) → {Number}

Source:

Get the number of double bonds inside this ring.

Parameters:
Name Type Description
vertices Array.<Vertex>

An array of vertices associated with the current molecule.

Returns:

The number of double bonds inside this ring.

Type
Number

getOrderedNeighbours(ringConnections) → {Array.<Object>}

Source:

Returns an array containing the neighbouring rings of this ring ordered by ring size.

Parameters:
Name Type Description
ringConnections Array.<RingConnection>

An array of ring connections associated with the current molecule.

Returns:

An array of neighbouring rings sorted by ring size. Example: { n: 5, neighbour: 1 }.

Type
Array.<Object>

getPolygon(vertices) → {Array.<Vector2>}

Source:

Gets the polygon representation (an array of the ring-members positional vectors) of this ring.

Parameters:
Name Type Description
vertices Array.<Vertex>

An array of vertices representing the current molecule.

Returns:

An array of the positional vectors of the ring members.

Type
Array.<Vector2>

getSize() → {Number}

Source:

Returns the size (number of members) of this ring.

Returns:

The size (number of members) of this ring.

Type
Number

isBenzeneLike(vertices) → {Boolean}

Source:

Check whether this ring is an implicitly defined benzene-like (e.g. C1=CC=CC=C1) with 6 members and 3 double bonds.

Parameters:
Name Type Description
vertices Array.<Vertex>

An array of vertices associated with the current molecule.

Returns:

A boolean indicating whether or not this ring is an implicitly defined benzene-like.

Type
Boolean