SOFUS ..
Namespaces | Classes | Typedefs | Enumerations | Functions
sps Namespace Reference

Single Purpose Solutions. A number of lighweight additions to C and/or C++. More...

Namespaces

namespace  nix
 
namespace  win32
 

Classes

struct  bbox_t
 Bounding box. More...
 
struct  circle_t
 
struct  element_circular_t
 
struct  element_rect_t
 Element representation. More...
 
struct  ellipsis_t
 
struct  euler_t
 Euler angles. More...
 
struct  mat3_t
 
class  msignal1D
 
struct  point_t
 Point type (aligned) More...
 
struct  rect_t
 Rectangle. More...
 

Typedefs

typedef enum sps::RotationConvention RotationConvention
 
template<typename T >
using vector_t = point_t< T >
 Vector aliased as point. More...
 

Enumerations

enum  RotationConvention { EulerIntrinsicZYZ = 0x00 , EulerIntrinsicYXY = 0x01 }
 

Functions

template<typename I , typename J >
std::pair< I, J > minmax_weighted_element (I begin, I end, J it)
 
template<typename T , typename U >
std::pair< T, T > minmax_delay (const T *xs, const U *ws, size_t nData)
 
template<class T >
dist_point_to_point (const point_t< T > &a, const point_t< T > &b)
 
template<typename T >
dot (const point_t< T > &a, const point_t< T > &b)
 
template<typename T >
point_t< T > operator- (const point_t< T > &a, const point_t< T > &b)
 
template<typename T >
point_t< T > operator+ (const point_t< T > &a, const point_t< T > &b)
 
template<typename T >
point_t< T > cross (const point_t< T > &a, const point_t< T > &b)
 
template<typename T >
point_t< T > operator* (const T &a, const point_t< T > &b)
 
template<typename T >
norm (const point_t< T > &a)
 
template<typename T >
dist_point_to_line (const point_t< T > &point, const point_t< T > &pointOnLine, const point_t< T > &direction)
 
template<typename T >
sgn_dist_to_plane (const point_t< T > &point, const point_t< T > &pointOnPlane, const point_t< T > &unitNormal)
 
template<typename T >
dist_point_to_circle (const point_t< T > &point, const circle_t< T > &circle)
 
template<typename T >
void dist_point_to_circle_local (const point_t< T > &point, const circle_t< T > &circle, T *r, T *z, T *distNear)
 
template<typename T >
void dist_point_to_circle_local (const point_t< T > &point, const circle_t< T > &circle, T *r, T *z, T *distNear, T *distFar)
 
template<typename T >
sps::point_t< T > clamp_vector (const sps::point_t< T > &point, const sps::bbox_t< T > &box)
 
template<typename T >
void compute_bounding_box3 (const T *pos, const size_t nPos, sps::bbox_t< T > *box)
 
template<typename T >
bool point_inside_box (const sps::point_t< T > &point, const sps::bbox_t< T > &box)
 
template<typename T >
sps::point_t< T > nearest_point_on_bbox (const sps::point_t< T > &point, const sps::bbox_t< T > &box)
 
template<typename T >
sps::point_t< T > farthest_point_on_bbox (const sps::point_t< T > &point, const sps::bbox_t< T > &box)
 
template<typename T >
void dists_most_distant_and_closest (const sps::bbox_t< T > &box0, const sps::bbox_t< T > &box1, T *distNear, T *distFar)
 
template<typename T , RotationConvention conv>
void basis_vectors (sps::point_t< T > *output, const sps::euler_t< T > &euler, size_t index)
 
template<typename T , RotationConvention conv>
void euler2rot (const sps::euler_t< T > &euler, sps::mat3_t< T > *mat)
 
template<typename T , RotationConvention conv>
void rot2euler (const sps::mat3_t< T > &rot, euler_t< T > *euler)
 
template<typename T , RotationConvention conv>
void basis_rotate (const sps::point_t< T > &input, const euler_t< T > &euler, sps::point_t< T > *output)
 
template<typename T >
void basis_vectors (T *vec0, T *vec1, T *vec2, const sps::euler_t< T > &euler)
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const point_t< T > &point)
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const mat3_t< T > &mat)
 
template<typename T >
void compute_bounding_box_circle (const sps::circle_t< T > &circle, sps::bbox_t< T > *box)
 
template<typename T >
void arc_point_ellipsis (const sps::ellipsis_t< T > &ellipsis, const T &arc, sps::point_t< T > *point)
 
