Core 1.0
Public Member Functions | Protected Attributes | Friends | List of all members
HexagonAlpha2 Class Reference

Hexagon with arbitrary orientations. More...

#include <hexagon.h>

Inheritance diagram for HexagonAlpha2:
Hexagon2

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ HexagonAlpha2() [1/3]

HexagonAlpha2::HexagonAlpha2 ( )
inline

Empty.

Constructor.

◆ HexagonAlpha2() [2/3]

HexagonAlpha2::HexagonAlpha2 ( const Vector2 c,
const double &  r,
const double &  a = 0.0 
)
explicit

Create an oriented hexagon.

Parameters
cCenter.
rRadius.
aAngle of rotation.

◆ HexagonAlpha2() [3/3]

HexagonAlpha2::HexagonAlpha2 ( const Hexagon2 h,
const double &  a = 0.0 
)
explicit

Create an hexagon.

Parameters
hHexagon.
aAngle of rotation.

Member Function Documentation

◆ Draw()

void HexagonAlpha2::Draw ( QGraphicsScene &  scene,
const QPen &  pen = QPen(),
const QBrush &  brush = QBrush() 
) const

Draws an hexagon.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush.

◆ GetBox()

Box2 HexagonAlpha2::GetBox ( ) const

Compute the (coarse) bounding box of a hexagon.

This code is the same as:

Box2 b=Box2(h.Center(),r.Radius());
Axis aligned box in the plane.
Definition: box.h:371
double r
Radius.
Definition: hexagon.h:13
Hexagon with arbitrary orientations.
Definition: hexagon.h:118
static const Vector2 Null
Null vector.
Definition: evector.h:737

For a tighter bounding box, use GetTightBox().

See also
GetTightBox()

◆ GetTightBox()

Box2 HexagonAlpha2::GetTightBox ( ) const

Compute the (tight) bounding box of a hexagon.

This function involves trigonometric functions, significantly slower than GetBox().

See also
GetBox()

◆ Rotate()

void HexagonAlpha2::Rotate ( const double &  ra)

Rotates an hexagon.

Parameters
raRotation angle.

◆ Vertex()

Vector2 HexagonAlpha2::Vertex ( int  k) const

Return the coordinates of the k-th vertex.

Parameters
kIndex, should be in [0,5].

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const HexagonAlpha2 hex 
)
friend

Overloaded.

Parameters
sStream.
hexThe hexagon.