Mana
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Vector Class Reference

Vector class. More...

#include <vector.h>

Public Member Functions

 Vector ()=default
 
 Vector (float x, float y, float z=0.0f)
 
bool isNull () const
 Returns true if all coordinates are set to 0, otherwise returns false.
 
Vector operator* (float c) const
 Scale vector operator.
 
Vectoroperator*= (float c)
 In-place scale vector operator.
 
Vector operator/ (float c) const
 Scale vector operator.
 
Vectoroperator/= (float c)
 In-place scale vector operator.
 
Vector operator+ (const Vector &v) const
 Add vector operator.
 
Vectoroperator+= (const Vector &v)
 In-place add vector operator.
 
Vector operator- (const Vector &v) const
 Subtract vector operator.
 
Vectoroperator-= (const Vector &v)
 In-place subtract vector operator.
 
float length () const
 Returns the length of this vector.
 
float squaredLength () const
 Returns the squared length of this vector.
 
float manhattanLength () const
 Returns the manhattan length of this vector.
 
Vector normalized () const
 Returns a normalized version of this vector.
 

Public Attributes

float x = 0.0f
 
float y = 0.0f
 
float z = 0.0f
 

Detailed Description

Vector class.

Represents either a 3D point in space, a velocity or a force. Provides several convenient operator overloads.

Definition at line 32 of file vector.h.

Constructor & Destructor Documentation

◆ Vector() [1/2]

Vector::Vector ( )
default

◆ Vector() [2/2]

Vector::Vector ( float  x,
float  y,
float  z = 0.0f 
)
inline

Definition at line 37 of file vector.h.

Member Function Documentation

◆ isNull()

bool Vector::isNull ( ) const
inline

Returns true if all coordinates are set to 0, otherwise returns false.

Definition at line 47 of file vector.h.

◆ length()

float Vector::length ( ) const
inline

Returns the length of this vector.

This method does a relatively slow square root.

Definition at line 140 of file vector.h.

◆ manhattanLength()

float Vector::manhattanLength ( ) const
inline

Returns the manhattan length of this vector.

Definition at line 156 of file vector.h.

◆ normalized()

Vector Vector::normalized ( ) const
inline

Returns a normalized version of this vector.

This is a unit vector running parallel to it.

Definition at line 165 of file vector.h.

◆ operator*()

Vector Vector::operator* ( float  c) const
inline

Scale vector operator.

Definition at line 55 of file vector.h.

◆ operator*=()

Vector & Vector::operator*= ( float  c)
inline

In-place scale vector operator.

Definition at line 65 of file vector.h.

◆ operator+()

Vector Vector::operator+ ( const Vector v) const
inline

Add vector operator.

Definition at line 97 of file vector.h.

◆ operator+=()

Vector & Vector::operator+= ( const Vector v)
inline

In-place add vector operator.

Definition at line 107 of file vector.h.

◆ operator-()

Vector Vector::operator- ( const Vector v) const
inline

Subtract vector operator.

Definition at line 118 of file vector.h.

◆ operator-=()

Vector & Vector::operator-= ( const Vector v)
inline

In-place subtract vector operator.

Definition at line 128 of file vector.h.

◆ operator/()

Vector Vector::operator/ ( float  c) const
inline

Scale vector operator.

Definition at line 76 of file vector.h.

◆ operator/=()

Vector & Vector::operator/= ( float  c)
inline

In-place scale vector operator.

Definition at line 86 of file vector.h.

◆ squaredLength()

float Vector::squaredLength ( ) const
inline

Returns the squared length of this vector.

Avoids the square root.

Definition at line 148 of file vector.h.

Member Data Documentation

◆ x

float Vector::x = 0.0f

Definition at line 171 of file vector.h.

◆ y

float Vector::y = 0.0f

Definition at line 172 of file vector.h.

◆ z

float Vector::z = 0.0f

Definition at line 173 of file vector.h.


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