ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
asw::Vec3< T > Class Template Reference

A 3D vector in space. More...

#include <geometry.h>

Public Member Functions

 Vec3 ()=default
 Default constructor for the Vec3 class.
 
 Vec3 (T x, T y, T z)
 Constructor for the Vec3 class.
 
angle (const Vec3 &other) const
 Get angle between two vectors (in 3D space).
 
distance (const Vec3 &other) const
 Get distance between two vectors.
 
dot (const Vec3 &other) const
 Calculate the dot product of two vectors.
 
Vec3 cross (const Vec3 &other) const
 Calculate the cross product of two vectors.
 
magnitude () const
 Calculate the magnitude of the vector.
 
Vec3 operator+ (const Vec3 &other) const
 Addition operator for the Vec3 class.
 
Vec3 operator- (const Vec3 &other) const
 Subtraction operator for the Vec3 class.
 
Vec3 operator* (const T scalar) const
 Multiplication operator for the Vec3 class.
 
Vec3 operator/ (const T scalar) const
 Division operator for the Vec3 class.
 
Vec3 operator% (const T scalar) const
 Modulo the Vec3 object by a scalar.
 
Vec3operator+= (const Vec3 &other)
 Addition assignment operator for the Vec3 class.
 
Vec3operator-= (const Vec3 &other)
 Subtraction assignment operator for the Vec3 class.
 
Vec3operator*= (const T scalar)
 Multiplication assignment operator for the Vec3 class.
 
Vec3operator/= (const T scalar)
 Division assignment operator for the Vec3 class.
 
Vec3operator%= (const T scalar)
 Modulo assignment operator for the Vec3 class.
 
bool operator== (const Vec3 &other) const =default
 Equality operator for the Vec3 class.
 

Public Attributes

x { 0 }
 The x component of the vector.
 
y { 0 }
 The y component of the vector.
 
z { 0 }
 The z component of the vector.
 

Detailed Description

template<typename T>
class asw::Vec3< T >

A 3D vector in space.

This class represents a 3D vector in space. It is used to represent points, directions, and sizes.

Definition at line 226 of file geometry.h.

Constructor & Destructor Documentation

◆ Vec3() [1/2]

template<typename T >
asw::Vec3< T >::Vec3 ( )
default

Default constructor for the Vec3 class.

◆ Vec3() [2/2]

template<typename T >
asw::Vec3< T >::Vec3 ( T x,
T y,
T z )
inline

Constructor for the Vec3 class.

Parameters
xThe x component of the vector.
yThe y component of the vector.
zThe z component of the vector.

Definition at line 238 of file geometry.h.

Member Function Documentation

◆ angle()

template<typename T >
T asw::Vec3< T >::angle ( const Vec3< T > & other) const
inline

Get angle between two vectors (in 3D space).

Returns
The angle of the vector in radians.

Definition at line 249 of file geometry.h.

◆ cross()

template<typename T >
Vec3 asw::Vec3< T >::cross ( const Vec3< T > & other) const
inline

Calculate the cross product of two vectors.

Parameters
otherThe vector to cross with.
Returns
Vec3 The cross product of the vectors.

Definition at line 281 of file geometry.h.

◆ distance()

template<typename T >
T asw::Vec3< T >::distance ( const Vec3< T > & other) const
inline

Get distance between two vectors.

Returns
The distance between the vectors.

Definition at line 260 of file geometry.h.

◆ dot()

template<typename T >
T asw::Vec3< T >::dot ( const Vec3< T > & other) const
inline

Calculate the dot product of two vectors.

Parameters
otherThe vector to dot with.
Returns
T The dot product of the vectors.

Definition at line 271 of file geometry.h.

◆ magnitude()

template<typename T >
T asw::Vec3< T >::magnitude ( ) const
inline

Calculate the magnitude of the vector.

Returns
T The magnitude of the vector.

Definition at line 291 of file geometry.h.

◆ operator%()

template<typename T >
Vec3 asw::Vec3< T >::operator% ( const T scalar) const
inline

Modulo the Vec3 object by a scalar.

Parameters
scalarThe scalar to modulo by
Returns
Vec3 The result of the modulo

Definition at line 341 of file geometry.h.

◆ operator%=()

template<typename T >
Vec3 & asw::Vec3< T >::operator%= ( const T scalar)
inline

Modulo assignment operator for the Vec3 class.

Parameters
scalarThe scalar to modulo by.
Returns
Vec3& The result of the modulo operation.

Definition at line 403 of file geometry.h.

◆ operator*()

template<typename T >
Vec3 asw::Vec3< T >::operator* ( const T scalar) const
inline

Multiplication operator for the Vec3 class.

Parameters
scalarThe scalar to multiply by.
Returns
Vec3 The scaled vector.

Definition at line 321 of file geometry.h.

◆ operator*=()

template<typename T >
Vec3 & asw::Vec3< T >::operator*= ( const T scalar)
inline

Multiplication assignment operator for the Vec3 class.

Parameters
scalarThe scalar to multiply by.
Returns
Vec3& The scaled vector.

Definition at line 377 of file geometry.h.

◆ operator+()

template<typename T >
Vec3 asw::Vec3< T >::operator+ ( const Vec3< T > & other) const
inline

Addition operator for the Vec3 class.

Parameters
otherThe vector to add.
Returns
Vec3 The sum of the vectors.

Definition at line 301 of file geometry.h.

◆ operator+=()

template<typename T >
Vec3 & asw::Vec3< T >::operator+= ( const Vec3< T > & other)
inline

Addition assignment operator for the Vec3 class.

Parameters
otherThe vector to add.
Returns
Vec3& The sum of the vectors.

Definition at line 351 of file geometry.h.

◆ operator-()

template<typename T >
Vec3 asw::Vec3< T >::operator- ( const Vec3< T > & other) const
inline

Subtraction operator for the Vec3 class.

Parameters
otherThe vector to subtract.
Returns
Vec3 The difference of the vectors.

Definition at line 311 of file geometry.h.

◆ operator-=()

template<typename T >
Vec3 & asw::Vec3< T >::operator-= ( const Vec3< T > & other)
inline

Subtraction assignment operator for the Vec3 class.

Parameters
otherThe vector to subtract.
Returns
Vec3& The difference of the vectors.

Definition at line 364 of file geometry.h.

◆ operator/()

template<typename T >
Vec3 asw::Vec3< T >::operator/ ( const T scalar) const
inline

Division operator for the Vec3 class.

Parameters
scalarThe scalar to divide by.
Returns
Vec3 The scaled vector.

Definition at line 331 of file geometry.h.

◆ operator/=()

template<typename T >
Vec3 & asw::Vec3< T >::operator/= ( const T scalar)
inline

Division assignment operator for the Vec3 class.

Parameters
scalarThe scalar to divide by.
Returns
Vec3& The scaled vector.

Definition at line 390 of file geometry.h.

◆ operator==()

template<typename T >
bool asw::Vec3< T >::operator== ( const Vec3< T > & other) const
default

Equality operator for the Vec3 class.

Parameters
otherThe vector to compare.
Returns
bool True if the vectors are equal.

Member Data Documentation

◆ x

template<typename T >
T asw::Vec3< T >::x { 0 }

The x component of the vector.

Definition at line 419 of file geometry.h.

◆ y

template<typename T >
T asw::Vec3< T >::y { 0 }

The y component of the vector.

Definition at line 422 of file geometry.h.

◆ z

template<typename T >
T asw::Vec3< T >::z { 0 }

The z component of the vector.

Definition at line 425 of file geometry.h.


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