AngelCAD  1.5-00
Public Member Functions | List of all members
vec2d Class Reference

2d direction vector More...

#include <angelcad.h>

Public Member Functions

 vec2d (const pos2d@ p1, const pos2d@ p2)
 Create direction vector from p1 to p2. More...
 
 vec2d (const vec2d@ other)
 Construct direction vector from other vector. More...
 
 vec2d (double x, double y)
 Construct direction vector from x and y components. More...
 
double angle (const vec2d@ other) const
 angle between: double rad = v.angle(other); More...
 
double cross (const vec2d@ other) const
 cross product: double cp = v.cross(other); More...
 
double dot (const vec2d@ other) const
 dot product: double cp = v.dot(other); More...
 
double length () const
 length of vector More...
 
double x () const
 vector x component More...
 
double y () const
 vector y component More...
 
vec2dopAdd (vec2d@ v1)
 Add vector to vector, return new vector: vec2d@ v = v0 + v1. More...
 
vec2dopMul (double f1)
 Multiply vector with factor, return new vector: vec2d@ v = v0 * f1. More...
 
vec2dopMul_r (double f1)
 Multiply vector with factor, return new vector: vec2d@ v = f1 * v0. More...
 
vec2dopSub (vec2d@ v1)
 Subtract vector from vector, return new vector: vec2d@ v = v0 - v1. More...
 
void normalise ()
 normalise vector length More...
 

Detailed Description

2d direction vector

vec2d is a 2-dimensional vector offering useful operations such as dot and cross products.

Constructor & Destructor Documentation

◆ vec2d() [1/3]

vec2d::vec2d ( const pos2d p1,
const pos2d p2 
)

Create direction vector from p1 to p2.

Parameters
p1pos2d@, vector start position
p2pos2d@, vector end position

◆ vec2d() [2/3]

vec2d::vec2d ( const vec2d other)

Construct direction vector from other vector.

Parameters
othervec2d@

◆ vec2d() [3/3]

vec2d::vec2d ( double  x,
double  y 
)

Construct direction vector from x and y components.

Parameters
xdouble, vector x component
ydouble, vector y component

Member Function Documentation

◆ angle()

double vec2d::angle ( const vec2d other) const

angle between: double rad = v.angle(other);

Parameters
othervec2d@, vector to compute angle relative to this
Returns
double, angle value in radians

◆ cross()

double vec2d::cross ( const vec2d other) const

cross product: double cp = v.cross(other);

Parameters
othervec2d@, vector to multiply with
Returns
double, cross product value

◆ dot()

double vec2d::dot ( const vec2d other) const

dot product: double cp = v.dot(other);

Parameters
othervec2d@, vector to multiply with
Returns
double, dot product value

◆ length()

double vec2d::length ( ) const

length of vector

Returns
double, length of vector

◆ normalise()

void vec2d::normalise ( )

normalise vector length

◆ opAdd()

vec2d@ vec2d::opAdd ( vec2d v1)

Add vector to vector, return new vector: vec2d@ v = v0 + v1.

Parameters
v1vec2d@
Returns
vec2d@

◆ opMul()

vec2d@ vec2d::opMul ( double  f1)

Multiply vector with factor, return new vector: vec2d@ v = v0 * f1.

Parameters
f1double
Returns
vec2d@

◆ opMul_r()

vec2d@ vec2d::opMul_r ( double  f1)

Multiply vector with factor, return new vector: vec2d@ v = f1 * v0.

Parameters
f1double
Returns
vec2d@

◆ opSub()

vec2d@ vec2d::opSub ( vec2d v1)

Subtract vector from vector, return new vector: vec2d@ v = v0 - v1.

Parameters
v1vec2d@
Returns
vec2d@

◆ x()

double vec2d::x ( ) const

vector x component

Returns
double, vector x component

◆ y()

double vec2d::y ( ) const

vector y component

Returns
double, vector y component

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