CSCI3081W Drone Delivery System
Public Member Functions | Public Attributes | Friends | List of all members
Vector3 Class Reference

a simple class used for vector math, most function are self explanatory More...

#include <vector3.h>

Public Member Functions

 Vector3 ()
 Default constructor.
 
 Vector3 (double a)
 Parameter constructor. More...
 
 Vector3 (double a, double b, double c)
 Parameter constructor. More...
 
 Vector3 (const std::vector< double > &v)
 Parameter constructor. More...
 
 Vector3 (const std::vector< float > &v)
 Parameter constructor. More...
 
bool operator== (const Vector3 &v) const
 Overrides comparison operator. More...
 
double & operator[] (int i)
 Overrides indexing operator. More...
 
double operator[] (int i) const
 Overrides const indexing operator. More...
 
Vector3 operator+ (const Vector3 &v) const
 Overrides + operator. More...
 
Vector3 operator- (const Vector3 &v) const
 Overrides - operator. More...
 
Vector3 operator* (double s) const
 Overrides * operator. More...
 
Vector3 operator/ (double s) const
 Overrides / operator. More...
 
double operator* (const Vector3 &v) const
 Dot product. More...
 
template<class T >
std::vector< T > vec () const
 return std::vector version of this Vector3 template function should be defined in same file with template keyword
 
Vector3 cross (const Vector3 &v) const
 Cross product. More...
 
double magnitude () const
 Returns the magnitude of the Vector3 object.
 
Vector3normalize ()
 Normalizes the Vector3 object.
 
Vector3 unit () const
 Normalizes the vector in the same direction.
 
double dist (const Vector3 &v) const
 Finds the distance between two vectors. More...
 

Public Attributes

double x = 0
 
double y = 0
 
double z = 0
 

Friends

std::ostream & operator<< (std::ostream &strm, const Vector3 &v)
 << operator for Vector3 objects More...
 

Detailed Description

a simple class used for vector math, most function are self explanatory

Constructor & Destructor Documentation

◆ Vector3() [1/4]

Vector3::Vector3 ( double  a)

Parameter constructor.

Parameters
[in]ax, y, and z-coordinate

◆ Vector3() [2/4]

Vector3::Vector3 ( double  a,
double  b,
double  c 
)

Parameter constructor.

Parameters
[in]ax-coordinate
[in]by-coordinate
[in]cz-coordinate

◆ Vector3() [3/4]

Vector3::Vector3 ( const std::vector< double > &  v)

Parameter constructor.

Parameters
[in]vThe vector containing double-value xyz coordinates

◆ Vector3() [4/4]

Vector3::Vector3 ( const std::vector< float > &  v)

Parameter constructor.

Parameters
[in]vThe vector containing float-value xyz coordinates

Member Function Documentation

◆ cross()

Vector3 Vector3::cross ( const Vector3 v) const

Cross product.

Parameters
[in]TheVector3 object you would like to use to cross product with this Vector3
Returns
The Vector3 object comprised of the cross product of the two objects

◆ dist()

double Vector3::dist ( const Vector3 v) const

Finds the distance between two vectors.

Parameters
[in]vThe Vector3 object you would like to find the distance between with this Vector3

◆ operator*() [1/2]

double Vector3::operator* ( const Vector3 v) const

Dot product.

Parameters
[in]TheVector3 object you would like to use to dot product with this Vector3
Returns
The Vector3 object comprised of the dot product of the two objects

◆ operator*() [2/2]

Vector3 Vector3::operator* ( double  s) const

Overrides * operator.

Parameters
[in]vThe Vector3 object you would like to multiply to this Vector3 object
Returns
The Vector3 Object comprised of the multiplication of the two objects

◆ operator+()

Vector3 Vector3::operator+ ( const Vector3 v) const

Overrides + operator.

Parameters
[in]vThe Vector3 object you would like to add to this Vector3 object
Returns
The Vector3 Object comprised of the sum of the two objects

◆ operator-()

Vector3 Vector3::operator- ( const Vector3 v) const

Overrides - operator.

Parameters
[in]vThe Vector3 object you would like to subtract to this Vector3 object
Returns
The Vector3 Object comprised of the subtraction of the two objects

◆ operator/()

Vector3 Vector3::operator/ ( double  s) const

Overrides / operator.

Parameters
[in]vThe Vector3 object you would like to divide to this Vector3 object
Returns
The Vector3 Object comprised of the division of the two objects

◆ operator==()

bool Vector3::operator== ( const Vector3 v) const

Overrides comparison operator.

Parameters
vThe Vector3 object you would like to compare to this Vector3

◆ operator[]() [1/2]

double& Vector3::operator[] ( int  i)

Overrides indexing operator.

Parameters
iThe index you want to return

◆ operator[]() [2/2]

double Vector3::operator[] ( int  i) const

Overrides const indexing operator.

Parameters
iThe index you want to return

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  strm,
const Vector3 v 
)
friend

<< operator for Vector3 objects

Parameters
[in]strmThe given output stream
[in]vThe given Vector3 object to output

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