cubelib_corner_t¶
////////////////////////////////////////////////////////////////////////////////
//Headers
////////////////////////////////////////////////////////////////////////////////
//forward declarations
#include <cubelib/cubelib.fwd.h>
//API
#include <cubelib/cubelib.h>
-
group
cubelib-corner-group This is the API for cubelib_corner_t.
Typedefs
-
typedef
cubelib_corner_t¶ Struct that represents a corner.
Functions
-
bool
cubelib_is_corner_valid(cubelib_corner_t corner)¶ Checks that a corner is not corrupted somehow and represents a valid corner (including a null corner).
-
bool
cubelib_is_corner_null(cubelib_corner_t corner)¶ Returns true if this corner is a null corner.
- See
- cubelib_is_corner_valid(), cubelib_null_corner, CUBELIB_NULL_CORNER
-
bool
cubelib_is_corner_equal(cubelib_corner_t left, cubelib_corner_t right)¶ Comparison.
-
int
cubelib_get_corner_x(cubelib_corner_t corner)¶ get the “origin-centered-cube-representation” x component of the corner.
-
int
cubelib_get_corner_y(cubelib_corner_t corner)¶ get the “origin-centered-cube-representation” y component of the corner.
-
int
cubelib_get_corner_z(cubelib_corner_t corner)¶ get the “origin-centered-cube-representation” z component of the corner.
-
int
cubelib_get_corner_i(cubelib_corner_t corner, uint_fast8_t dim)¶ get the “origin-centered-cube-representation” i-th component of the corner.
- See
cubelib_get_corner_x(), cubelib_get_corner_y(), cubelib_get_corner_z(), cubelib_get_corner_ui()
- Parameters
dim-an index representing the component dimension.
-
int
cubelib_get_corner_ux(cubelib_corner_t corner)¶ get the “unit-cube-representation” x component of the corner.
-
int
cubelib_get_corner_uy(cubelib_corner_t corner)¶ get the “unit-cube-representation” y component of the corner.
-
int
cubelib_get_corner_uz(cubelib_corner_t corner)¶ get the “unit-cube-representation” z component of the corner.
-
int
cubelib_get_corner_ui(cubelib_corner_t corner, uint_fast8_t dim)¶ get the “unit-cube-representation” i-th component of the corner.
- See
- cubelib_get_corner_ux(), cubelib_get_corner_uy(), cubelib_get_corner_uz(), cubelib_get_corner_i()
- Parameters
dim-an index representing the component dimension.
-
cubelib_corner_t
cubelib_get_corner_by_float3(float x, float y, float z)¶ gets a corner using 3 floats, same as cubelib_get_corner_by_int3().
-
cubelib_corner_t
cubelib_get_corner_by_int3(int x, int y, int z)¶ Gets a corner using 3 component integer vector representation.
Each component represents a dimension in the cube; if the component value is more than 0, then it is an upper corner (in that dimension); if it is zero or negative, then it is a lower corner. This accomodates both cube representations, “unit-cube-representation” (where \(x,y,z \in \left\{0,1\right\}\)) or the “origin-centered-cube-representation” (where \(x,y,z \in \left\{-1,+1\right\}\)).
-
uint_fast8_t
cubelib_get_corner_index(cubelib_corner_t corner)¶ Returns a 0-based index that represents this corner; for use in array indexing and similar.
The index returned will be in 3D Z-order curve also known as “Morton order”, within the cube, in the range \([0,7]\).
-
cubelib_corner_t
cubelib_get_corner_by_index(uint_fast8_t index)¶ Return a corner based on the 0-based index returned by cubelib_get_corner_index().
-
cubelib_corner_t
cubelib_get_opposite_corner(cubelib_corner_t corner)¶ Return the corner on the opposite side of the cube.
-
cubelib_corner_t
cubelib_get_adjacent_corner(cubelib_corner_t corner, cubelib_direction_t direction)¶ Retrieve an adjacent a corner in a specified dimension.
If the new corner cannot be moved in the specified direction then this method will wrap around and return the adjacent corner in the specified direction.
-
cubelib_corner_t
cubelib_calc_adjacent_corner(cubelib_corner_t corner, cubelib_direction_t direction)¶
-
cubelib_corner_t
cubelib_corner_move(cubelib_corner_t corner, cubelib_direction_t direction)¶ Move a corner in a specified direction.
& If the new corner cannot be moved in that direction then this method will return a
null_corner.
-
cubelib_corner_t
cubelib_corner_push(cubelib_corner_t corner, cubelib_direction_t direction)¶ Push a corner in a specified direction.
If the new corner cannot be moved in that direction then this method will return the same corner.
-
bool
cubelib_calc_is_corner_adjacent_corner(cubelib_corner_t corner0, cubelib_corner_t corner1)¶
-
bool
cubelib_is_corner_adjacent_corner(cubelib_corner_t corner0, cubelib_corner_t corner1)¶ Returns true if the two corners are adjacent.
-
cubelib_corner_t
cubelib_calc_cnr_adj_cnr(cubelib_corner_t corner, uint_fast8_t dim)¶
-
cubelib_edge_t
cubelib_calc_cnr_adj_edge(cubelib_corner_t corner, uint_fast8_t idx)¶
-
cubelib_face_t
cubelib_calc_cnr_adj_face(cubelib_corner_t corner, uint_fast8_t idx)¶
Variables
-
cubelib_corner_t
cubelib_null_corner¶
-
size_t
cubelib_corners_size¶
-
cubelib_corner_t cubelib_cnr_adj_cnrs[8][3] Index through this array with the corner’s index, to obtain the 3 adjacent corners.
Example:
for (int i = 0; i < 3; ++i) cubelib_corner_t adj_corner_i = cubelib_cnr_adj_cnrs[ cubelib_get_corner_index(corner) ][i];
-
cubelib_corner_t cubelib_all_corners[8]
-
struct
cubelib_corner_t¶ - #include <cubelib/cubelib.h>
Struct that represents a corner.
-
typedef