Nox Engine
 
Loading...
Searching...
No Matches
Vector2D Struct Reference

A simple struct for 2D mathematics (points, vectors). More...

#include <Vector2D.h>

Collaboration diagram for Vector2D:
Collaboration graph

Public Member Functions

 Vector2D (float x, float y)
 
Vector2Dadd (const Vector2D vec)
 Adds another vector to this one.
 
Vector2Dsubtract (const Vector2D vec)
 Subtracts another vector from this one.
 
Vector2Dmultiply (const Vector2D vec)
 Multiplies this vector by another, component-wise.
 
Vector2Ddivide (const Vector2D vec)
 Divides this vector by another, component-wise.
 
Vector2Doperator+= (const Vector2D &vec)
 
Vector2Doperator-= (const Vector2D &vec)
 
Vector2Doperator*= (const Vector2D &vec)
 
Vector2Doperator/= (const Vector2D &vec)
 
Vector2Doperator* (const int &i)
 Multiplies the vector by a scalar value.
 
bool operator== (const Vector2D &vec)
 
bool operator! ()
 
Vector2Dzero ()
 Resets the vector's components to zero.
 

Public Attributes

float x
 
float y
 

Friends

Vector2D operator+ (Vector2D v1, const Vector2D &v2)
 
Vector2D operator- (Vector2D v1, const Vector2D &v2)
 
Vector2D operator* (Vector2D v1, const Vector2D &v2)
 
Vector2D operator/ (Vector2D v1, const Vector2D &v2)
 
std::ostream & operator<< (std::ostream &stream, const Vector2D &vec)
 

Detailed Description

A simple struct for 2D mathematics (points, vectors).

Provides basic vector operations like addition, subtraction, and scalar multiplication, along with overloaded operators for convenience.

Member Function Documentation

◆ add()

Vector2D & Vector2D::add ( const Vector2D  vec)

Adds another vector to this one.

Parameters
vecThe vector to add.
Returns
A reference to this vector.
Here is the call graph for this function:

◆ divide()

Vector2D & Vector2D::divide ( const Vector2D  vec)

Divides this vector by another, component-wise.

Parameters
vecThe vector to divide by.
Returns
A reference to this vector.
Here is the call graph for this function:

◆ multiply()

Vector2D & Vector2D::multiply ( const Vector2D  vec)

Multiplies this vector by another, component-wise.

Parameters
vecThe vector to multiply by.
Returns
A reference to this vector.
Here is the call graph for this function:

◆ operator*()

Vector2D & Vector2D::operator* ( const int i)

Multiplies the vector by a scalar value.

Parameters
iThe scalar integer to multiply by.
Returns
A reference to this vector.
Here is the call graph for this function:

◆ subtract()

Vector2D & Vector2D::subtract ( const Vector2D  vec)

Subtracts another vector from this one.

Parameters
vecThe vector to subtract.
Returns
A reference to this vector.
Here is the call graph for this function:

◆ zero()

Vector2D & Vector2D::zero ( )

Resets the vector's components to zero.

Returns
A reference to this vector.
Here is the caller graph for this function:

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