template<typename T >
void tan_point_ellipsis (const sps::ellipsis_t< T > &ellipsis, const T &y, const T &x, sps::point_t< T > *point)
 
template<typename T >
void intcp_line_rect (const sps::element_rect_t< T > &rect, const T &y, const T &x, sps::point_t< T > *point)
 

Detailed Description

Single Purpose Solutions. A number of lighweight additions to C and/or C++.

Todo:
(JMH): Consider creating a template class to allow constructions like,

Typedef Documentation

◆ RotationConvention

◆ vector_t

using vector_t = point_t<T>

Vector aliased as point.

Enumeration Type Documentation

◆ RotationConvention

Enumerator
EulerIntrinsicZYZ 
EulerIntrinsicYXY 

Function Documentation

◆ arc_point_ellipsis()

void arc_point_ellipsis ( const sps::ellipsis_t< T > &  ellipsis,
const T &  arc,
sps::point_t< T > *  point 
)

Intersection point of line originating from center of ellipsis in the plane defined using Euler coordinates and a direction angle arc

TODO(JMH): Support Euler orientation, ellipsis is assumed to lie in xy-plane

Parameters
[in]ellipsis
[in]arcangle
[out]pointintersection point

◆ basis_rotate()

void basis_rotate ( const sps::point_t< T > &  input,
const euler_t< T > &  euler,
sps::point_t< T > *  output 
)

Rotate point using 3 Euler angles according to the convention.

Template Parameters
convRotation convention
Parameters
input
euler
output
Returns

◆ basis_vectors() [1/2]

void basis_vectors ( sps::point_t< T > *  output,
const sps::euler_t< T > &  euler,
size_t  index 
)

Function for returning the basis vector for a given coordinate system defined using 3 Euler angles according to the the z-x-z' or y-x-y' convention.

Template Parameters
convRotation convention
Parameters
output
euler
index

◆ basis_vectors() [2/2]

void basis_vectors ( T *  vec0,
T *  vec1,
T *  vec2,
const sps::euler_t< T > &  euler 
)

Function for returning the basis vector for a given coordinate system defined using 3 Euler angles according to the the z-x-z' convention. Using SIMD for packed singles

Parameters
vec0
vec1
vec2
euler

◆ clamp_vector()

sps::point_t< T > clamp_vector ( const sps::point_t< T > &  point,
const sps::bbox_t< T > &  box 
)
inline

Clamp a vector inside a box

Parameters
point
box
Returns

References bbox_t< T >::max, and bbox_t< T >::min.

Referenced by nearest_point_on_bbox().

Here is the caller graph for this function:

◆ compute_bounding_box3()

void compute_bounding_box3 ( const T *  pos,
const size_t  nPos,
sps::bbox_t< T > *  box 
)

Compute bounding box aligned with the axes for 3D positions

Parameters
pos
nPos
box

References bbox_t< T >::max, and bbox_t< T >::min.

◆ compute_bounding_box_circle()

void compute_bounding_box_circle ( const sps::circle_t< T > &  circle,
sps::bbox_t< T > *  box 
)

References circle_t< T >::center, dot(), circle_t< T >::euler, bbox_t< T >::max, bbox_t< T >::min, and circle_t< T >::radius.

Here is the call graph for this function:

◆ cross()

point_t< T > cross ( const point_t< T > &  a,
const point_t< T > &  b 
)
inline

Cross product of two points or vectors

Parameters
a
b
Returns
a x b

Referenced by dist_point_to_line().

Here is the caller graph for this function:

◆ dist_point_to_circle()

T dist_point_to_circle ( const point_t< T > &  point,
const circle_t< T > &  circle 
)

Distance from point to circle

Parameters
point
circle
Returns

◆ dist_point_to_circle_local() [1/2]

void dist_point_to_circle_local ( const point_t< T > &  point,
const circle_t< T > &  circle,
T *  r,
T *  z,
T *  distNear 
)

◆ dist_point_to_circle_local() [2/2]

void dist_point_to_circle_local ( const point_t< T > &  point,
const circle_t< T > &  circle,
T *  r,
T *  z,
T *  distNear,
T *  distFar 
)

◆ dist_point_to_line()

T dist_point_to_line ( const point_t< T > &  point,
const point_t< T > &  pointOnLine,
const point_t< T > &  direction 
)
inline

Distance from point to line

Parameters
point
pointOnLine
direction
Returns

References cross(), and norm().

Here is the call graph for this function:

◆ dist_point_to_point()

