ICAROUS
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
larcfm::Vect2 Class Reference

#include <Vect2.h>

Inheritance diagram for larcfm::Vect2:
larcfm::Horizontal larcfm::TangentLine

Public Member Functions

 Vect2 (const double xx=0.0, const double yy=0.0)
 
virtual ~Vect2 ()
 
bool isZero () const
 
bool almostEquals (const Vect2 &v) const
 
bool almostEquals (const Vect2 &v, INT64FM maxUlps) const
 
Vect2 operator+ (const Vect2 &v) const
 
Vect2 operator- (const Vect2 &v) const
 
Vect2 operator- () const
 
Vect2 operator* (const double k) const
 
double operator* (const Vect2 &v) const
 
bool operator== (const Vect2 &v) const
 
bool operator!= (const Vect2 &v) const
 
Vect2 Hat () const
 
Vect2 Add (const Vect2 &v) const
 
Vect2 Sub (const Vect2 &v) const
 
Vect2 Neg () const
 
Vect2 Scal (double k) const
 
Vect2 ScalAdd (const double k, const Vect2 &v) const
 
Vect2 AddScal (double k, const Vect2 &v) const
 
Vect2 PerpR () const
 
Vect2 PerpL () const
 
Vect2 linear (const Vect2 &v, double t) const
 
double distance (const Vect2 &s) const
 
double dot (const double x, const double y) const
 
double dot (const Vect2 &v) const
 
double det (const double x, const double y) const
 
double det (const Vect2 &v) const
 
double sqv () const
 
double norm () const
 
double angle () const
 
double trk () const
 
double compassAngle () const
 
double compassAngle (const Vect2 &v2) const
 
bool leq (const Vect2 &v, const Vect2 &vo) const
 
bool isInvalid () const
 
std::string toString () const
 
std::string toString (int precision) const
 
std::string toStringNP (const std::string &xunit, const std::string &yunit) const
 
std::string toStringNP (const std::string &xunit, const std::string &yunit, int precision) const
 
std::string formatXY (const std::string &pre, const std::string &mid, const std::string &post) const
 
std::string formatXY (int prec, const std::string &pre, const std::string &mid, const std::string &post) const
 
std::string toPVS () const
 
std::string toPVS (int precision) const
 
bool within_epsilon (const Vect2 &v2, double epsilon) const
 

Static Public Member Functions

static Vect2 mkTrkGs (double trk, double gs)
 
static double actual_tcpa (const Vect2 &so, const Vect2 &vo, const Vect2 &si, const Vect2 &vi)
 
static double tcpa (const Vect2 &so, const Vect2 &vo, const Vect2 &si, const Vect2 &vi)
 
static double dcpa (const Vect2 &so, const Vect2 &vo, const Vect2 &si, const Vect2 &vi)
 
static double distPerp (const Vect2 &s, const Vect2 &v, const Vect2 &q)
 
static double distAlong (const Vect2 &s, const Vect2 &v, const Vect2 &q)
 
static Vect2 intersect_pt (const Vect2 &s0, const Vect2 &v0, const Vect2 &s1, const Vect2 &v1)
 
static const Vect2ZERO ()
 
static const Vect2INVALID ()
 

Public Attributes

double x
 
double y
 

Private Member Functions

double sqRel (const Vect2 &v) const
 

Detailed Description

2-Dimensional mathematical vectors. Vect2 is immutable. Once these objects are created they can never be changed so multiple references to the same object will never cause problems. However, it does mean that for most vector operations new objects are created. Methods that start with a capital letter create a new object, just as a reminder of this behavior.

Constructor & Destructor Documentation

◆ Vect2()

larcfm::Vect2::Vect2 ( const double  xx = 0.0,
const double  yy = 0.0 
)

Creates a new vector with coordinates (x,y).

Parameters
xxReal value
yyReal value

◆ ~Vect2()

virtual larcfm::Vect2::~Vect2 ( )
inlinevirtual

Destructor

Member Function Documentation

◆ actual_tcpa()

double larcfm::Vect2::actual_tcpa ( const Vect2 so,
const Vect2 vo,
const Vect2 si,
const Vect2 vi 
)
static

Return actual time of closest point approach (return negative infinity if parallel)

◆ Add()

Vect2 larcfm::Vect2::Add ( const Vect2 v) const

Vector addition.

Parameters
vVector
Returns
the vector addition of this vector and v.

◆ AddScal()

Vect2 larcfm::Vect2::AddScal ( double  k,
const Vect2 v 
) const

Addition and scalar multiplication. Compute: this + k*v;

