Dura2D  v0.1.0
An educational 2D game physics library
Loading...
Searching...
No Matches
d2Vec2 Struct Reference

Represents a 2D vector. More...

#include <d2Math.h>

Public Member Functions

 d2Vec2 ()
 
 d2Vec2 (real x, real y)
 Constructor that initializes the vector with given x and y components.
 
 ~d2Vec2 ()=default
 
void Zero ()
 Sets all components of the vector to zero.
 
real Lenght () const
 Calculates the magnitude of the vector.
 
real LenghtSquared () const
 Calculates the squared magnitude of the vector.
 
d2Vec2Normalize ()
 Normalizes the vector.
 
d2Vec2 UnitVector () const
 Calculates the unit vector.
 
d2Vec2 Normal () const
 Calculates the normal of the vector.
 
real Dot (const d2Vec2 &v) const
 Calculates the dot product with another vector.
 
real Cross (const d2Vec2 &v) const
 Calculates the cross product with another vector.
 
d2Vec2operator= (const d2Vec2 &v)
 
bool operator== (const d2Vec2 &v) const
 
bool operator!= (const d2Vec2 &v) const
 
d2Vec2 operator+ (const d2Vec2 &v) const
 
d2Vec2 operator- (const d2Vec2 &v) const
 
d2Vec2 operator* (const real n) const
 
d2Vec2 operator* (const d2Vec2 &v) const
 
d2Vec2 operator/ (const real n) const
 
d2Vec2 operator- ()
 
d2Vec2operator+= (const d2Vec2 &v)
 
d2Vec2operator-= (const d2Vec2 &v)
 
d2Vec2operator*= (const d2Vec2 &v)
 
d2Vec2operator*= (const real n)
 
d2Vec2operator/= (const real n)
 

Public Attributes

real x
 
real y
 

Detailed Description

Represents a 2D vector.

Constructor & Destructor Documentation

◆ d2Vec2() [1/2]

d2Vec2::d2Vec2 ( )
inline

◆ d2Vec2() [2/2]

d2Vec2::d2Vec2 ( real x,
real y )
inline

Constructor that initializes the vector with given x and y components.

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

◆ ~d2Vec2()

d2Vec2::~d2Vec2 ( )
default

Member Function Documentation

◆ Cross()

real d2Vec2::Cross ( const d2Vec2 & v) const
inline

Calculates the cross product with another vector.

Parameters
vThe other vector.
Returns
The cross product.

◆ Dot()

real d2Vec2::Dot ( const d2Vec2 & v) const
inline

Calculates the dot product with another vector.

Parameters
vThe other vector.
Returns
The dot product.

◆ Lenght()

real d2Vec2::Lenght ( ) const
inline

Calculates the magnitude of the vector.

Returns
The magnitude of the vector.

◆ LenghtSquared()

real d2Vec2::LenghtSquared ( ) const
inline

Calculates the squared magnitude of the vector.

Returns
The squared magnitude of the vector.

◆ Normal()

d2Vec2 d2Vec2::Normal ( ) const
inline

Calculates the normal of the vector.

Returns
The normal of the vector.

◆ Normalize()

d2Vec2 & d2Vec2::Normalize ( )

Normalizes the vector.

Returns
The normalized vector.

◆ operator!=()

bool d2Vec2::operator!= ( const d2Vec2 & v) const

◆ operator*() [1/2]

d2Vec2 d2Vec2::operator* ( const d2Vec2 & v) const

◆ operator*() [2/2]

d2Vec2 d2Vec2::operator* ( const real n) const

◆ operator*=() [1/2]

d2Vec2 & d2Vec2::operator*= ( const d2Vec2 & v)

◆ operator*=() [2/2]

d2Vec2 & d2Vec2::operator*= ( const real n)

◆ operator+()

d2Vec2 d2Vec2::operator+ ( const d2Vec2 & v) const

◆ operator+=()

d2Vec2 & d2Vec2::operator+= ( const d2Vec2 & v)

◆ operator-() [1/2]

d2Vec2 d2Vec2::operator- ( )

◆ operator-() [2/2]

d2Vec2 d2Vec2::operator- ( const d2Vec2 & v) const

◆ operator-=()

d2Vec2 & d2Vec2::operator-= ( const d2Vec2 & v)

◆ operator/()

d2Vec2 d2Vec2::operator/ ( const real n) const

◆ operator/=()

d2Vec2 & d2Vec2::operator/= ( const real n)

◆ operator=()

d2Vec2 & d2Vec2::operator= ( const d2Vec2 & v)

◆ operator==()

bool d2Vec2::operator== ( const d2Vec2 & v) const

◆ UnitVector()

d2Vec2 d2Vec2::UnitVector ( ) const
inline

Calculates the unit vector.

Returns
The unit vector.

◆ Zero()

void d2Vec2::Zero ( )
inline

Sets all components of the vector to zero.

Member Data Documentation

◆ x

real d2Vec2::x

◆ y

real d2Vec2::y

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