KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
kjb::geometry Namespace Reference

Functions

Matrix get_translation_matrix (const Vector &v)
 Creates a translation matrix from the given vector. More...
 
Matrix get_rotation_matrix (double theta)
 Creates a (2D) rotation matrix from the given angle. More...
 
Matrix get_rotation_matrix (const Vector &u, const Vector &v)
 Creates a ND rotation matrix that rotates the first argument to the second one. More...
 
Vector projective_to_euclidean (const Vector &v)
 Converts coordinates in projective space to coordinates in euclidean space. More...
 
Vector projective_to_euclidean_2d (const Vector &v)
 Converts coordinates in (2D) projective space to coordinates in (2D) euclidean space. More...
 
Vector euclidean_to_projective (const Vector &v)
 Converts coordinates in euclidean space to coordinates in projective space. More...
 
Vector euclidean_to_projective_2d (const Vector &v)
 Converts coordinates in (2D) euclidean space to coordinates in (2D) projective space. More...
 
bool is_point_in_polygon_new (Matrix poly, Vector point)
 
Matrix polygon_to_mask (Matrix poly, int height, int width)
 
template<size_t D>
Matrix_d< D, Dget_rotation_matrix (const Vector_d< D > &u, const Vector_d< D > &v)
 Creates a ND rotation matrix that rotates the first argument to the second one. More...
 

Function Documentation

Vector kjb::geometry::euclidean_to_projective ( const Vector &  v)

Converts coordinates in euclidean space to coordinates in projective space.

Converts coordinates in euclidean space to coordinates in projective space. i.e., converts from non-homogeneous to homogeneous coordinates. If the given vector is already homogeneous, this function simply returns it.

This is a simple function, but is useful when passing to stl transform() to convert a vector of non-homogeneous coordinates to homogeneous with a single line of code.

Author
Kyle Simek, Ernesto Brau
Vector kjb::geometry::euclidean_to_projective_2d ( const Vector &  v)

Converts coordinates in (2D) euclidean space to coordinates in (2D) projective space.

Converts coordinates in euclidean space to coordinates in projective space. i.e., converts from non-homogeneous to homogeneous coordinates. If the given vector is already homogeneous, this function simply returns it.

This is a simple function, but is useful when passing to stl transform() to convert a vector of non-homogeneous coordinates to homogeneous with a single line of code.

Author
Ernesto Brau, Kyle Simek
Matrix kjb::geometry::get_rotation_matrix ( double  theta)

Creates a (2D) rotation matrix from the given angle.

Parameters
thetaThe angle.
Note
If you want 3D rotations, use kjb::Quaternion.
Matrix kjb::geometry::get_rotation_matrix ( const Vector &  u,
const Vector &  v 
)

Creates a ND rotation matrix that rotates the first argument to the second one.

Parameters
uStarting vector
vEnding vector
Note
If you want 3D rotations, use kjb::Quaternion.
template<size_t D>
Matrix_d<D, D> kjb::geometry::get_rotation_matrix ( const Vector_d< D > &  u,
const Vector_d< D > &  v 
)
inline

Creates a ND rotation matrix that rotates the first argument to the second one.

Parameters
uStarting vector
vEnding vector
Note
If you want 3D rotations, use kjb::Quaternion.
Matrix kjb::geometry::get_translation_matrix ( const Vector &  v)

Creates a translation matrix from the given vector.

Parameters
vThe translation vector, which must be in euclidean (non-homogeneous) coordinates!
bool kjb::geometry::is_point_in_polygon_new ( Matrix  poly,
Vector  point 
)

is_point_in_polygon_new() (updated cpp version)

Takes a polygon and a point. Determines wheter or not the point is in the boundaries of the polygon.

NOTE: Points of the Polygon must be in cyclical order, otherwise you might get the wrong answer

NOTE: if the point is on the border, returns true;

Fun Fact: Works with non convex polygons! (except sometimes when the point has exactly the y value of one of the polygon's verticies - working on that)

Parameters
poly- a Nx2 Matrix of the points of a Polygon, in a cyclic order. point - Vector(x,y)
Returns
false if point is outside polygon true if point is inside polygon
Matrix kjb::geometry::polygon_to_mask ( Matrix  poly,
int  height,
int  width 
)
Vector kjb::geometry::projective_to_euclidean ( const Vector &  v)

Converts coordinates in projective space to coordinates in euclidean space.

Converts coordinates in projective space to coordinates in euclidean space. i.e., converts from homogeneous to non-homogeneous coordinates. If the given vector is already euclidean, this function simply returns it.

This is a simple function, but is useful when passing to stl transform() to convert a vector of homogeneous coordinates to non-homogeneous with a single line of code.

Author
Kyle Simek, Ernesto Brau
Vector kjb::geometry::projective_to_euclidean_2d ( const Vector &  v)

Converts coordinates in (2D) projective space to coordinates in (2D) euclidean space.

Converts coordinates in projective space to coordinates in euclidean space. i.e., converts from homogeneous to non-homogeneous coordinates. If the given vector is already euclidean, this function simply returns it.

This is a simple function, but is useful when passing to stl transform() to convert a vector of homogeneous coordinates to non-homogeneous with a single line of code.

Author
Kyle Simek, Ernesto Brau