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

A class for 2D vector. More...

#include <vec2d.h>

Public Member Functions

 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 46 of file vec2d.h.

Constructor & Destructor Documentation

◆ Vec2d() [1/2]

Vec2d ( )
inline

Definition at line 52 of file vec2d.h.

◆ Vec2d() [2/2]

Vec2d ( double const x_i,
double const y_i )
inline

Definition at line 53 of file vec2d.h.

Member Function Documentation

◆ Add()

void Add ( Vec2d const & v)
inline

Adds two vectors.

Definition at line 69 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 94 of file vec2d.h.

◆ Dist()

double Dist ( Vec2d const & v) const
inline

Definition at line 108 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 101 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 111 of file vec2d.h.

◆ Divide()

int Divide ( const double scalar)
inline

Divide vector by a scalar.

Definition at line 75 of file vec2d.h.

◆ Dot()

double Dot ( Vec2d const & v) const
inline

Computes dot product of two Vectors.

Definition at line 85 of file vec2d.h.

◆ Norm()

double Norm ( ) const
inline

Returns Euclidean distance from origin.

Definition at line 91 of file vec2d.h.

◆ Normalize()

int Normalize ( )
inline

Definition at line 137 of file vec2d.h.

◆ NormSqr()

double NormSqr ( ) const
inline

Returns square of Euclidean distance from origin.

Definition at line 88 of file vec2d.h.

◆ operator*()

Vec2d operator* ( double const & scalar) const
inline

Definition at line 133 of file vec2d.h.

◆ operator+()

Vec2d operator+ ( Vec2d const & vec) const
inline

Definition at line 119 of file vec2d.h.

◆ operator-() [1/2]

Vec2d operator- ( ) const
inline

Definition at line 127 of file vec2d.h.

◆ operator-() [2/2]

Vec2d operator- ( Vec2d const & vec) const
inline

Definition at line 123 of file vec2d.h.

◆ operator/()

Vec2d operator/ ( double const & scalar) const
inline

Definition at line 129 of file vec2d.h.

◆ Perpendicular()

Vec2d Perpendicular ( ) const
inline

Computes perpendicular Vector.

Definition at line 62 of file vec2d.h.

◆ SetX()

void SetX ( double x)
inline

Definition at line 58 of file vec2d.h.

◆ SetY()

void SetY ( double y)
inline

Definition at line 59 of file vec2d.h.

◆ x()

double x ( ) const
inline

Definition at line 55 of file vec2d.h.

◆ y()

double y ( ) const
inline

Definition at line 56 of file vec2d.h.