|
| | HexagonArray2 (const Vector2 &, const double &, int, int) |
| | Create and array of hexagons.
|
| | HexagonArray2 (const Box2 &, const double &) |
| | Create and array of hexagons embedded in a box.
|
|
bool | IsEmpty () const |
| | Detect if the array is empty, i.e., any dimension equal to zero.
|
|
int | GetSizeX () const |
| | Get the vertex size of the array for x axis.
|
|
int | GetSizeY () const |
| | Get the vertex size of the array for y axis.
|
|
int | VertexSize () const |
| | Return the size of the vertex array.
|
| Box2 | GetBox () const |
| | Compute the bounding box of the centroids of the hexagons.
|
| Box2 | GetHexagonBox () const |
| | Compute the bounding box of all the hexagons.
|
| Vector2 | CellCenter (int, int) const |
| | Compute the center of the hexagonal cell.
|
| void | Translate (const Vector2 &) |
| | Translate the array.
|
| Vector2 | ArrayVertex (int, int) const |
| | Compute the coordinates of a point on the grid.
|
| constexpr bool | InsideVertexIndex (int, int) const |
| | Check if the indexes are within range.
|
| bool | Inside (const Vector2 &) const |
| | Check if a point is in the rectangular domain.
|
| Hexagon2 | UnitCell () const |
| | Return the geometry of a generic cell.
|
| double | CellArea () const |
| | Return the area of a cell.
|
| QPoint | Next (int, int, int) const |
| | Compute the index of the neighboring hexagon.
|
| QPoint | Next (const QPoint &, int) const |
| | Compute the index of the neighboring hexagon.
|
| void | TriangleInteger (const Vector2 &, int &, int &, double &, double &) const |
| | Compute the coordinates of a vertex inside a triangle of the hexagonal grid.
|
| QPoint | TriangleInteger (const Vector2 &) const |
| | Compute the integer coordinates of the lower vertex of the triangle of the hexagonal grid containing a point.
|
| QRect | VertexIntegerArea (const Box2 &) const |
| | Compute the integer coordinates of the vertices embedding a box.
|
| QRect | VertexIntegerArea (const Circle2 &) const |
| | Compute the integer coordinates of the vertices embedding a circle.
|
| void | Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const |
| | Draws the hexagon array.
|
| void | DrawCenters (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const |
| | Draws the centers of the hexagon grid.
|
|
| constexpr int | VertexIndex (int, int) const |
| | Compute the index of a given cell.
|
| void | InverseVertexIndex (int, int &, int &) const |
| | Compute the coordinates of a given cell.
|
| QPoint | InverseVertexIndex (int) const |
| | Compute the coordinates of a given cell.
|
| bool | InsideCellIndex (int, int) const |
| | Check if the indexes are within range.
|
|
| Hexagon2 () |
| | Empty.
|
| | Hexagon2 (const Vector2 &, const double &) |
| | Create an hexagon.
|
| | Hexagon2 (const double &) |
| | Create an hexagon.
|
| void | Translate (const Vector2 &) |
| | Translate a hexagon.
|
| void | Scale (const double &) |
| | Scale a hexagon.
|
|
double | Width () const |
| | Width of the hexagon.
|
|
double | Height () const |
| | Height of the hexagon.
|
| bool | Inside (const Vector2 &) const |
| | Test if a point is inside.
|
| bool | Intersect (const Hexagon2 &) const |
| | Check if two hexagons intersect.
|
| double | R (const Vector2 &) const |
| | Compute the squared Euclidean distance to the hexagon.
|
| double | Signed (const Vector2 &) const |
| | Compute the signed Euclidean distance to the hexagon.
|
| Vector2 | Normal (const Vector2 &) const |
| | Computes the distance vector between a hexagon and a point.
|
|
Vector2 | Center () const |
| | Return the center of the hexagonal cell.
|
|
double | Radius () const |
| | Return the radius of the hexagonal cell.
|
| Vector2 | Radial (int) const |
| | Return the radial vector of the k-th vertex.
|
| Vector2 | Edge (int) const |
| | Return the edge vector connecting vertexes k and k+1.
|
| Vector2 | Vertex (int) const |
| | Return the coordinates of the k-th vertex.
|
|
Box2 | GetBox () const |
| | Compute the bounding box of a hexagon.
|
|
double | Area () const |
| | Area of the hexagon.
|
|
double | Perimeter () const |
| | Perimeter of the hexagon.
|
| Vector2 | RandomInside (Random &=Random::R239) const |
| | Generate a random vector inside the hexagon.
|
| QVector< Vector2 > | Poisson (const double &, int, Random &=Random::R239) const |
| | Compute a Poisson disc distribution inside the hexagon.
|
| bool | Intersect (const Circle2 &) const |
| | Check the intersection with a circle.
|
| void | Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const |
| | Draws an hexagon.
|
| double HexagonArray2::CellArea |
( |
| ) |
const |
Return the area of a cell.
This is convenience function, which is the same as the following code, but more efficient:
HexagonArray2 array;
double Area() const
Area of the hexagon.
Definition hexagon2.cpp:61
Hexagon2 UnitCell() const
Return the geometry of a generic cell.
Definition hexagonarray2.cpp:109
The area of a regular hexagon of side r is \( \frac{3\sqrt{3}}{2} r^2 = \frac{3}{4} w h \), where \( w=2r \) is the width and \( h=\sqrt{3} r \) the height of the hexagon.
- Returns
- The area of a hexagonal cell.
| void HexagonArray2::TriangleInteger |
( |
const Vector2 & | p, |
|
|
int & | i, |
|
|
int & | j, |
|
|
double & | u, |
|
|
double & | v ) const |
Compute the coordinates of a vertex inside a triangle of the hexagonal grid.
The centers of the cells are organized in columns, odd columns being shifted by half a cell, see HexagonArray2::CellCenter(). The point is first expressed in the axial coordinates of the grid, which are then rounded down (and not truncated, so that the result is also correct on the negative side) and converted into the indexes of the cells.
The point is located in the rhombus defined by the vertex (i,j), and by the vertices (i+1,j+(i&1)) and (i,j+1), which are its two neighbors in the axial directions: \( p=c_{i,j}+u (c_{i+1,j+(i&1)}-c_{i,j})+v (c_{i,j+1}-c_{i,j}) \).
- Parameters
-
| p | Point. |
| i,j | Integer coordinates of the lower vertex. |
| u,v | Coordinates of the point in the corresponding triangle, in [0,1[. |