Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
Vector3.hpp
Go to the documentation of this file.
1/*
2Copyright (C) 2015-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 AEONGAMES_VECTOR3_H
17#define AEONGAMES_VECTOR3_H
23
25#include <cstdint>
26
27namespace AeonGames
28{
29 class Plane;
31 class Vector3
32 {
33 public:
35 DLL Vector3();
40 DLL Vector3 ( const float* const aVector );
45 DLL Vector3 ( const void* const aVector, const uint32_t aStride );
51 DLL Vector3 ( float aX, float aY, float aZ );
55 DLL void Get ( float* aData ) const;
59 DLL const float* const GetVector3() const;
63 DLL const float& GetX() const;
67 DLL const float& GetY() const;
71 DLL const float& GetZ() const;
75 DLL void SetVector3 ( const float* const aVector );
80 DLL void SetVector3 ( const void* const aVector, const uint32_t aStride );
84 DLL float GetLenghtSquared() const;
88 DLL float GetLenght() const;
92 DLL size_t GetMaxAxisIndex() const;
96 DLL size_t GetMinAxisIndex() const;
100 DLL float GetMaxAxisLenght() const;
104 DLL float GetMinAxisLenght() const;
109 DLL float GetDistanceToPlane ( const Plane& aPlane ) const;
113 DLL bool IsZero() const;
116
117 DLL Vector3& operator= ( const float* aLhs );
119 DLL Vector3& operator-= ( const Vector3& aLhs );
121 DLL Vector3& operator+= ( const Vector3& aLhs );
123 DLL Vector3& operator*= ( const float aLhs );
125 DLL Vector3& operator*= ( const Vector3& aLhs );
127 DLL Vector3& operator/= ( const float aLhs );
129 DLL float operator[] ( const size_t aIndex ) const;
131 DLL float& operator [] ( const size_t aIndex );
133 protected:
135 float mVector[3];
136 };
137
142 DLL const Vector3 operator- ( const Vector3& aLhs, const Vector3& aRhs );
148 DLL const Vector3 operator+ ( const Vector3& aLhs, const Vector3& aRhs );
154 DLL const Vector3 operator* ( const Vector3& aLhs, const float aRhs );
160 DLL const Vector3 operator/ ( const Vector3& aLhs, const float aRhs );
166 DLL const Vector3 operator* ( const float aLhs, const Vector3& aRhs );
172 DLL const Vector3 operator* ( const Vector3& aLhs, const Vector3& aRhs );
178 DLL bool operator!= ( const Vector3& aLhs, const Vector3& aRhs );
184 DLL bool operator== ( const Vector3& aLhs, const Vector3& aRhs );
190 DLL const Vector3 Cross ( const Vector3& aLhs, const Vector3& aRhs );
196 DLL const float Dot ( const Vector3& aLhs, const Vector3& aRhs );
201 DLL const Vector3 Normalize ( const Vector3& aVector );
206 DLL const Vector3 Abs ( const Vector3& aVector );
215 DLL const Vector3 Spline ( const Vector3& p0, const Vector3& p1, const Vector3& p2, const Vector3& p3, double interpolation );
216}
217#endif
Platform-specific macros, includes, and DLL export/import definitions.
Plane class.
Definition Plane.hpp:33
3D vector class.
Definition Vector3.hpp:32
DLL float GetLenghtSquared() const
Get the squared length of the vector.
Definition Vector3.cpp:49
DLL const float *const GetVector3() const
Get a pointer to the internal vector data.
Definition Vector3.cpp:102
DLL float operator[](const size_t aIndex) const
Access a component by index (const).
Definition Vector3.cpp:131
DLL float GetMaxAxisLenght() const
Get the absolute value of the largest axis component.
Definition Vector3.cpp:75
DLL const float & GetZ() const
Get the Z component.
Definition Vector3.cpp:118
DLL float GetMinAxisLenght() const
Get the absolute value of the smallest axis component.
Definition Vector3.cpp:80
DLL size_t GetMaxAxisIndex() const
Get the index of the axis with the largest absolute value.
Definition Vector3.cpp:59
DLL float GetDistanceToPlane(const Plane &aPlane) const
Get the signed distance from this point to a plane.
Definition Vector3.cpp:85
DLL float GetLenght() const
Get the length of the vector.
Definition Vector3.cpp:54
DLL Vector3 & operator=(const float *aLhs)
Assign from a raw float array.
Definition Vector3.cpp:143
DLL Vector3 & operator*=(const float aLhs)
Scale this vector by a scalar.
Definition Vector3.cpp:181
DLL Vector3 & operator/=(const float aLhs)
Divide this vector by a scalar.
Definition Vector3.cpp:197
DLL void SetVector3(const float *const aVector)
Set the vector from a float array.
Definition Vector3.cpp:32
DLL bool IsZero() const
Check whether all components are zero.
Definition Vector3.cpp:205
DLL Vector3 & operator-=(const Vector3 &aLhs)
Subtract a vector from this vector.
Definition Vector3.cpp:149
DLL const float & GetY() const
Get the Y component.
Definition Vector3.cpp:112
DLL Vector3()
Default constructor.
Definition Vector3.cpp:22
float mVector[3]
X,Y,Z.
Definition Vector3.hpp:135
DLL Vector3 & operator+=(const Vector3 &aLhs)
Add a vector to this vector.
Definition Vector3.cpp:166
DLL const float & GetX() const
Get the X component.
Definition Vector3.cpp:107
DLL void Get(float *aData) const
Copy vector data to an external float array.
Definition Vector3.cpp:97
DLL size_t GetMinAxisIndex() const
Get the index of the axis with the smallest absolute value.
Definition Vector3.cpp:67
<- This is here just for the literals
Definition AABB.hpp:31
DLL const Vector3 Spline(const Vector3 &p0, const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, double interpolation)
Catmull-Rom spline interpolation between four control points.
Definition Vector3.cpp:275
DLL bool operator!=(const Vector3 &aLhs, const Vector3 &aRhs)
Inequality comparison operator.
Definition Vector3.cpp:239
DLL const Vector3 operator/(const Vector3 &aLhs, const float aRhs)
Scalar division operator.
Definition Vector3.cpp:218
DLL const Matrix3x3 operator*(const Matrix3x3 &lhs, const Matrix3x3 &rhs)
Multiplies two 3x3 matrices. Multiplies two 3x3 matrices.
DLL const float Dot(const Vector3 &aLhs, const Vector3 &aRhs)
Compute the dot product of two vectors.
Definition Vector3.cpp:249
DLL const Vector3 operator+(const Vector3 &aLhs, const Vector3 &aRhs)
Addition operator.
Definition Vector3.cpp:173
DLL const Matrix3x3 Abs(const Matrix3x3 &aMatrix3x3)
Compute the element-wise absolute value of a matrix.
DLL const Vector3 Cross(const Vector3 &aLhs, const Vector3 &aRhs)
Compute the cross product of two vectors.
Definition Vector3.cpp:123
DLL const Vector3 operator-(const Vector3 &aLhs, const Vector3 &aRhs)
Subtraction operator.
Definition Vector3.cpp:158
DLL const bool operator==(const Matrix3x3 &lhs, const Matrix3x3 &rhs)
Compare two 3x3 matrices for equality.
DLL const Vector3 Normalize(const Vector3 &aVector)
Return a normalized (unit length) copy of the vector.
Definition Vector3.cpp:257