cubexx::corner_t

struct cubexx::corner_t

Represents a corner of a cube.

There are 8 corners in a cube.

Public Functions

corner_t()

Default construct a “null” corner.

const corner_t &push(const direction_t &direction) const

Returns a corner that is the next corner in the specified direction.

Specifically, it will NOT wrap around the cube if there is no corner in the specified direction; but instead return the same corner.

See
adjacent(), move()

const corner_t &move(const direction_t &direction) const

Returns a corner that is the next corner in the specified direction.

Specifically, it will NOT wrap around the cube if there is no corner in the specified direction; but instead return the null corner.

See
adjacent(), push()

const corner_t &adjacent(const direction_t &direction) const

Returns a corner that is adjacent in the axis of the direction.

Specifically, it will wrap around the cube if there is no corner in the specified direction

See
push(), move(), adjacents(), adjacent_set()

bool is_adjacent(const corner_t &other) const

Returns true if.

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

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

bool is_adjacent(const edge_t &edge) const

Returns true if.

Parameters
  • edge -

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

bool is_adjacent(const face_t &face) const

Returns true if.

Parameters
  • face -

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

const direction_t &get_adjacent_direction(const corner_t &other) const

Returns the direction between two adjacent corners.

const std::array<corner_t, 3> &adjacents() const

Returns a list of 3 adjacent corners to this corner.

See
adjacent_set()

const corner_set_t &adjacent_set() const

Returns a set of 3 adjacent corners to this corner.

See
adajcents()

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

Returns the 3 adjacent faces to this corner.

See
face_set()

const face_set_t &face_set() const

Returns a set of the 3 adjacent faces to this corner.

See
faces()

const std::array<edge_t, 3> &edges() const

Returns a set of the 3 adjacent edges to this corner.

See
edge_set()

const edge_set_t &edge_set() const

Returns a set of the 3 adjacent edges to this corner.

See
edge_set()

const edge_t &edge(const direction_t &direction) const

Returns the edge between this corner and an adjacent corner, specified via the.

See
edges, edge_set(), corner_t::edge(const corner_t&)
Parameters
  • direction -

    parameter. If the direction is pointing outside of the cube from this corner, it will return the edge between this corner and the corner in the opposite direction.

const edge_t &edge(const corner_t &other) const

Returns the edge between this corner and an adjacent corner, specified via the.

See
edges, edge_set(), corner_t::edge(const direction_t&)
Parameters
  • corner -

    parameter.

const corner_t &opposite() const

Returns the opposite corner across the cube.

std::uint_fast8_t index() const

Retrieve a numeric 0-based index for the corner, 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” corner has no index, and it is illegal to call index() on it.

See
get(std::uint_fast8_t idx)

bool operator<(const corner_t &other) const

Comparison.

bool operator==(const corner_t &other) const

Comparison.

bool operator!=(const corner_t &other) const

Comparison.

std::int_fast8_t x() const

Return an integer in {-1,1} depending if the corner is in the near side or the far side of the x, respectively.

See

get(std::int_fast8_t,std::int_fast8_t,std::int_fast8_t)

x(), y(), z(), ux(), uy(), uz()

std::int_fast8_t y() const

Return an integer in {-1,1} depending if the corner is in the near side or the far side of the y, respectively.

See

get(std::int_fast8_t,std::int_fast8_t,std::int_fast8_t)

x(), y(), z(), ux(), uy(), uz()

std::int_fast8_t z() const

Return an integer in {-1,1} depending if the corner is in the near side or the far side of the z, respectively.

See

get(std::int_fast8_t,std::int_fast8_t,std::int_fast8_t)

x(), y(), z(), ux(), uy(), uz()

std::uint_fast8_t ux() const

Return an unsigned integer in {0,1} depending if the corner is in the near side or the far side of the x, respectively.

See

get(std::int_fast8_t,std::int_fast8_t,std::int_fast8_t)

x(), y(), z(), ux(), uy(), uz()

std::uint_fast8_t uy() const

Return an unsigned integer in {0,1} depending if the corner is in the near side or the far side of the y, respectively.

See

get(std::int_fast8_t,std::int_fast8_t,std::int_fast8_t)

x(), y(), z(), ux(), uy(), uz()

std::uint_fast8_t uz() const

Return an unsigned integer in {0,1} depending if the corner is in the near side or the far side of the z, respectively.

See

get(std::int_fast8_t,std::int_fast8_t,std::int_fast8_t)

x(), y(), z(), ux(), uy(), uz()

const std::array<std::int_fast8_t, 3> &xyz() const

Return an array with all three components of the corner’s vector.

See
x(), y(), z(), get(std::int_fast8_t,std::int_fast8_t,std::int_fast8_t)

const std::array<std::uint_fast8_t, 3> &uxyz() const

Return an array with all three unsigned components of the corner’s unsigned representation vector.

See
ux(), uy(), uz(), get(std::int_fast8_t,std::int_fast8_t,std::int_fast8_t)

bool is_null() const

Returns true if this corner is null; false otherwise.

Public Static Functions

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

Returns a corner that is represented by the specified index,.

Parameters
  • idx. -

static const corner_t &get(std::int_fast8_t x, std::int_fast8_t y, std::int_fast8_t z)

Returns a corner that is represented by a vector of 3 components.

There are two representations that fit in well with the same function.

The first, which we be called “origin-centered-cube-representation” is as follows:

Cube coordinates are in the range [-1,+1], and specfically can each take one of the two values in {-1,+1}. The lower corner is represented as (-1,-1,-1). The other corners are offset away from the corner by +2, so they look like (+1,-1,-1) or (+1,+1,+1) (for the far corner), and so on. The coordinates of this representation can be retrieved via the corner_t::x(), corner_t::y(), and corner_t::z() functions.

The alternative representation, which will called “unit-cube-representation”, (or “unsigned”) is as follows:

Cube coordinates are in the range [0,1] and specifically can each take one of the two values in {0,1} The lower corner is represented as (0,0,0). The other corners are offset away from the lower corner by +1, so they look like (1,0,0) or (1,1,1) (for the far corner), and so on. The coordinates of this representation can be retrieved via the corner_t::ux(), corner_t::uy(), and corner_t::uz() functions.

This function can construct the corner_t with either reprentation. The rule is as follows: if a coordinate is positive, it will result in being +1; if it is zero or negative, it will be lower coordinate; -1 in the “origin-centered-cube-representation” or 0 in “unit-cube-representation”.

See

corner_t::x(), corner_t::y(), and corner_t::z(), corner_t::ux(), corner_t::uy(), and corner_t::uz()

cubelib_get_corner_by_int3()

static const corner_t &get(const corner_t &corner)

Returns a corner, given a corner.

static const std::array<corner_t, 8> &all()

Return a list of all the faces on the cube.

static std::size_t SIZE()

Number of corners.

static const corner_t &null_corner()

Retrieve the “null” corner.