Parameters
kreal value
vvector
Returns
the addition of this vector to v scaled by k.

◆ almostEquals() [1/2]

bool larcfm::Vect2::almostEquals ( const Vect2 v) const

Checks if vectors are almost equal.

Parameters
vVector
Returns
true, if this vector is almost equal to v.

◆ almostEquals() [2/2]

bool larcfm::Vect2::almostEquals ( const Vect2 v,
INT64FM  maxUlps 
) const

Checks if vectors are almost equal.

Parameters
vVector
maxUlpsunit of least precision
Returns
true, if this vector is almost equal to v.

◆ angle()

double larcfm::Vect2::angle ( ) const

Angle.

Returns
the angle of this vector in the range (-pi, pi]. Convention is counter-clockwise with respect to east.

◆ compassAngle() [1/2]

double larcfm::Vect2::compassAngle ( ) const

Compass angle.

Returns
the track angle of this vector in the range [0, 2*pi). Convention is clockwise with respect to north.

◆ compassAngle() [2/2]

double larcfm::Vect2::compassAngle ( const Vect2 v2) const

Compass angle from this position to v2

Parameters
v2vector
Returns
the track angle of v2-this vector in the range [0, 2*Math.PI). Convention is clockwise with respect to north.

◆ dcpa()

double larcfm::Vect2::dcpa ( const Vect2 so,
const Vect2 vo,
const Vect2 si,
const Vect2 vi 
)
static

distance at time of closest point of approach

Parameters
soposition of ownship
vovelocity of ownship
siposition of intruder
vivelocity of intruder
Returns
distance at time of closest point of approach

Return distance at time of closest point of approach

◆ det() [1/2]

double larcfm::Vect2::det ( const double  x,
const double  y 
) const

Determinant.

Parameters
xReal value
yReal value
Returns
the determinant of this vector and (x,y).

◆ det() [2/2]

double larcfm::Vect2::det ( const Vect2 v) const

Determinant.

Parameters
vVector
Returns
the determinant of this vector and v.

◆ distAlong()

double larcfm::Vect2::distAlong ( const Vect2 s,
const Vect2 v,
const Vect2 q 
)
static

returns the longitudinal distance between line defined by s,v and point q.

Parameters
spoint on line
vdirection vector of line
qa point not on the line
Returns
longitudinal distance

returns the perpendicular distance between line defined vy s,v and point q.

Parameters
s
v
q

◆ distPerp()

double larcfm::Vect2::distPerp ( const Vect2 s,
const Vect2 v,
const Vect2 q 
)
static

returns the perpendicular distance between line defined by s,v and point q.

Parameters
spoint on line
vdirection vector of line
qa point not on the line
Returns
perpendicular distance

returns the perpendicular distance between line defined vy s,v and point q.

Parameters
s
v
q

◆ dot() [1/2]

double larcfm::Vect2::dot ( const double  x,
const double  y 
) const

Dot product.

Parameters
xReal value
yReal value
Returns
the dot product of this vector and (x,y).

◆ dot() [2/2]

double larcfm::Vect2::dot ( const Vect2 v) const

Dot product.

Parameters
vVector
Returns
the dot product of this vector and v.

◆ Hat()

Vect2 larcfm::Vect2::Hat ( ) const

Make a unit vector from the current vector. If it is a zero vector, then a copy is returned.

Returns
the unit vector

◆ intersect_pt()

Vect2 larcfm::Vect2::intersect_pt ( const Vect2 s0,
const Vect2 v0,
const Vect2 s1,
const Vect2 v1 
)
static

Computes intersection point of two lines

Parameters
s0starting point of line 1
v0direction vector for line 1
s1starting point of line 2
v1direction vector of line 2
Returns
2-dimensional point of intersection, or an invalid point if they are parallel

◆ INVALID()

const Vect2 & larcfm::Vect2::INVALID ( )
static

Return an "invalid" vector

◆ isInvalid()

bool larcfm::Vect2::isInvalid ( ) const

Returns true if the current vector has an "invalid" value

Returns
true if invalid

◆ isZero()

bool larcfm::Vect2::isZero ( ) const

Checks if vector is zero.

Returns
true, if this vector is zero.

◆ leq()

bool larcfm::Vect2::leq ( const Vect2 v,
const Vect2 vo 
) const

Relative less or equal.

Parameters
vVector
voVector
Returns
true, if the norm of Sub(vo) is less or equal than the norm of v.Sub(vo).

◆ linear()

Vect2 larcfm::Vect2::linear ( const Vect2 v,
double  t 
) const

Calculates position after t time units in direction and magnitude of velocity v

Parameters
vvelocity
ttime
Returns
the new position

◆ mkTrkGs()

Vect2 larcfm::Vect2::mkTrkGs ( double  trk,
double  gs 
)
static

Construct a Vect2 from a track angle and ground speed. This is a vector of length gs pointed in the direction of track angle of trk.

Parameters
trktrack angle
gsground speed
Returns
a vector in with the given length and with the direction of track angle

◆ Neg()

Vect2 larcfm::Vect2::Neg ( ) const

Vector negation.

Returns
the vector negation of of this vector.

◆ norm()

double larcfm::Vect2::norm ( ) const

Norm.

Returns
the norm of of this vector.

◆ operator!=()

bool larcfm::Vect2::operator!= ( const Vect2 v) const

Is any component not exactly equal

◆ operator*() [1/2]

Vect2 larcfm::Vect2::operator* ( const double  k) const

Scalar multiplication.

Parameters
kReal value
Returns
the vector scalar multiplication of this vector and k.

◆ operator*() [2/2]

double larcfm::Vect2::operator* ( const Vect2 v) const

Dot product.

Parameters
vVector
Returns
the dot product of this vector and v.

◆ operator+()

Vect2 larcfm::Vect2::operator+ ( const Vect2 v) const

Vector addition.

Parameters
vVector
Returns
the vector addition of this vector and v.

◆ operator-() [1/2]

Vect2 larcfm::Vect2::operator- ( ) const

Vector negation.

Returns
the vector negation of of this vector.

◆ operator-() [2/2]

Vect2 larcfm::Vect2::operator- ( const Vect2 v) const

Vector subtraction.

Parameters
vVector
Returns
the vector subtraction of this vector and v.

◆ operator==()

bool larcfm::Vect2::operator== ( const Vect2 v) const

Exact equality

◆ PerpL()

Vect2 larcfm::Vect2::PerpL ( ) const

Left perpendicular.

Returns
the left perpendicular of this vector, i.e., (-y, x).

◆ PerpR()

Vect2 larcfm::Vect2::PerpR ( ) const

Right perpendicular.

Returns
the right perpendicular of this vector, i.e., (y, -x).

◆ Scal()

Vect2 larcfm::Vect2::Scal ( double  k) const

Scalar multiplication.

Parameters
kReal value
Returns
the vector scalar multiplication of this vector and k.

◆ ScalAdd()

Vect2 larcfm::Vect2::ScalAdd ( const double  k,
const Vect2 v 
) const

Scalar and addition multiplication. Compute: k*this + v

Parameters
kreal value
vvector
Returns
the scalar multiplication this vector and k, followed by an addition to vector v.

◆ sqv()

double larcfm::Vect2::sqv ( ) const

Square.

Returns
the dot product of this vector with itself.

◆ Sub()

Vect2 larcfm::Vect2::Sub ( const Vect2 v) const

Vector subtraction.

Parameters
vVector
Returns
the vector subtraction of this vector and v.

◆ tcpa()

double larcfm::Vect2::tcpa ( const Vect2 so,
const Vect2 vo,
const Vect2 si,
const Vect2 vi 
)
static

time to closest point of approach if time is negative or velocities are parallel returns 0

Return time to closest point approach if time is negative or velocities are parallel returns 0

◆ toString() [1/2]

std::string larcfm::Vect2::toString ( ) const

A string representation of this vector

◆ toString() [2/2]

std::string larcfm::Vect2::toString ( int  precision) const

A string representation of this vector

Parameters
precisionnumber of digits of precision
Returns
string representation

◆ toStringNP()

std::string larcfm::Vect2::toStringNP ( const std::string &  xunit,
const std::string &  yunit 
) const

A string representation of this vector

◆ trk()

double larcfm::Vect2::trk ( ) const

Track angle.

Returns
the track angle of this vector in the range (-pi, pi]. The track angle is the clockwise angle with respect to north, i.e., v.track() = pi/2 - v.angle().

◆ within_epsilon()

bool larcfm::Vect2::within_epsilon ( const Vect2 v2,
double  epsilon 
) const

Returns true if x components and y components of both vectors are within the given bounds

Parameters
v2vector
epsilonbound
Returns
true if vector is within bounds

◆ ZERO()

const Vect2 & larcfm::Vect2::ZERO ( )
static

Return a zero vector

Member Data Documentation

◆ x

double larcfm::Vect2::x

The x-component

◆ y

double larcfm::Vect2::y

The y-component


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