Classes | Functions
geometry.hpp File Reference

Geometrical calculations. More...

#include <vector>
#include <boost/array.hpp>
#include "../misc/serializable.hpp"
Include dependency graph for geometry.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Vector2D
 2D Mathematical vector More...
 

Functions

double abs (Vector2D const &v)
 Norm of a vector. More...
 
double fastabs (Vector2D const &v)
 Norm of a vector, less accurate. More...
 
Vector2D operator+ (Vector2D const &v1, Vector2D const &v2)
 Term by term addition. More...
 
Vector2D operator- (Vector2D const &v1, Vector2D const &v2)
 Term by term subtraction. More...
 
Vector2D operator* (double d, Vector2D const &v)
 Scalar product. More...
 
Vector2D operator* (Vector2D const &v, double d)
 Scalar product. More...
 
Vector2D operator/ (Vector2D const &v, double d)
 Scalar division. More...
 
double ScalarProd (Vector2D const &v1, Vector2D const &v2)
 Scalar product of two vectors. More...
 
double CalcAngle (Vector2D const &v1, Vector2D const &v2)
 Returns the angle between two vectors (in radians) More...
 
double Projection (Vector2D const &v1, Vector2D const &v2)
 Calculates the projection of one vector in the direction of the second. More...
 
Vector2D Rotate (Vector2D const &v, double a)
 Rotates a vector. More...
 
Vector2D Reflect (Vector2D const &v, Vector2D const &axis)
 Reflect vector. More...
 
double distance (Vector2D const &v1, Vector2D const &v2)
 Calculates the distance between two vectors. More...
 
double CrossProduct (Vector2D const &v1, Vector2D const &v2)
 Returns the z component of the cross product of two vectors. More...
 
Vector2D calc_mid_point (Vector2D const &v1, Vector2D const &v2)
 Calculates the mid point between two vectors. More...
 
Vector2D zcross (Vector2D const &v)
 Cross product of a vector in x,y plane with a unit vector in the z direction. More...
 
Vector2D pol2cart (double radius, double angle)
 Converts from polar coordinates to cartesian coordinates. More...
 
Vector2D normalize (const Vector2D &v)
 Normalized a vector. More...
 
double dist_sqr (const Vector2D &v)
 Calculates the square of the distance. This is computationaly cheaper then actually calculating the distance. More...
 

Detailed Description

Geometrical calculations.

Author
Almog Yalinewich

Definition in file geometry.hpp.

Function Documentation

◆ abs()

double abs ( Vector2D const &  v)

Norm of a vector.

Parameters
vTwo dimensional vector
Returns
Norm of v

Definition at line 19 of file geometry.cpp.

Here is the caller graph for this function:

◆ calc_mid_point()

Vector2D calc_mid_point ( Vector2D const &  v1,
Vector2D const &  v2 
)

Calculates the mid point between two vectors.

Parameters
v1First vector
v2Second vector
Returns
Distance between v1 and v2

Definition at line 140 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalcAngle()

double CalcAngle ( Vector2D const &  v1,
Vector2D const &  v2 
)

Returns the angle between two vectors (in radians)

Parameters
v1First vector
v2Second vector
Returns
Angle

Definition at line 119 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CrossProduct()

double CrossProduct ( Vector2D const &  v1,
Vector2D const &  v2 
)

Returns the z component of the cross product of two vectors.

Parameters
v1First vector
v2Second vector
Returns
z component of the cross product between v1 and v2

Definition at line 134 of file geometry.cpp.

Here is the caller graph for this function:

◆ dist_sqr()

double dist_sqr ( const Vector2D v)

Calculates the square of the distance. This is computationaly cheaper then actually calculating the distance.

Parameters
vVector
Returns
Square of the distance

Definition at line 163 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ distance()

double distance ( Vector2D const &  v1,
Vector2D const &  v2 
)

Calculates the distance between two vectors.

Parameters
v1First vector
v2Second vector
Returns
distance between v1 and v2

Definition at line 129 of file geometry.cpp.

Here is the call graph for this function:

◆ fastabs()

double fastabs ( Vector2D const &  v)

Norm of a vector, less accurate.

Parameters
vTwo dimensional vector
Returns
Norm of v

Definition at line 24 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalize()

Vector2D normalize ( const Vector2D v)

Normalized a vector.

Parameters
vOriginal vector
Returns
Vector divided by its norm

Definition at line 158 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator*() [1/2]

Vector2D operator* ( double  d,
Vector2D const &  v 
)

Scalar product.

Parameters
dScalar
vVector
Returns
Two dimensional vector

Definition at line 92 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator*() [2/2]

Vector2D operator* ( Vector2D const &  v,
double  d 
)

Scalar product.

Parameters
vVector
dScalar
Returns
Two dimensional vector

Definition at line 97 of file geometry.cpp.

◆ operator+()

Vector2D operator+ ( Vector2D const &  v1,
Vector2D const &  v2 
)

Term by term addition.

Parameters
v1First vector
v2Second vector
Returns
Sum

Definition at line 81 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator-()

Vector2D operator- ( Vector2D const &  v1,
Vector2D const &  v2 
)

Term by term subtraction.

Parameters
v1First vector
v2Second vector
Returns
Difference

Definition at line 86 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator/()

Vector2D operator/ ( Vector2D const &  v,
double  d 
)

Scalar division.

Parameters
vVector
dScalar
Returns
Two dimensional vector

Definition at line 102 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pol2cart()

Vector2D pol2cart ( double  radius,
double  angle 
)

Converts from polar coordinates to cartesian coordinates.

Parameters
radiusRadius
angleAngle relative to the x axis
Returns
Same vector in cartesian coordiantes

Definition at line 150 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Projection()

double Projection ( Vector2D const &  v1,
Vector2D const &  v2 
)

Calculates the projection of one vector in the direction of the second.

Parameters
v1First vector
v2Direction of the projection
Returns
Component of v1 in the direction of v2

Definition at line 114 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Reflect()

Vector2D Reflect ( Vector2D const &  v,
Vector2D const &  axis 
)

Reflect vector.

Parameters
vVector
axisAxis of reflection
Returns
Reflection of v about axis

Definition at line 124 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rotate()

Vector2D Rotate ( Vector2D const &  v,
double  a 
)

Rotates a vector.

Parameters
vVector
aAngle
Returns
Rotated vector

Definition at line 7 of file geometry.cpp.

◆ ScalarProd()

double ScalarProd ( Vector2D const &  v1,
Vector2D const &  v2 
)

Scalar product of two vectors.

Parameters
v12D vector
v22D vector
Returns
Scalar product of v1 and v2

Definition at line 107 of file geometry.cpp.

Here is the caller graph for this function:

◆ zcross()

Vector2D zcross ( Vector2D const &  v)

Cross product of a vector in x,y plane with a unit vector in the z direction.

Parameters
vVector in the x,y plane
Returns
Two dimensional vector

Definition at line 145 of file geometry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: