Apollo  6.0
Open source self driving car software
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
apollo::common::math::Vec2d Class Reference

Implements a class of 2-dimensional vectors. More...

#include <vec2d.h>

Inheritance diagram for apollo::common::math::Vec2d:
Inheritance graph
Collaboration diagram for apollo::common::math::Vec2d:
Collaboration graph

Public Member Functions

constexpr Vec2d (const double x, const double y) noexcept
 Constructor which takes x- and y-coordinates. More...
 
constexpr Vec2d () noexcept
 Constructor returning the zero vector. More...
 
double x () const
 Getter for x component. More...
 
double y () const
 Getter for y component. More...
 
void set_x (const double x)
 Setter for x component. More...
 
void set_y (const double y)
 Setter for y component. More...
 
double Length () const
 Gets the length of the vector. More...
 
double LengthSquare () const
 Gets the squared length of the vector. More...
 
double Angle () const
 Gets the angle between the vector and the positive x semi-axis. More...
 
void Normalize ()
 Returns the unit vector that is co-linear with this vector. More...
 
double DistanceTo (const Vec2d &other) const
 Returns the distance to the given vector. More...
 
double DistanceSquareTo (const Vec2d &other) const
 Returns the squared distance to the given vector. More...
 
double CrossProd (const Vec2d &other) const
 Returns the "cross" product between these two Vec2d (non-standard). More...
 
double InnerProd (const Vec2d &other) const
 Returns the inner product between these two Vec2d. More...
 
Vec2d rotate (const double angle) const
 rotate the vector by angle. More...
 
void SelfRotate (const double angle)
 rotate the vector itself by angle. More...
 
Vec2d operator+ (const Vec2d &other) const
 Sums two Vec2d. More...
 
Vec2d operator- (const Vec2d &other) const
 Subtracts two Vec2d. More...
 
Vec2d operator* (const double ratio) const
 Multiplies Vec2d by a scalar. More...
 
Vec2d operator/ (const double ratio) const
 Divides Vec2d by a scalar. More...
 
Vec2doperator+= (const Vec2d &other)
 Sums another Vec2d to the current one. More...
 
Vec2doperator-= (const Vec2d &other)
 Subtracts another Vec2d to the current one. More...
 
Vec2doperator*= (const double ratio)
 Multiplies this Vec2d by a scalar. More...
 
Vec2doperator/= (const double ratio)
 Divides this Vec2d by a scalar. More...
 
bool operator== (const Vec2d &other) const
 Compares two Vec2d. More...
 
std::string DebugString () const
 Returns a human-readable string representing this object. More...
 

Static Public Member Functions

static Vec2d CreateUnitVec2d (const double angle)
 Creates a unit-vector with a given angle to the positive x semi-axis. More...
 

Protected Attributes

double x_ = 0.0
 
double y_ = 0.0
 

Detailed Description

Implements a class of 2-dimensional vectors.

Constructor & Destructor Documentation

◆ Vec2d() [1/2]

constexpr apollo::common::math::Vec2d::Vec2d ( const double  x,
const double  y 
)
inlinenoexcept

Constructor which takes x- and y-coordinates.

◆ Vec2d() [2/2]

constexpr apollo::common::math::Vec2d::Vec2d ( )
inlinenoexcept

Constructor returning the zero vector.

Member Function Documentation

◆ Angle()

double apollo::common::math::Vec2d::Angle ( ) const

Gets the angle between the vector and the positive x semi-axis.

◆ CreateUnitVec2d()

static Vec2d apollo::common::math::Vec2d::CreateUnitVec2d ( const double  angle)
static

Creates a unit-vector with a given angle to the positive x semi-axis.

◆ CrossProd()

double apollo::common::math::Vec2d::CrossProd ( const Vec2d other) const

Returns the "cross" product between these two Vec2d (non-standard).

◆ DebugString()

std::string apollo::common::math::Vec2d::DebugString ( ) const

Returns a human-readable string representing this object.

◆ DistanceSquareTo()

double apollo::common::math::Vec2d::DistanceSquareTo ( const Vec2d other) const

Returns the squared distance to the given vector.

◆ DistanceTo()

double apollo::common::math::Vec2d::DistanceTo ( const Vec2d other) const

Returns the distance to the given vector.

◆ InnerProd()

double apollo::common::math::Vec2d::InnerProd ( const Vec2d other) const

Returns the inner product between these two Vec2d.

◆ Length()

double apollo::common::math::Vec2d::Length ( ) const

Gets the length of the vector.

◆ LengthSquare()

double apollo::common::math::Vec2d::LengthSquare ( ) const

Gets the squared length of the vector.

◆ Normalize()

void apollo::common::math::Vec2d::Normalize ( )

Returns the unit vector that is co-linear with this vector.

◆ operator*()

Vec2d apollo::common::math::Vec2d::operator* ( const double  ratio) const

Multiplies Vec2d by a scalar.

◆ operator*=()

Vec2d& apollo::common::math::Vec2d::operator*= ( const double  ratio)

Multiplies this Vec2d by a scalar.

◆ operator+()

Vec2d apollo::common::math::Vec2d::operator+ ( const Vec2d other) const

Sums two Vec2d.

◆ operator+=()

Vec2d& apollo::common::math::Vec2d::operator+= ( const Vec2d other)

Sums another Vec2d to the current one.

◆ operator-()

Vec2d apollo::common::math::Vec2d::operator- ( const Vec2d other) const

Subtracts two Vec2d.

◆ operator-=()

Vec2d& apollo::common::math::Vec2d::operator-= ( const Vec2d other)

Subtracts another Vec2d to the current one.

◆ operator/()

Vec2d apollo::common::math::Vec2d::operator/ ( const double  ratio) const

Divides Vec2d by a scalar.

◆ operator/=()

Vec2d& apollo::common::math::Vec2d::operator/= ( const double  ratio)

Divides this Vec2d by a scalar.

◆ operator==()

bool apollo::common::math::Vec2d::operator== ( const Vec2d other) const

Compares two Vec2d.

◆ rotate()

Vec2d apollo::common::math::Vec2d::rotate ( const double  angle) const

rotate the vector by angle.

◆ SelfRotate()

void apollo::common::math::Vec2d::SelfRotate ( const double  angle)

rotate the vector itself by angle.

◆ set_x()

void apollo::common::math::Vec2d::set_x ( const double  x)
inline

Setter for x component.

◆ set_y()

void apollo::common::math::Vec2d::set_y ( const double  y)
inline

Setter for y component.

◆ x()

double apollo::common::math::Vec2d::x ( ) const
inline

Getter for x component.

◆ y()

double apollo::common::math::Vec2d::y ( ) const
inline

Getter for y component.

Member Data Documentation

◆ x_

double apollo::common::math::Vec2d::x_ = 0.0
protected

◆ y_

double apollo::common::math::Vec2d::y_ = 0.0
protected

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