cubexx::edge_t

struct cubexx::edge_t

Represents an edge of a cube.

There are 12 edges in a cube.

Public Functions

edge_t()

Default construct a “null” edge.

const corner_t &corner0() const

Get the lower corner of this edge.

Note that “lower” here means the one closer to the origin.

See
corner1(), corners(), corner_set()

const corner_t &corner1() const

Get the upper corner of this edge.

Note that “upper” here means the one farther from the origin.

See
corner0(), corners(), corner_set()

const std::array<corner_t, 2> &corners() const

Retrieve a list of (2) corners associated with this edge.

See
corner0(), corner1()

const corner_set_t &corner_set() const

Retrieve the set of (2) corners associated with this edge.

See
corner0(), corner1()

const std::array<corner_t, 2> &adjacent_corners(const corner_t &corner) const

Retrieve a list of (2) adjacent corners associated with a particular corner of the edge.

See
adjacent_corner_set(), adjacent_corners(), adjacent_corner_set(const corner_t&)

const edge_set_t &adjacent_corner_set(const corner_t &corner) const

Retrieve a set of (2) corners that are adjacent with a particular corner of the edge.

See
adjacent_corners(), adjacent_corners(const corner_t&)

const std::array<edge_t, 4> &adjacent_corners() const

Retrieve a list of (4) corners that are adjacent with this edge.

const edge_set_t &adjacent_corner_set() const

Retrieve a set of (4) corners that are adjacent with this edge.

const std::array<edge_t, 2> &adjacent_edges(const corner_t &corner) const

Retrieve a list of (2) adjacent edges associated with a particular corner of the edge.

See
adjacent_set(), adjacents(), adjacent_set(const corner_t&)

const edge_set_t &adjacent_edge_set(const corner_t &corner) const

Retrieve a set of (2) edges that are adjacent with a particular corner of the edge.

See
adjacents(), adjacents(const corner_t&)

const std::array<edge_t, 4> &adjacent_edges() const

Retrieve a list of (4) edges that are adjacent with this edge.

const edge_set_t &adjacent_edge_set() const

Retrieve a set of (4) edges that are adjacent with this edge.

const std::array<face_t, 2> &faces() const

Retrieve a list of (2) faces that are adjacent with this edge.

const face_set_t &face_set() const

Retrieve a set of (2) faces that are adjacent with this edge.

const face_t &end_face(const corner_t &corner) const

Retrieve a face that is not directly adjacent, but is perpendicular and touching with the specified end of this edge.

See
end_faces(), end_face_set()

const std::array<face_t, 2> &end_faces() const

Retrieve a list of (2) faces that are not directly adjacent, but are perpendicular and touching with the ends of this edge.

See
end_face(), end_face_set()

const face_set_t &end_face_set() const

Retrieve a list of (2) faces that are not directly adjacent, but are perpendicular and touching with the ends of this edge.

See
end_face(), end_faces()

const edge_t &opposite() const

Retrieve the edge on the opposite side of the cube.

const edge_t &opposite(const face_t &face) const

Retrieve the edge on the opposite side of the specified face.

bool is_adjacent(const edge_t &other) const

Returns true if.

Note
that this will NOT return true for (*this).is_adjacent(*this).
Parameters
  • other -

    is an edge adjacent to this edge; otherwise returns false.

bool is_adjacent(const face_t &face) const

Returns true if.

Parameters
  • face -

    is a face adjacent to this edge; otherwise returns false.

bool is_adjacent(const corner_t &corner) const

Returns true if.

Parameters
  • corner -

    is a corner adjacent to this edge; otherwise returns false.

bool is_null() const

Test if an edge is a “null” edge.

std::uint_fast8_t base_axis() const

Returns the “base-axis” (in {0,1,2} for the x,y,z axis repsectively) that this edge is aligned with this edge.

See
secondary_axis(), tertiary_axis(), get(std::uint_fast8_t,bool,bool)

std::uint_fast8_t secondary_axis() const

Returns the “secondary-axis” (in {0,1,2} for the x,y,z axis repsectively); the “secondary-axis” is the next axis (modular increment) from the “base-axis”.

See
base_axis(), tertiary_axis(), get(std::uint_fast8_t,bool,bool)

std::uint_fast8_t tertiary_axis() const

Returns the “tertiary-axis” (in {0,1,2} for the x,y,z axis repsectively); the “tertiary-axis” is the next axis (modular increment) from the “secondary-axis”.

See
base_axis(), secondary_axis(), get(std::uint_fast8_t,bool,bool)

bool project_secondary() const

Returns true if this edge is closer to or farther from the lower (-1,-1,-1) corner in the cube, specifically compared with the other parallel edge along the “secondary-axis”.

See
base_axis(), secondary_axis(), get(std::uint_fast8_t,bool,bool)

bool project_tertiary() const

Returns true if this edge is closer to or farther from the lower (-1,-1,-1) corner in the cube, specifically compared with the other parallel edge along the “tertiary-axis”.

See
base_axis(), tertiary_axis(), get(std::uint_fast8_t,bool,bool)

std::uint_fast8_t index() const

Retrieve a numeric 0-based index for the edge, for use in indexing when storing in an array, or for comparison when storing in a container requiring comparison.

The index will be less than SIZE(). The “null” edge has no index, and it is illegal to call index() on it.

See
get(std::uint_fast8_t idx)

bool operator<(const edge_t &other) const

A comparison operator for using the edge in an std::set-like container.

bool operator==(const edge_t &other) const

Equality operator, can be used between null edge and non-null-edges etc. Two null edges are equal.

bool operator!=(const edge_t &other) const

Inequality operator, can be used between null edge and non-null-edges etc. Two null edges are equal.

Public Static Functions

static const std::array<edge_t, 12> &all()

Retrieve a list of all (12) edges on the cube.

static const edge_t &null_edge()

Retrieve the “null” edge.

static const edge_t &get(std::uint_fast8_t idx)

Retrieve an edge by its index.

See
index()

static const edge_t &get(std::uint_fast8_t axis, bool project_secondary, bool project_tertiary)

Retrieves an edge by the following descriptive logic:

First, choose a base-axis, the X axis, the Y axis or the Z axis (0,1, or 2 respectively).

Second, let us define the “secondary-axis” as the first non-base-axis in (X,Y,Z), and the “tertiary-axis” as the remaining non-base-axis.

Finally, you can “project” the axis across the cube in the direction of the secondary or tertiary axes.

There are four combinations of projection: project none, project the secondary only, project the tertiary only, and project it across both, which would give an edge on the far side of the cube.

See
base_axis(), secondary_axis(), tertiary_axis(), project_secondary(), project_tertiary()

static const edge_t &get(const corner_t &corner0, const corner_t &corner1)

Retrieves an edge via the two corners.

Note, the corners specified here may be in any order so long as they are adjacent; however the edge canonicalizes the order so that calls to corner0() and corner1() may not match the two corners used to obtain the edge here.

See
corner0(), corner1()

static std::size_t SIZE()

Number of edges.