T dist_point_to_point ( const point_t< T > &  a,
const point_t< T > &  b 
)
inline

Distance from point to point

Parameters
aFirst point
bSecond point
Returns
$d = |\mathbf{a}-\mathbf{b}|$

◆ dists_most_distant_and_closest()

void dists_most_distant_and_closest ( const sps::bbox_t< T > &  box0,
const sps::bbox_t< T > &  box1,
T *  distNear,
T *  distFar 
)
inline

Shortest and longest distance between any point on two boxes

Parameters
box0
box1
distNearShortest distance
distFarLongest distance

TODO: Verify if point is inside a box

References bbox_t< T >::max, bbox_t< T >::min, and nearest_point_on_bbox().

Here is the call graph for this function:

◆ dot()

T dot ( const point_t< T > &  a,
const point_t< T > &  b 
)
inline

Dot product of vectors or points

Parameters
a
b
Returns
$d= \mathbf{a}\cdot\mathbf{b}$

Referenced by sofus::calcProjectionAndBoundaries(), compute_bounding_box_circle(), norm(), and sgn_dist_to_plane().

Here is the caller graph for this function:

◆ euler2rot()

void euler2rot ( const sps::euler_t< T > &  euler,
sps::mat3_t< T > *  mat 
)

◆ farthest_point_on_bbox()

sps::point_t< T > farthest_point_on_bbox ( const sps::point_t< T > &  point,
const sps::bbox_t< T > &  box 
)
inline

Farthest point on a box (from a point)

Parameters
point
box
Returns

References bbox_t< T >::max, and bbox_t< T >::min.

◆ intcp_line_rect()

void intcp_line_rect ( const sps::element_rect_t< T > &  rect,
const T &  y,
const T &  x,
sps::point_t< T > *  point 
)
Todo:
(JMH): Make more general line

◆ minmax_delay()

std::pair< T, T > minmax_delay ( const T *  xs,
const U *  ws,
size_t  nData 
)

◆ minmax_weighted_element()

std::pair< I, J > minmax_weighted_element ( begin,
end,
it 
)

◆ nearest_point_on_bbox()

sps::point_t< T > nearest_point_on_bbox ( const sps::point_t< T > &  point,
const sps::bbox_t< T > &  box 
)
inline

Nearest point on a box (from a point)

Parameters
point
box
Returns

References clamp_vector().

Referenced by dists_most_distant_and_closest().

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

◆ norm()

T norm ( const point_t< T > &  a)
inline

Norm of a vector or point

Parameters
a
Returns
$|\mathbf{a}|$

References dot().

Referenced by sofus::calcProjectionAndBoundaries(), and dist_point_to_line().

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

◆ operator*()

point_t< T > operator* ( const T &  a,
const point_t< T > &  b 
)
inline

Scalar multiplication of a vector or point

Parameters
ascalar
bpoint
Returns

◆ operator+()

point_t< T > operator+ ( const point_t< T > &  a,
const point_t< T > &  b 
)
inline

Add two points

Parameters
a
b
Returns
a + b

◆ operator-()

point_t< T > operator- ( const point_t< T > &  a,
const point_t< T > &  b 
)
inline

Subtract two points

Parameters
a
b
Returns
a - b

◆ operator<<() [1/2]

std::ostream & operator<< ( std::ostream &  out,
const mat3_t< T > &  mat 
)
inline

References mat3_t< T >::data.

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  out,
const point_t< T > &  point 
)
inline

Operator for printing points to a stream

Parameters
out
point
Returns

◆ point_inside_box()

bool point_inside_box ( const sps::point_t< T > &  point,
const sps::bbox_t< T > &  box 
)
inline

◆ rot2euler()

void rot2euler ( const sps::mat3_t< T > &  rot,
euler_t< T > *  euler 
)

◆ sgn_dist_to_plane()

T sgn_dist_to_plane ( const point_t< T > &  point,
const point_t< T > &  pointOnPlane,
const point_t< T > &  unitNormal 
)
inline

Signed distance from point to plane.

Parameters
point$\mathbf{p}$
pointOnPlane$\mathbf{q}$
unitNormal$\mathbf{n}$
Returns
$d = (\mathbf{p} - \mathbf{q})\cdot \mathbf{n}$

References dot().

Here is the call graph for this function:

◆ tan_point_ellipsis()

void tan_point_ellipsis ( const sps::ellipsis_t< T > &  ellipsis,
const T &  y,
const T &  x,
sps::point_t< T > *  point 
)