AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
AeonGUI::Vector2 Class Reference

2D vector of doubles. More...

#include <aeongui/Vector2.hpp>

Public Member Functions

 Vector2 ()
 Default constructor. Initializes to (0, 0).
 Vector2 (double aX, double aY)
 Construct from X and Y components.
double GetX () const
 Get the X component.
double GetY () const
 Get the Y component.
void SetX (double aX)
 Set the X component.
void SetY (double aY)
 Set the Y component.
double Length () const
 Get the length (magnitude) of the vector.
const double & operator[] (std::size_t aIndex) const
 Access a component by index (const).
double & operator[] (std::size_t aIndex)
 Access a component by index.
Vector2operator+= (const Vector2 &aRight)
 Add another vector in-place.
Vector2operator-= (const Vector2 &aRight)
 Subtract another vector in-place.
Vector2operator*= (const Matrix2x3 &aRight)
 Transform by a Matrix2x3 in-place.
Vector2operator*= (const Vector2 &aRight)
 Component-wise multiply in-place.
Vector2operator*= (double aRight)
 Scalar multiply in-place.
Vector2operator/= (double aRight)
 Scalar divide in-place.

Detailed Description

2D vector of doubles.

Provides basic 2D vector arithmetic including addition, subtraction, scalar and component-wise multiplication, division, and transformation by a Matrix2x3.

Constructor & Destructor Documentation

◆ Vector2()

AeonGUI::Vector2::Vector2 ( double aX,
double aY )

Construct from X and Y components.

Parameters
aXThe X component.
aYThe Y component.

Member Function Documentation

◆ GetX()

double AeonGUI::Vector2::GetX ( ) const

Get the X component.

Returns
The X value.

◆ GetY()

double AeonGUI::Vector2::GetY ( ) const

Get the Y component.

Returns
The Y value.

◆ Length()

double AeonGUI::Vector2::Length ( ) const

Get the length (magnitude) of the vector.

Returns
The length.

◆ operator*=() [1/3]

Vector2 & AeonGUI::Vector2::operator*= ( const Matrix2x3 & aRight)

Transform by a Matrix2x3 in-place.

Parameters
aRightThe matrix to multiply by.
Returns
Reference to this.

◆ operator*=() [2/3]

Vector2 & AeonGUI::Vector2::operator*= ( const Vector2 & aRight)

Component-wise multiply in-place.

Parameters
aRightThe vector to multiply by.
Returns
Reference to this.

◆ operator*=() [3/3]

Vector2 & AeonGUI::Vector2::operator*= ( double aRight)

Scalar multiply in-place.

Parameters
aRightThe scalar to multiply by.
Returns
Reference to this.

◆ operator+=()

Vector2 & AeonGUI::Vector2::operator+= ( const Vector2 & aRight)

Add another vector in-place.

Parameters
aRightThe vector to add.
Returns
Reference to this.

◆ operator-=()

Vector2 & AeonGUI::Vector2::operator-= ( const Vector2 & aRight)

Subtract another vector in-place.

Parameters
aRightThe vector to subtract.
Returns
Reference to this.

◆ operator/=()

Vector2 & AeonGUI::Vector2::operator/= ( double aRight)

Scalar divide in-place.

Parameters
aRightThe scalar to divide by.
Returns
Reference to this.

◆ operator[]() [1/2]

double & AeonGUI::Vector2::operator[] ( std::size_t aIndex)

Access a component by index.

Parameters
aIndex0 for X, 1 for Y.
Returns
Reference to the component.

◆ operator[]() [2/2]

const double & AeonGUI::Vector2::operator[] ( std::size_t aIndex) const

Access a component by index (const).

Parameters
aIndex0 for X, 1 for Y.
Returns
Const reference to the component.

◆ SetX()

void AeonGUI::Vector2::SetX ( double aX)

Set the X component.

Parameters
aXThe new X value.

◆ SetY()

void AeonGUI::Vector2::SetY ( double aY)

Set the Y component.

Parameters
aYThe new Y value.

The documentation for this class was generated from the following files: