template class EE::Math::Quad2

Overview

Utility template class for manipulating quads. More…

#include <quad2.hpp>

template <typename T>
class Quad2 {
public:
    // fields

    Vector2<T> V[4];

    // construction

    Quad2();
    Quad2(const tRECT<T>& R);
    Quad2(const Vector2<T>& v1, const Vector2<T>& v2, const Vector2<T>& v3, const Vector2<T>& v4);

    // methods

    const Vector2<T>& operator[](const Uint32& Pos) const;
    Vector2<T> getCenter();
    Vector2<T>& getAt(Uint32 Index);
    tRECT<T> toAABB(const T& OffsetX = 0, const T& OffsetY = 0);
    void rotate(const T& Angle, const Vector2<T>& Center);
    void rotate(const T& Angle);
    void scale(const T& scale);
    void scale(const T& scale, const Vector2<T>& center);
    void scale(const Vector2<T>& scale);
    void scale(const Vector2<T>& scale, const Vector2<T>& center);
    void move(Vector2<T> dist);
    static Quad2<T> fromAABB(const tRECT<T>& R);
};

Detailed Documentation

Utility template class for manipulating quads.

Construction

Quad2()

Default constructor creates an empty quad ( four Vector2(0,0)

Quad2(const tRECT<T>& R)

Creates a quad from a Rectangle

Quad2(const Vector2<T>& v1, const Vector2<T>& v2, const Vector2<T>& v3, const Vector2<T>& v4)

Creates a quad from four Vector2

Methods

const Vector2<T>& operator[](const Uint32& Pos) const

Returns:

The vector from the position ( position from 0 to 3 )

Vector2<T> getCenter()

Vector2<T> V[0]; //! Left - Top Vector2 Vector2<T> V[1]; //! Left - Bottom Vector2 Vector2<T> V[2]; //! Right - Bottom Vector2 Vector2<T> V[3]; //! Right - Top Vector2

Returns:

The center point of the quad

Vector2<T>& getAt(Uint32 Index)

Returns:

The Vector2 from the position index ( from 0 to 3 )

tRECT<T> toAABB(const T& OffsetX = 0, const T& OffsetY = 0)

Returns:

The Axis-Aligned bounding box of the Quad

void rotate(const T& Angle, const Vector2<T>& Center)

Rotates the quad from a rotation center

void rotate(const T& Angle)

Rotates the quad from its rotation center

void scale(const T& scale)

Scale the quad from its rotation center

void scale(const T& scale, const Vector2<T>& center)

Scale the quad from an specified center

void scale(const Vector2<T>& scale)

Scale the quad from its rotation center

void scale(const Vector2<T>& scale, const Vector2<T>& center)

Scale the quad from an specified center

void move(Vector2<T> dist)

Move the polygon Vector2s, add to every point the distance specified

static Quad2<T> fromAABB(const tRECT<T>& R)

Creates a quad from a rectangle