|
Core 1.0
|
Flat topped hexagon in the plane. More...
#include <hexagon.h>
Public Member Functions | |
| 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. | |
Static Protected Member Functions | |
| static int | Sector (const Vector2 &) |
| Compute the sector given an input direction. | |
Protected Attributes | |
| Vector2 | c = Vector2::Null |
| Center. | |
| double | r = 1.0 |
| Radius. | |
Static Protected Attributes | |
| static const Vector2 | vertex [6] |
| Array of vertices. | |
| static const Vector2 | normal [6] |
| Array of normal vectors to the edges. | |
| static const Vector2 | edge [6] |
| Unit edge vectors. | |
| static const double | Alpha = sqrt(3.0) / 2.0 |
| Constant sin(π/6)=√3/2. | |
Friends | |
| std::ostream & | operator<< (std::ostream &s, const Hexagon2 &hex) |
| Overloaded. | |
Flat topped hexagon in the plane.
|
explicit |
Create an hexagon.
| c | Center. |
| r | Radius. |
|
explicit |
Create an hexagon.
| r | Radius. |
| void Hexagon2::Draw | ( | QGraphicsScene & | scene, |
| const QPen & | pen = QPen(), | ||
| const QBrush & | brush = QBrush() ) const |
Draws an hexagon.
| scene | Graphics scene. |
| pen | The pen. |
| brush | The brush. |
|
inline |
Return the edge vector connecting vertexes k and k+1.
| k | Index, should be in [0,5]. |
| bool Hexagon2::Inside | ( | const Vector2 & | p | ) | const |
Test if a point is inside.
| p | Point. |
| bool Hexagon2::Intersect | ( | const Circle2 & | circle | ) | const |
Check the intersection with a circle.
Accurate intersection test using the distance from the center of the circle to the hexagon.
| circle | The circle. |
| bool Hexagon2::Intersect | ( | const Hexagon2 & | hexagon | ) | const |
Check if two hexagons intersect.
| hexagon | Hexagon. |
Computes the distance vector between a hexagon and a point.
| p | Point. |
| QVector< Vector2 > Hexagon2::Poisson | ( | const double & | r, |
| int | n, | ||
| Random & | random = Random::R239 ) const |
Compute a Poisson disc distribution inside the hexagon.
This function uses a simple dart throwing algorithm.
| r | Radius of the discs. |
| n | Number of candidate points. |
| random | Random number generator. |
| double Hexagon2::R | ( | const Vector2 & | p | ) | const |
Compute the squared Euclidean distance to the hexagon.
| p | Point. |
|
inline |
Return the radial vector of the k-th vertex.
| k | Index, should be in [0,5]. |
| Vector2 Hexagon2::RandomInside | ( | Random & | random = Random::R239 | ) | const |
Generate a random vector inside the hexagon.
| random | Random number generator. |
| void Hexagon2::Scale | ( | const double & | s | ) |
Scale a hexagon.
| s | Scaling factor. |
|
staticprotected |
Compute the sector given an input direction.
| d | Direction. |
| double Hexagon2::Signed | ( | const Vector2 & | p | ) | const |
Compute the signed Euclidean distance to the hexagon.
| p | Point. |
| void Hexagon2::Translate | ( | const Vector2 & | t | ) |
Translate a hexagon.
| t | Translation vector. |
|
inline |
Return the coordinates of the k-th vertex.
| k | Index, should be in [0,5]. |
|
friend |
Overloaded.
| s | Stream. |
| hex | The hexagon. |