AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
Vector2.hpp
1/*
2Copyright (C) 2019,2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_VECTOR2_H
17#define AEONGUI_VECTOR2_H
18#include <cstddef>
19#include <cstdint>
20#include "aeongui/Platform.hpp"
21namespace AeonGUI
22{
23 class Matrix2x3;
30 class Vector2
31 {
32 public:
34 DLL Vector2();
39 DLL Vector2 ( double aX, double aY );
43 DLL double GetX() const;
47 DLL double GetY() const;
51 DLL void SetX ( double aX );
55 DLL void SetY ( double aY );
59 DLL double Length() const;
64 DLL const double& operator[] ( std::size_t aIndex ) const;
69 DLL double& operator[] ( std::size_t aIndex );
74 DLL Vector2& operator+= ( const Vector2& aRight );
79 DLL Vector2& operator-= ( const Vector2& aRight );
84 DLL Vector2& operator*= ( const Matrix2x3& aRight );
89 DLL Vector2& operator*= ( const Vector2& aRight );
94 DLL Vector2& operator*= ( double aRight );
99 DLL Vector2& operator/= ( double aRight );
100 private:
101 double mVector2[2];
102 };
103
104 DLL Vector2 operator+ ( const Vector2& aLeft, const Vector2& aRight );
106 DLL Vector2 operator- ( const Vector2& aLeft, const Vector2& aRight );
108 DLL Vector2 operator* ( const Vector2& aLeft, const Matrix2x3& aRight );
110 DLL Vector2 operator* ( const Vector2& aLeft, const Vector2& aRight );
112 DLL Vector2 operator/ ( const Vector2& aLeft, double aRight );
114 DLL Vector2 operator* ( const Vector2& aLeft, double aRight );
116 DLL Vector2 Abs ( const Vector2& aVector2 );
118 DLL double Dot ( const Vector2& aLeft, const Vector2& aRight );
120 DLL double Distance ( const Vector2& aLeft, const Vector2& aRight );
121}
122#endif
Platform-specific DLL import/export macros and compiler helpers.
2x3 affine transformation matrix.
Definition Matrix2x3.hpp:37
2D vector of doubles.
Definition Vector2.hpp:31
double GetX() const
Get the X component.
Definition Vector2.cpp:32
void SetY(double aY)
Set the Y component.
Definition Vector2.cpp:44
Vector2 & operator/=(double aRight)
Scalar divide in-place.
Definition Vector2.cpp:80
double GetY() const
Get the Y component.
Definition Vector2.cpp:36
Vector2 & operator-=(const Vector2 &aRight)
Subtract another vector in-place.
Definition Vector2.cpp:73
Vector2()
Default constructor. Initializes to (0, 0).
Definition Vector2.cpp:21
const double & operator[](std::size_t aIndex) const
Access a component by index (const).
Definition Vector2.cpp:52
Vector2 & operator+=(const Vector2 &aRight)
Add another vector in-place.
Definition Vector2.cpp:61
Vector2 & operator*=(const Matrix2x3 &aRight)
Transform by a Matrix2x3 in-place.
Definition Vector2.cpp:97
double Length() const
Get the length (magnitude) of the vector.
Definition Vector2.cpp:48
void SetX(double aX)
Set the X component.
Definition Vector2.cpp:40