Core 1.0
|
Hexagon with arbitrary orientations. More...
#include <hexagon.h>
Public Member Functions | |
HexagonAlpha2 () | |
Empty. More... | |
HexagonAlpha2 (const Vector2 &, const double &, const double &=0.0) | |
Create an oriented hexagon. More... | |
HexagonAlpha2 (const Hexagon2 &, const double &=0.0) | |
Create an hexagon. More... | |
void | Rotate (const double &) |
Rotates an hexagon. More... | |
Vector2 | Vertex (int) const |
Return the coordinates of the k-th vertex. More... | |
Box2 | GetBox () const |
Compute the (coarse) bounding box of a hexagon. More... | |
Box2 | GetTightBox () const |
Compute the (tight) bounding box of a hexagon. More... | |
void | Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const |
Draws an hexagon. More... | |
Public Member Functions inherited from Hexagon2 | |
Hexagon2 () | |
Empty. | |
Hexagon2 (const Vector2 &, const double &) | |
Create an hexagon. More... | |
Hexagon2 (const double &) | |
Create an hexagon. More... | |
void | Translate (const Vector2 &) |
Translate a hexagon. More... | |
void | Scale (const double &) |
Scale a hexagon. More... | |
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. More... | |
bool | Intersect (const Hexagon2 &) const |
Check if two hexagons intersect. More... | |
double | R (const Vector2 &) const |
Compute the squared Euclidean distance to the hexagon. More... | |
double | Signed (const Vector2 &) const |
Compute the signed Euclidean distance to the hexagon. More... | |
Vector2 | Normal (const Vector2 &) const |
Computes the distance vector between a hexagon and a point. More... | |
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. More... | |
Vector2 | Edge (int) const |
Return the edge vector connecting vertexes k and k+1. More... | |
Vector2 | Vertex (int) const |
Return the coordinates of the k-th vertex. More... | |
Box2 | GetBox () const |
Compute the bounding box of a hexagon. | |
double | Area () const |
Area of the hexagon. | |
double | Perimeter () const |
Perimeter of the hexagon. | |
bool | Intersect (const Circle2 &) const |
Check the intersection with a circle. More... | |
void | Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const |
Draws an hexagon. More... | |
Protected Attributes | |
double | a |
Angle. | |
Vector2 | x |
Base vector. | |
Protected Attributes inherited from Hexagon2 | |
Vector2 | c = Vector2::Null |
Center. | |
double | r = 1.0 |
Radius. | |
Friends | |
std::ostream & | operator<< (std::ostream &, const HexagonAlpha2 &) |
Overloaded. More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from Hexagon2 | |
static int | Sector (const Vector2 &) |
Compute the sector given an input direction. More... | |
Static Protected Attributes inherited from Hexagon2 | |
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. | |
Hexagon with arbitrary orientations.
The reference hexagon is the flat topped hexagon. Pointy topped hexagons can be derived by setting the rotation angle to 30 degrees.
|
inline |
Empty.
Constructor.
|
explicit |
Create an oriented hexagon.
c | Center. |
r | Radius. |
a | Angle of rotation. |
|
explicit |
Create an hexagon.
h | Hexagon. |
a | Angle of rotation. |
void HexagonAlpha2::Draw | ( | QGraphicsScene & | scene, |
const QPen & | pen = QPen() , |
||
const QBrush & | brush = QBrush() |
||
) | const |
Draws an hexagon.
scene | Graphics scene. |
pen | The pen. |
brush | The brush. |
Box2 HexagonAlpha2::GetBox | ( | ) | const |
Compute the (coarse) bounding box of a hexagon.
This code is the same as:
For a tighter bounding box, use GetTightBox().
Box2 HexagonAlpha2::GetTightBox | ( | ) | const |
void HexagonAlpha2::Rotate | ( | const double & | ra | ) |
Rotates an hexagon.
ra | Rotation angle. |
Vector2 HexagonAlpha2::Vertex | ( | int | k | ) | const |
Return the coordinates of the k-th vertex.
k | Index, should be in [0,5]. |
|
friend |
Overloaded.
s | Stream. |
hex | The hexagon. |