Coverage Control Library
Loading...
Searching...
No Matches
Vec2d Class Reference

A class for 2D vector. More...

#include <vec2d.h>

Public Member Functions

 Vec2d ()
 
 Vec2d (double const x_i, double const y_i)
 
double x () const
 
double y () const
 
void SetX (double x)
 
void SetY (double y)
 
Vec2d Perpendicular () const
 Computes perpendicular Vector.
 
void Add (Vec2d const &v)
 Adds two vectors.
 
int Divide (const double scalar)
 Divide vector by a scalar.
 
double Dot (Vec2d const &v) const
 Computes dot product of two Vectors.
 
double NormSqr () const
 Returns square of Euclidean distance from origin.
 
double Norm () const
 Returns Euclidean distance from origin.
 
int CosAngle (Vec2d const &v, double &ang) const
 Gives cosine of the angle between this and Vector v.
 
double DistSqr (Vec2d const &v) const
 Gives the distance between the Vector and another Vector v.
 
double Dist (Vec2d const &v) const
 
void DistTht (Vec2d const &v, double &d, double &tht) const
 Computes distance and angle with another Vector (v-this)
 
Vec2d operator+ (Vec2d const &vec) const
 
Vec2d operator- (Vec2d const &vec) const
 
Vec2d operator- () const
 
Vec2d operator/ (double const &scalar) const
 
Vec2d operator* (double const &scalar) const
 
int Normalize ()
 

Detailed Description

A class for 2D vector.

Definition at line 45 of file vec2d.h.

Constructor & Destructor Documentation

◆ Vec2d() [1/2]

Vec2d ( )
inline

Definition at line 51 of file vec2d.h.

◆ Vec2d() [2/2]

Vec2d ( double const x_i,
double const y_i )
inline

Definition at line 52 of file vec2d.h.

Member Function Documentation

◆ Add()

void Add ( Vec2d const & v)
inline

Adds two vectors.

Definition at line 68 of file vec2d.h.

◆ CosAngle()

int CosAngle ( Vec2d const & v,
double & ang ) const
inline

Gives cosine of the angle between this and Vector v.

Definition at line 93 of file vec2d.h.

◆ Dist()

double Dist ( Vec2d const & v) const
inline

Definition at line 107 of file vec2d.h.

◆ DistSqr()

double DistSqr ( Vec2d const & v) const
inline

Gives the distance between the Vector and another Vector v.

Definition at line 100 of file vec2d.h.

◆ DistTht()

void DistTht ( Vec2d const & v,
double & d,
double & tht ) const
inline

Computes distance and angle with another Vector (v-this)

Definition at line 110 of file vec2d.h.

◆ Divide()

int Divide ( const double scalar)
inline

Divide vector by a scalar.

Definition at line 74 of file vec2d.h.

◆ Dot()

double Dot ( Vec2d const & v) const
inline

Computes dot product of two Vectors.

Definition at line 84 of file vec2d.h.

◆ Norm()

double Norm ( ) const
inline

Returns Euclidean distance from origin.

Definition at line 90 of file vec2d.h.

◆ Normalize()

int Normalize ( )
inline

Definition at line 136 of file vec2d.h.

◆ NormSqr()

double NormSqr ( ) const
inline

Returns square of Euclidean distance from origin.

Definition at line 87 of file vec2d.h.

◆ operator*()

Vec2d operator* ( double const & scalar) const
inline

Definition at line 132 of file vec2d.h.

◆ operator+()

Vec2d operator+ ( Vec2d const & vec) const
inline

Definition at line 118 of file vec2d.h.

◆ operator-() [1/2]

Vec2d operator- ( ) const
inline

Definition at line 126 of file vec2d.h.

◆ operator-() [2/2]

Vec2d operator- ( Vec2d const & vec) const
inline

Definition at line 122 of file vec2d.h.

◆ operator/()

Vec2d operator/ ( double const & scalar) const
inline

Definition at line 128 of file vec2d.h.

◆ Perpendicular()

Vec2d Perpendicular ( ) const
inline

Computes perpendicular Vector.

Definition at line 61 of file vec2d.h.

◆ SetX()

void SetX ( double x)
inline

Definition at line 57 of file vec2d.h.

◆ SetY()

void SetY ( double y)
inline

Definition at line 58 of file vec2d.h.

◆ x()

double x ( ) const
inline

Definition at line 54 of file vec2d.h.

◆ y()

double y ( ) const
inline

Definition at line 55 of file vec2d.h.