Namespaces | Classes | Functions

OpenTissue::geometry Namespace Reference

Namespaces

namespace  detail

Classes

class  AABB
class  BaseShape
class  Capsule
class  Cylinder
class  Ellipsoid
class  HybridVolume
class  LocalTriangleFrame
class  OBB
class  Plane
class  PlaneBox
class  Prism
class  Quadric
class  Ray
class  Sphere
class  Tetrahedron
class  TetrahedronSlicer
class  ZTetrahedronSlicer
class  Torus
class  Triangle
class  VolumeShape

Functions

template<typename vector3_iterator , typename aabb_type >
void aabb_fit (vector3_iterator begin, vector3_iterator end, aabb_type &aabb)
template<typename aabb_type >
aabb_type aabb_union (aabb_type const &A, aabb_type const &B)
template<typename vector_type >
vector_type::value_type angle_from_cot (vector_type const &p, vector_type const &pi, vector_type const &pj)
template<typename V >
void barycentric_geometric (V const &x1, V const &x2, V const &x3, typename V::value_type &w1, typename V::value_type &w2)
template<typename V >
void barycentric_geometric (V const &x1, V const &x2, V const &x3, V const &x4, typename V::value_type &w1, typename V::value_type &w2, typename V::value_type &w3)
template<typename V >
void barycentric_geometric (V const &x1, V const &x2, V const &x3, V const &x4, V const &p, typename V::value_type &w1, typename V::value_type &w2, typename V::value_type &w3, typename V::value_type &w4)
template<typename V >
void barycentric_algebraic (V const &x1, V const &x2, V const &x3, V const &p, typename V::value_type &w1, typename V::value_type &w2, typename V::value_type &w3)
template<typename V >
void barycentric_algebraic (V const &x1, V const &x2, V const &x3, V const &x4, V const &p, typename V::value_type &w1, typename V::value_type &w2, typename V::value_type &w3, typename V::value_type &w4)
template<typename vector3_type , typename sphere_type >
void compute_circumscribed_sphere (vector3_type const &p, sphere_type &sphere)
template<typename vector3_type , typename sphere_type >
void compute_circumscribed_sphere (vector3_type const &p0, vector3_type const &p1, sphere_type &sphere)
template<typename vector3_type , typename sphere_type >
void compute_circumscribed_sphere (vector3_type const &p0, vector3_type const &p1, vector3_type const &p2, sphere_type &sphere)
template<typename vector3_type , typename sphere_type >
void compute_circumscribed_sphere (vector3_type const &p0, vector3_type const &p1, vector3_type const &p2, vector3_type const &p3, sphere_type &sphere)
template<typename vector_type >
vector_type::value_type compute_area_mixed (vector_type const &p, vector_type const &pi, vector_type const &pj)
template<typename real_type , typename vector3_type >
void compute_box_mass_properties (vector3_type const &half_size, real_type const &density, real_type &mass, vector3_type &inertia)
template<typename vector3_type , typename real_type >
void compute_closest_points_line_line (vector3_type const &pA, vector3_type const &uA, vector3_type const &pB, vector3_type const &uB, real_type &s, real_type &t)
void compute_cylinder_mass_properties (real_type const &radius, real_type const &half_height, real_type const &density, real_type &mass, vector3_type &inertia)
template<typename vector3_type >
vector3_type::value_type compute_distance_to_triangle (vector3_type const &p, vector3_type const &pi, vector3_type const &pj, vector3_type const &pk)
template<typename vector3_type >
vector3_type::value_type compute_inscribed_circumscribed_radius_quality_measure (vector3_type const &p0, vector3_type const &p1, vector3_type const &p2, vector3_type const &p3)
template<typename vector3_type >
vector3_type::value_type compute_inscribed_radius_length_quality_measure (vector3_type const &p0, vector3_type const &p1, vector3_type const &p2, vector3_type const &p3)
template<typename vector3_type , typename real_type >
void compute_tetrahedron_inscribed_sphere (vector3_type const &pi, vector3_type const &pj, vector3_type const &pk, vector3_type const &pm, vector3_type &center, real_type &radius)
template<typename vector3_type >
vector3_type::value_type compute_minimum_sine_dihedral_angle_quality_measure (vector3_type const &p0, vector3_type const &p1, vector3_type const &p2, vector3_type const &p3)
template<typename vector3_type , typename matrix3x3_type >
void compute_obb_aabb (vector3_type const &position, matrix3x3_type const &R, vector3_type const &ext, vector3_type &min_coord, vector3_type &max_coord)
template<typename obb_type , typename aabb_type >
void compute_obb_aabb (obb_type const &obb, aabb_type &aabb)
template<typename obb_type >
geometry::AABB< typename
obb_type::math_types
compute_obb_aabb (obb_type const &obb)
template<typename vector_type , typename real_type >
void compute_perpendicular_line_point (vector_type const &p0, vector_type const &p1, vector_type const &x, real_type &t)
template<typename vector3_type , typename real_type >
void compute_plane_aabb (vector3_type const &n, real_type const &w, vector3_type &min_coord, vector3_type &max_coord)
template<typename plane_type , typename aabb_type >
void compute_plane_aabb (plane_type const &plane, aabb_type &aabb)
template<typename plane_type >
geometry::AABB< typename
plane_type::math_types
compute_plane_aabb (plane_type const &plane)
template<typename vector3_type >
vector3_type::value_type compute_signed_distance_to_triangle (vector3_type const &p, vector3_type const &pi, vector3_type const &pj, vector3_type const &pk, vector3_type const &nv_i, vector3_type const &nv_j, vector3_type const &nv_k, vector3_type const &ne_i, vector3_type const &ne_j, vector3_type const &ne_k)
template<typename vector3_iterator , typename sphere_type >
void compute_smallest_sphere (vector3_iterator begin, vector3_iterator end, sphere_type &sphere)
template<typename vector3_type , typename real_type >
void compute_sphere_aabb (vector3_type const &center, real_type const &radius, vector3_type &min_coord, vector3_type &max_coord)
template<typename sphere_type , typename aabb_type >
void compute_sphere_aabb (sphere_type const &sphere, aabb_type &aabb)
template<typename sphere_type >
geometry::AABB< typename
sphere_type::math_types
compute_sphere_aabb (sphere_type const &sphere)
template<typename real_type , typename vector3_type >
void compute_sphere_mass_properties (real_type const &radius, real_type const &density, real_type &mass, vector3_type &inertia)
template<typename vector3_type >
void compute_tetrahedron_aabb (vector3_type const &p0, vector3_type const &p1, vector3_type const &p2, vector3_type const &p3, vector3_type &min_coord, vector3_type &max_coord)
template<typename tetrahedron_type , typename vector3_type >
void compute_tetrahedron_aabb (tetrahedron_type const &tetrahedron, vector3_type &min_coord, vector3_type &max_coord)
template<typename tetrahedron_type , typename aabb_type >
void compute_tetrahedron_aabb (tetrahedron_type const &tetrahedron, aabb_type &aabb)
template<typename tetrahedron_type >
geometry::AABB< typename
tetrahedron_type::math_types
compute_tetrahedron_aabb (tetrahedron_type const &tetrahedron)
template<typename vector_type >
vector_type::value_type compute_triangle_area (vector_type const &p, vector_type const &pi, vector_type const &pj)
template<typename vector3_type >
vector3_type::value_type compute_triangle_extrusion_length (vector3_type const &p1, vector3_type const &p2, vector3_type const &p3, vector3_type const &n1, vector3_type const &n2, vector3_type const &n3, bool inward=false)
template<typename vector3_type >
vector3_type::value_type compute_volume_length_quality_measure (vector3_type const &p0, vector3_type const &p1, vector3_type const &p2, vector3_type const &p3)
template<typename vector_type >
vector_type::value_type cot (vector_type const &p, vector_type const &pi, vector_type const &pj)
template<typename vector3_iterator , typename cylinder_type >
void cylinder_fit (vector3_iterator begin, vector3_iterator end, cylinder_type &cylinder, bool const &use_convex_surface=true)
template<typename real_type , typename vector3_type , typename vector3_iterator >
Quadric< real_typecylindrical_growth (vector3_type const &center, real_type const &radius, vector3_type const &p, vector3_type const &q, vector3_type const &r, real_type const &alpha, vector3_iterator begin, vector3_iterator end, real_type &beta, vector3_type &s)
template<typename lut_container >
void create_lut6 (lut_container &lut)
template<typename lut_container >
void create_lut14 (lut_container &lut)
template<typename lut_container >
void create_lut26 (lut_container &lut)
template<typename lut_iterator , typename vector3_type >
unsigned int direction_bitmask (lut_iterator begin, lut_iterator end, vector3_type const &v)
template<typename vector3_type , typename vector3_iterator , typename ellipsoid_type >
void ellipsoid_growth_fit (vector3_type const &p, vector3_type const &n, vector3_iterator begin, vector3_iterator end, ellipsoid_type &E)
template<typename real_type , typename vector3_type , typename vector3_iterator >
Quadric< real_typeellipsoid_growth (real_type const &radius, vector3_type const &center, vector3_type const &p, vector3_type const &q, vector3_iterator begin, vector3_iterator end, real_type &alpha, vector3_type &r)
template<typename vector3_iterator , typename vector3_container , typename vector3_type >
void graham_scan (vector3_iterator begin, vector3_iterator end, vector3_container &hull, vector3_type const &n)
template<typename vector3_iterator , typename vector3_container >
void graham_scan (vector3_iterator begin, vector3_iterator end, vector3_container &hull)
template<typename vector3_iterator , typename hybrid_type >
void hybrid_fit (vector3_iterator begin, vector3_iterator end, hybrid_type &hybrid, bool const &use_convex_surface=true)
template<typename hybrid_volume_iterator , typename hybrid_type >
void hybrid_volume_fit (hybrid_volume_iterator begin, hybrid_volume_iterator end, hybrid_type &hybrid)
template<typename vector_type >
bool is_angle_obtuse (vector_type const &p, vector_type const &pi, vector_type const &pj)
template<typename vector_type >
bool is_triangle_obtuse (vector_type const &p, vector_type const &pi, vector_type const &pj)
template<typename vector3_iterator , typename obb_type >
void obb_fit (vector3_iterator begin, vector3_iterator end, obb_type &obb, bool const &use_convex_surface=true)
template<typename real_type , typename vector3_type >
unsigned int obb_z_slice (vector3_type const vertices[8], real_type z, vector3_type slice[8])
template<typename T >
Plane< typename
math::BasicMathTypes< T,
size_t > > 
make_plane (math::Vector3< T > const &n, T const &w)
template<typename T >
std::ostream & operator<< (std::ostream &o, Plane< T > const &p)
template<typename T >
std::istream & operator>> (std::istream &i, Plane< T > &p)
template<typename vector3_iterator , typename prism_type >
void prism_fit (vector3_iterator begin, vector3_iterator end, prism_type &prism, bool const &use_convex_surface=true)
template<typename real_type , typename vector3_type >
Quadric< real_typemake_sphere_quadric (real_type const &radius, vector3_type const &center)
template<typename real_type , typename vector3_type >
Quadric< real_typemake_cylinder_quadric (vector3_type const &center, vector3_type const &axis0, real_type const &radius0, vector3_type const &axis1, real_type const &radius1)
template<typename vector3_type >
Quadric< typename
vector3_type::value_type
make_plane_product_quadric (vector3_type const &p, vector3_type const &np, vector3_type const &q, vector3_type const &nq)
template<typename quadric_type >
bool is_valid_ellipsoid (quadric_type const &Q)
template<typename real_type , typename vector3_type , typename vector3_iterator >
Quadric< real_typespherical_growth (vector3_type const &p, vector3_type const &n, vector3_iterator begin, vector3_iterator end, real_type &radius, vector3_type &q)

Function Documentation

template<typename vector3_iterator , typename aabb_type >
void OpenTissue::geometry::aabb_fit ( vector3_iterator  begin,
vector3_iterator  end,
aabb_type &  aabb 
)

AABB Fit. This computes a``tight'' fitting enclosing AABB around a given point cloud.

Example Usage:

std::vector<vector3<real_type> > points(100); ... fill in coordinate values of points ... AABB<...> aabb; aabb_fit(points.begin(),points.end(),aabb)

Note that you could equally well use it as

vector3<real_type> * points = new vector<vector3<real_type>[100]; ... fill in coordinate values of points ... AABB<...> aabb; aabb_fit(points,points+100,aabb)

Parameters:
begin Iterator to first point
end Iterator to one past the last point
aabb Upon return this argument holds the fitted AABB.
template<typename aabb_type >
aabb_type OpenTissue::geometry::aabb_union ( aabb_type const &  A,
aabb_type const &  B 
)

AABB Union. Given two AABBs this method computes a new AABB, which exactly encloses the two given AABB.

Parameters:
A The first AABB.
B The second AABB.
Returns:
The resulting enclosing AABB.
template<typename vector_type >
vector_type::value_type OpenTissue::geometry::angle_from_cot ( vector_type const &  p,
vector_type const &  pi,
vector_type const &  pj 
)

Retrives the ``angle'' from the cotangent of two vectors, (pi-p) and (pj-p). This implementation is based on the paper:

Meyer, M., Desbrun, M., Schröder, P., AND Barr, A. H. Discrete Differential Geometry Operators for Triangulated 2-Manifolds, 2002. VisMath.

Parameters:
p The common tail point of the two vectors
pi The head point of one vector.
pj The head point of the other vector.
Returns:
The angle value of the cotangent of the angle between the two specified vectors.
template<typename V >
void OpenTissue::geometry::barycentric_algebraic ( V const &  x1,
V const &  x2,
V const &  x3,
V const &  x4,
V const &  p,
typename V::value_type &  w1,
typename V::value_type &  w2,
typename V::value_type &  w3,
typename V::value_type &  w4 
) [inline]
template<typename V >
void OpenTissue::geometry::barycentric_algebraic ( V const &  x1,
V const &  x2,
V const &  x3,
V const &  p,
typename V::value_type &  w1,
typename V::value_type &  w2,
typename V::value_type &  w3 
) [inline]
template<typename V >
void OpenTissue::geometry::barycentric_geometric ( V const &  x1,
V const &  x2,
V const &  x3,
typename V::value_type &  w1,
typename V::value_type &  w2 
) [inline]
template<typename V >
void OpenTissue::geometry::barycentric_geometric ( V const &  x1,
V const &  x2,
V const &  x3,
V const &  x4,
typename V::value_type &  w1,
typename V::value_type &  w2,
typename V::value_type &  w3 
) [inline]
template<typename V >
void OpenTissue::geometry::barycentric_geometric ( V const &  x1,
V const &  x2,
V const &  x3,
V const &  x4,
V const &  p,
typename V::value_type &  w1,
typename V::value_type &  w2,
typename V::value_type &  w3,
typename V::value_type &  w4 
) [inline]
template<typename vector_type >
vector_type::value_type OpenTissue::geometry::compute_area_mixed ( vector_type const &  p,
vector_type const &  pi,
vector_type const &  pj 
)

Compute the mixed triangle area. Implicitly assumes that vertex arguments are given in CCW order. This implementation is based on the paper:

Meyer, M., Desbrun, M., Schröder, P., AND Barr, A. H. Discrete Differential Geometry Operators for Triangulated 2-Manifolds, 2002. VisMath.

Parameters:
p First vertex of triangle.
pi Second vertex of triangle.
pj Third vertex of triangle.
Returns:
The mixed area of the triangle.
template<typename real_type , typename vector3_type >
void OpenTissue::geometry::compute_box_mass_properties ( vector3_type const &  half_size,
real_type const &  density,
real_type mass,
vector3_type inertia 
)

Compute Box Mass Properties

Some density values in kg/m^3 Air 20 C, 1 atm, dry 1.21 Aluminum 2700 Balsa wood 120 Brick 2000 Copper 8900 Cork 250 Diamond 3300 Earth Average 5500 Core 9500 Crust 2800 Glass 2500 Gold 19300 Helium (0 C, 1 atm) 0.178 Hydrogen (0C, 1 atm) 0.090 Ice 917 Iron 7900 Lead 11300 Mercury 13600 Nickel 8800 Oil (olive) 920 Oxygen (0 C, 1 atm) 1.43 Platinum 21500 Silver 10500 Styrofoam 100 Tungsten 19300 Uranium 18700 Water 20 C, 1 atm 998 20 C, 50 atm 1000 seawater 20 C, 1 atm 1024

Parameters:
half_size Half side extent of box
density The mass density of the box.
mass Upon return this argument holds the total mass of the box.
intertia Upon return this argument holds the body frame inertia tensor. Note this is a diagnoal 3x3 matrix, so only 3 values are needed.
template<typename vector3_type , typename sphere_type >
void OpenTissue::geometry::compute_circumscribed_sphere ( vector3_type const &  p,
sphere_type &  sphere 
)
Parameters:
p 
Returns:
template<typename vector3_type , typename sphere_type >
void OpenTissue::geometry::compute_circumscribed_sphere ( vector3_type const &  p0,
vector3_type const &  p1,
sphere_type &  sphere 
)
Parameters:
p0 
p1 
Returns:
template<typename vector3_type , typename sphere_type >
void OpenTissue::geometry::compute_circumscribed_sphere ( vector3_type const &  p0,
vector3_type const &  p1,
vector3_type const &  p2,
sphere_type &  sphere 
)
Parameters:
p0 
p1 
p2 
Returns:
template<typename vector3_type , typename sphere_type >
void OpenTissue::geometry::compute_circumscribed_sphere ( vector3_type const &  p0,
vector3_type const &  p1,
vector3_type const &  p2,
vector3_type const &  p3,
sphere_type &  sphere 
)
Parameters:
p0 
p1 
p2 
p3 
Returns:
template<typename vector3_type , typename real_type >
void OpenTissue::geometry::compute_closest_points_line_line ( vector3_type const &  pA,
vector3_type const &  uA,
vector3_type const &  pB,
vector3_type const &  uB,
real_type s,
real_type t 
)

Compute Closest Points between Lines

Parameters:
pA Point on first line.
uA Direction of first line (unit vector).
pB Point on second line.
uB Direction of second line (unit vector).
s The line parameter of the closest point on the first line pA + uA*s
t The line parameter of the closest point on the second line pB + uB*t
void OpenTissue::geometry::compute_cylinder_mass_properties ( real_type const &  radius,
real_type const &  half_height,
real_type const &  density,
real_type mass,
vector3_type inertia 
)

Compute Cylinder Mass Properties.

Some density values in kg/m^3 Air 20 C, 1 atm, dry 1.21 Aluminum 2700 Balsa wood 120 Brick 2000 Copper 8900 Cork 250 Diamond 3300 Earth Average 5500 Core 9500 Crust 2800 Glass 2500 Gold 19300 Helium (0 C, 1 atm) 0.178 Hydrogen (0C, 1 atm) 0.090 Ice 917 Iron 7900 Lead 11300 Mercury 13600 Nickel 8800 Oil (olive) 920 Oxygen (0 C, 1 atm) 1.43 Platinum 21500 Silver 10500 Styrofoam 100 Tungsten 19300 Uranium 18700 Water 20 C, 1 atm 998 20 C, 50 atm 1000 seawater 20 C, 1 atm 1024

Parameters:
radius 
half_height 
density The mass density of the cylinder.
mass Upon return this argument holds the total mass of the cylinder.
intertia Upon return this argument holds the body frame inertia tensor. Note this is a diagnoal 3x3 matrix, so only 3 values are needed.
template<typename vector3_type >
vector3_type::value_type OpenTissue::geometry::compute_distance_to_triangle ( vector3_type const &  p,
vector3_type const &  pi,
vector3_type const &  pj,
vector3_type const &  pk 
)

Compute Distance to Triangle . This method implicitly assumes that the triangle is non-degenerate!

p A point in space

Parameters:
pi First vertex of triangle.
pj Second vertex of triangle.
pk Third vertex of triangle.
Returns:
The closest distance from p to the specified triangle.
template<typename vector3_type >
vector3_type::value_type OpenTissue::geometry::compute_inscribed_circumscribed_radius_quality_measure ( vector3_type const &  p0,
vector3_type const &  p1,
vector3_type const &  p2,
vector3_type const &  p3 
) [inline]

Compute Tetrahedron Quality Measure. The quality of a tetrahedron is 3.0 times the ratio of the radius of the inscribed sphere divided by that of the circumscribed sphere.

An equilateral tetrahredron achieves the maximum possible quality of 1.

Parameters:
p0 The first coordinate of the tetrahedron.
p1 The second coordinate of the tetrahedron.
p2 The third coordinate of the tetrahedron.
p3 The fourth coordinate of the tetrahedron.
Returns:
The computed quality measure.
template<typename vector3_type >
vector3_type::value_type OpenTissue::geometry::compute_inscribed_radius_length_quality_measure ( vector3_type const &  p0,
vector3_type const &  p1,
vector3_type const &  p2,
vector3_type const &  p3 
) [inline]

Compute Tetrahedron Quality Measure. The quality measure of a tetrahedron is:

2 * sqrt ( 6 ) * RIN / LMAX

where

RIN = radius of the inscribed sphere; LMAX = length of longest side of the tetrahedron.

An equilateral tetrahredron achieves the maximum possible quality of 1.

Parameters:
p0 The first coordinate of the tetrahedron.
p1 The second coordinate of the tetrahedron.
p2 The third coordinate of the tetrahedron.
p3 The fourth coordinate of the tetrahedron.
Returns:
The computed quality measure.
template<typename vector3_type >
vector3_type::value_type OpenTissue::geometry::compute_minimum_sine_dihedral_angle_quality_measure ( vector3_type const &  p0,
vector3_type const &  p1,
vector3_type const &  p2,
vector3_type const &  p3 
) [inline]

Compute Tetrahedron Quality Measure. This routine computes minimum sine of the dihedral angles of a tetrahedron.

{9 {2}}{8} V min_{1 i < j 4} {l_{ij}}{A_k A_l}

where l_ij is the length of the edge between vertices i and j. A_k is the signed area of the triangle opposing the k'th vertex. V is the signed volume of the tetrahedron.

As described in the paper:

What Is a Good Linear Finite element? Interpolation, Conditioning, Anisotropy, and Quality Measures (Preprint)

by Jonathan Shewchuk.

Parameters:
p0 The first coordinate of the tetrahedron.
p1 The second coordinate of the tetrahedron.
p2 The third coordinate of the tetrahedron.
p3 The fourth coordinate of the tetrahedron.
Returns:
The computed quality measure.
template<typename vector3_type , typename matrix3x3_type >
void OpenTissue::geometry::compute_obb_aabb ( vector3_type const &  position,
matrix3x3_type const &  R,
vector3_type const &  ext,
vector3_type min_coord,
vector3_type max_coord 
)

Compute AABB of OBB.

Parameters:
position The position of the center of the OBB.
R The orientation of the OBB.
ext The half width extent of the OBB.
min_coord Upon return holds the minimum coordinate corner of the AABB.
max_coord Upon return holds the maximum coordinate corner of the AABB.
template<typename obb_type , typename aabb_type >
void OpenTissue::geometry::compute_obb_aabb ( obb_type const &  obb,
aabb_type &  aabb 
)

Compute OBB AABB.

This function computes a tight fitting axis aligned bounding box around the specified obb.

Parameters:
obb The specified obb.
aabb Upon return holds the computed AABB.
template<typename obb_type >
geometry::AABB<typename obb_type::math_types> OpenTissue::geometry::compute_obb_aabb ( obb_type const &  obb  ) 

Compute OBB AABB.

This function computes a tight fitting axis aligned bounding box around the specified obb.

Parameters:
obb The specified obb.
Returns:
The computed AABB.
template<typename vector_type , typename real_type >
void OpenTissue::geometry::compute_perpendicular_line_point ( vector_type const &  p0,
vector_type const &  p1,
vector_type const &  x,
real_type t 
)

Compute Perpendicular Line Point in nD.

Parameters:
p0 First point on line.
p1 Second point on line.
x Requesting point to find the perpendicular point on the line.
t The line parameter t in the form of p0+t(p1-p0).
template<typename vector3_type , typename real_type >
void OpenTissue::geometry::compute_plane_aabb ( vector3_type const &  n,
real_type const &  w,
vector3_type min_coord,
vector3_type max_coord 
)

Compute AABB of plane.

Parameters:
n The plane normal.
w The ortogonal distance from origo.
min_coord Upon return holds the minimum coordinate corner of the AABB.
max_coord Upon return holds the maximum coordinate corner of the AABB.
template<typename plane_type , typename aabb_type >
void OpenTissue::geometry::compute_plane_aabb ( plane_type const &  plane,
aabb_type &  aabb 
)

Compute Plane AABB.

This function computes a tight fitting axis aligned bounding box around the specified plane.

Parameters:
plane The specified plane.
aabb Upon return holds the computed AABB.
template<typename plane_type >
geometry::AABB<typename plane_type::math_types> OpenTissue::geometry::compute_plane_aabb ( plane_type const &  plane  ) 

Compute Plane AABB.

This function computes a tight fitting axis aligned bounding box around the specified plane.

Parameters:
plane The specified plane.
Returns:
The computed AABB.
template<typename vector3_type >
vector3_type::value_type OpenTissue::geometry::compute_signed_distance_to_triangle ( vector3_type const &  p,
vector3_type const &  pi,
vector3_type const &  pj,
vector3_type const &  pk,
vector3_type const &  nv_i,
vector3_type const &  nv_j,
vector3_type const &  nv_k,
vector3_type const &  ne_i,
vector3_type const &  ne_j,
vector3_type const &  ne_k 
)

Compute Signed Distance to Triangle . This method implicitly assumes that the triangle is non-degenerate!

p A point in space

Parameters:
pi First vertex of triangle.
pj Second vertex of triangle.
pk Third vertex of triangle.
nv_i The pseudonormal of vertex i.
nv_j The pseudonormal of vertex j.
nv_k The pseudonormal of vertex k.
ne_i The pseudonormal of the edge going from vertex j to vertex k.
ne_j The pseudonormal of the edge going from vertex k to vertex i.
ne_k The pseudonormal of the edge going from vertex i to vertex j.
Returns:
The smallest signed distance from p to the specified triangle.
template<typename vector3_iterator , typename sphere_type >
void OpenTissue::geometry::compute_smallest_sphere ( vector3_iterator  begin,
vector3_iterator  end,
sphere_type &  sphere 
)

Convenience function.

Parameters:
begin 
end 
sphere 
template<typename sphere_type , typename aabb_type >
void OpenTissue::geometry::compute_sphere_aabb ( sphere_type const &  sphere,
aabb_type &  aabb 
)

Compute Sphere AABB.

This function computes a tight fitting axis aligned bounding box around the specified sphere.

Parameters:
sphere The specified sphere.
aabb Upon return holds the computed AABB.
template<typename sphere_type >
geometry::AABB<typename sphere_type::math_types> OpenTissue::geometry::compute_sphere_aabb ( sphere_type const &  sphere  ) 

Compute Sphere AABB.

This function computes a tight fitting axis aligned bounding box around the specified sphere.

Parameters:
sphere The specified sphere.
Returns:
The computed AABB.
template<typename vector3_type , typename real_type >
void OpenTissue::geometry::compute_sphere_aabb ( vector3_type const &  center,
real_type const &  radius,
vector3_type min_coord,
vector3_type max_coord 
)

Compute Sphere AABB.

This function computes a tight fitting axis aligned bounding box around the specified sphere.

Parameters:
center The center of the sphere.
radius The radius of the sphere.
min_coord Upon return holds the minimum coordinate corner of the AABB.
max_coord Upon return holds the maximum coordinate corner of the AABB.
template<typename real_type , typename vector3_type >
void OpenTissue::geometry::compute_sphere_mass_properties ( real_type const &  radius,
real_type const &  density,
real_type mass,
vector3_type inertia 
)

Compute Sphere Mass Properties.

Some density values in kg/m^3

Air 20 C, 1 atm, dry 1.21 Aluminum 2700 Balsa wood 120 Brick 2000 Copper 8900 Cork 250 Diamond 3300 Earth Average 5500 Core 9500 Crust 2800 Glass 2500 Gold 19300 Helium (0 C, 1 atm) 0.178 Hydrogen (0C, 1 atm) 0.090 Ice 917 Iron 7900 Lead 11300 Mercury 13600 Nickel 8800 Oil (olive) 920 Oxygen (0 C, 1 atm) 1.43 Platinum 21500 Silver 10500 Styrofoam 100 Tungsten 19300 Uranium 18700 Water 20 C, 1 atm 998 20 C, 50 atm 1000 seawater 20 C, 1 atm 1024

Parameters:
radius The radius of the sphere.
density The mass density of the sphere.
mass Upon return this argument holds the total mass of the sphere.
intertia Upon return this argument holds the body frame inertia tensor. Note this is a diagnoal 3x3 matrix, so only 3 values are needed.
template<typename vector3_type >
void OpenTissue::geometry::compute_tetrahedron_aabb ( vector3_type const &  p0,
vector3_type const &  p1,
vector3_type const &  p2,
vector3_type const &  p3,
vector3_type min_coord,
vector3_type max_coord 
)

Compute AABB of Tetrahedron.

Parameters:
p0 The position of a corner of the tetrahedron.
p1 The position of a corner of the tetrahedron.
p2 The position of a corner of the tetrahedron.
p3 The position of a corner of the tetrahedron.
min_coord Upon return holds the minimum coordinate corner of the AABB.
max_coord Upon return holds the maximum coordinate corner of the AABB.
template<typename tetrahedron_type , typename vector3_type >
void OpenTissue::geometry::compute_tetrahedron_aabb ( tetrahedron_type const &  tetrahedron,
vector3_type min_coord,
vector3_type max_coord 
)

Compute Tetrahedron AABB.

This function computes a tight fitting axis aligned bounding box around the specified tetrahedron.

Parameters:
tetrahedron The specified tetrahedron.
min_coord Upon return holds the minimum coordinate corner of the AABB.
max_coord Upon return holds the maximum coordinate corner of the AABB.
template<typename tetrahedron_type , typename aabb_type >
void OpenTissue::geometry::compute_tetrahedron_aabb ( tetrahedron_type const &  tetrahedron,
aabb_type &  aabb 
)

Compute Tetrahedron AABB.

This function computes a tight fitting axis aligned bounding box around the specified tetrahedron.

Parameters:
tetrahedron The specified tetrahedron.
aabb Upon return holds the computed AABB.
template<typename tetrahedron_type >
geometry::AABB<typename tetrahedron_type::math_types> OpenTissue::geometry::compute_tetrahedron_aabb ( tetrahedron_type const &  tetrahedron  ) 

Compute Tetrahedron AABB.

This function computes a tight fitting axis aligned bounding box around the specified tetrahedron.

Parameters:
tetrahedron The specified tetrahedron.
Returns:
The computed AABB.
template<typename vector3_type , typename real_type >
void OpenTissue::geometry::compute_tetrahedron_inscribed_sphere ( vector3_type const &  pi,
vector3_type const &  pj,
vector3_type const &  pk,
vector3_type const &  pm,
vector3_type center,
real_type radius 
)

Compute inscribed sphere of tetrahedron.

Note this method assumes that the tetrahedron is right-handed (i.e. has positive volume). If one wants to make sure that the method is invoked probably then one can use the following code

Tetrahedron< ... > tetrahedron(p0,p1,p2,p3);

if(tetrahedron.volume()>0) compute_tetrahedron_inscribed_sphere(p0,p1,p2,p3,center,radius); else compute_tetrahedron_inscribed_sphere(p1,p0,p2,p3,center,radius);

Tetrahedra with negative volume can occur durring simulation, if deformations is too large then a tetrahedron may get inverted. Implying negative volume.

Parameters:
pi The first point of the tetrahedron.
pj The second point of the tetrahedron.
pk The third point of the tetrahedron.
pm This fourth point of the tetrahedron. Note this point should lie on the front-side of the triangle given by points pi, pj, and pk.
center Upon return this argument holds the computed center.
radius Upon return this argument holds the computed radius.
template<typename vector_type >
vector_type::value_type OpenTissue::geometry::compute_triangle_area ( vector_type const &  p,
vector_type const &  pi,
vector_type const &  pj 
)

Compute Triangle Area.

Parameters:
p First vertex of triangle.
pi Second vertex of triangle.
pj Third vertex of triangle.
Returns:
template<typename vector3_type >
vector3_type::value_type OpenTissue::geometry::compute_triangle_extrusion_length ( vector3_type const &  p1,
vector3_type const &  p2,
vector3_type const &  p3,
vector3_type const &  n1,
vector3_type const &  n2,
vector3_type const &  n3,
bool  inward = false 
)

Compute Triangle Extrusion Length. Maximum extrusion along normals, which do not result in a ``swallow tail'' case.

To get inward extrusion, flip normal directions!

Parameters:
p1 Coordinate of first vertex.
p2 Coordinate of second vertex.
p3 Coordinate of third vertex.
n1 Outward pointing vertex normal of first vertex.
n2 Outward pointing vertex normal of second vertex.
n3 Outward pointing vertex normal of third vertex.
inward Boolean flag indicating wheter an outward or inward extrusion is computed. I.e. in case of ourward extrusion the i'th extruded vertex coordinate is given by q_i = p_i + epsilon n_i, in case of inward extrusion q_i = p_i - epsilon n_i
Returns:
The extrusion length along the normal directions.
template<typename vector3_type >
vector3_type::value_type OpenTissue::geometry::compute_volume_length_quality_measure ( vector3_type const &  p0,
vector3_type const &  p1,
vector3_type const &  p2,
vector3_type const &  p3 
) [inline]

Compute Tetrahedron Quality Measure. This routine computes the eigenvalue or mean ratio of a tetrahedron.

12 * ( 3 * volume )**(2/3) / (sum of square of edge lengths).

This value may be used as a shape quality measure for the tetrahedron.

For an equilateral tetrahedron, the value of this quality measure will be 1. For any other tetrahedron, the value will be between 0 and 1.

Parameters:
p0 The first coordinate of the tetrahedron.
p1 The second coordinate of the tetrahedron.
p2 The third coordinate of the tetrahedron.
p3 The fourth coordinate of the tetrahedron.
Returns:
The computed quality measure.
template<typename vector_type >
vector_type::value_type OpenTissue::geometry::cot ( vector_type const &  p,
vector_type const &  pi,
vector_type const &  pj 
)

Cotangent of two vectors. This implementation is based on the paper:

Meyer, M., Desbrun, M., Schröder, P., AND Barr, A. H. Discrete Differential Geometry Operators for Triangulated 2-Manifolds, 2002. VisMath.

This metod computes the cotangent angle between two vectors (pi-p) and (pj-p).

Let the angle between the two vectors u and v be . Then by defnition

cot() = {cos }{sin }

and we know that

cos() = { u v }{ {u} {v} }

and

{u v} = {u}{v}sin

since 1 = cos^2 + sin^2 we re-write

{u}{v}sin = {u}{v}( {1 - cos^2 })

Knowing that the angle between two vectors is between 0 and , we can throw away the negative solution of sin. Substituting the expression for cos and isolating we get

sin = { {{u}^2{v}^2 - (u v )^2 } }{{u}{v}}

Finally substituting the expressions for cos and sin into the equation for cot we get

cot() = {u v}{ {{u}^2{v}^2 - (u v )^2 } }

This is the formula we use for computing cot.

Parameters:
p The common tail point of the two vectors
pi The head point of one vector.
pj The head point of the other vector.
Returns:
The computed value.
template<typename lut_container >
void OpenTissue::geometry::create_lut14 ( lut_container &  lut  ) 
template<typename lut_container >
void OpenTissue::geometry::create_lut26 ( lut_container &  lut  ) 
template<typename lut_container >
void OpenTissue::geometry::create_lut6 ( lut_container &  lut  ) 
template<typename vector3_iterator , typename cylinder_type >
void OpenTissue::geometry::cylinder_fit ( vector3_iterator  begin,
vector3_iterator  end,
cylinder_type &  cylinder,
bool const &  use_convex_surface = true 
)

Cylinder Covariance Fit. This method uses covariance analysis to fit an good ``tight'' fitting enclosing cylinder around a given point cloud.

Example Usage:

std::vector<vector3<real_type> > points(100); ... fill in coordinate values of points ... Cylinder< ... > obb; cylinder_fit(points.begin(),points.end(),obb)

Note that you could equally well use it as

vector3<real_type> * points = new vector<vector3<real_type>[100]; ... fill in coordinate values of points ... Cylinder< ... > obb; cylinder_fit(points,points+100,obb)

Parameters:
begin Iterator to first point
end Iterator to one past the last point
cylinder Upon return this argument holds the fitted cylinder.
use_convex_surface If this argument is set to true, the covariace of the surface of the convex hull of the point cloud is used to extact axis information. Default value is true.
template<typename real_type , typename vector3_type , typename vector3_iterator >
Quadric<real_type> OpenTissue::geometry::cylindrical_growth ( vector3_type const &  center,
real_type const &  radius,
vector3_type const &  p,
vector3_type const &  q,
vector3_type const &  r,
real_type const &  alpha,
vector3_iterator  begin,
vector3_iterator  end,
real_type beta,
vector3_type s 
)

Cylindrical Growth. Find largest empty inner ellipsoid by growing it inside a cylindrical tube.

NOTE: Supposed to be used with ellipsoid_growing_fit(...).

Parameters:
center Center of largest inner empty sphere.
radius Radius of largest inner empty sphere.
p A point lying on the surface of the inner empty sphere.
q Another point lying on the surface of the inner empty sphere.
r A third point defining an ellipsoid grown inside the wedge defined by surface points p and q.
alpha The weight of the linear combination of ``wedge'' and inner sphere.
begin An iterator to the first sample point.
end An iterator one past the last sample point.
beta Upon return holds the linear weight of the cylindrical quadric, defining the resulting ellipsoid.
s Upon return holds the final and fourth point defining the last quadric.
template<typename lut_iterator , typename vector3_type >
unsigned int OpenTissue::geometry::direction_bitmask ( lut_iterator  begin,
lut_iterator  end,
vector3_type const &  v 
)

Get Direction Bit Patteren for Vector v.

Parameters:
begin Iterator to first direction vector.
end Iterator to last direction vector.
v The vector to test with
Returns:
A bitmask pattern. If i'th bit is set, then v points in the same direction as the i'th direction vector in the lookup table.
template<typename real_type , typename vector3_type , typename vector3_iterator >
Quadric<real_type> OpenTissue::geometry::ellipsoid_growth ( real_type const &  radius,
vector3_type const &  center,
vector3_type const &  p,
vector3_type const &  q,
vector3_iterator  begin,
vector3_iterator  end,
real_type alpha,
vector3_type r 
)

Ellipsoid Growth.

NOTE: Supposed to be used with ellipsoid_growing_fit(...).

Parameters:
radius Radius of inner largest empty sphere (S).
center Center of sphere S.
p A point on the surface of the sphere S.
q A point on the surface of the sphere S. Not equal to p.
begin Iterator to first point
end Iterator to one position past the last point
r A third point defining the grown ellipsoid.
alpha The alpha value defining the quadric Q = Q1 + alpha Q2.
template<typename vector3_type , typename vector3_iterator , typename ellipsoid_type >
void OpenTissue::geometry::ellipsoid_growth_fit ( vector3_type const &  p,
vector3_type const &  n,
vector3_iterator  begin,
vector3_iterator  end,
ellipsoid_type &  E 
)

Fitting by growing Ellipsoid. Determines ``largest'' possible (inner) empty ellipsoid by a growing strategy.

Parameters:
p The surface point, used to set the starting position of the growing ellipsoid.
n The ``outward'' pointing normal at the surface point p.
begin An iterator to the first sample point.
end An iterator one past the last sample point.
Returns:
The fitted ellipsoid.
template<typename vector3_iterator , typename vector3_container , typename vector3_type >
void OpenTissue::geometry::graham_scan ( vector3_iterator  begin,
vector3_iterator  end,
vector3_container &  hull,
vector3_type const &  n 
)
template<typename vector3_iterator , typename vector3_container >
void OpenTissue::geometry::graham_scan ( vector3_iterator  begin,
vector3_iterator  end,
vector3_container &  hull 
)
template<typename vector3_iterator , typename hybrid_type >
void OpenTissue::geometry::hybrid_fit ( vector3_iterator  begin,
vector3_iterator  end,
hybrid_type &  hybrid,
bool const &  use_convex_surface = true 
)

Hybrid Fit. This computes a``tight'' fitting enclosing Hybrid around a given point cloud.

Example Usage:

std::vector<vector3<real_type> > points(100); ... fill in coordinate values of points ... Hybrid<real_type> hybrid; hybrid_fit(points.begin(),points.end(),hybrid)

Note that you could equally well use it as

vector3<real_type> * points = new vector<vector3<real_type>[100]; ... fill in coordinate values of points ... Hybrid<real_type> hybrid; hybrid_fit(points,points+100,hybrid)

Parameters:
begin Iterator to first point
end Iterator to one past the last point
hybrid Upon return this argument holds the fitted Hybrid.
use_convex_surface If this argument is set to true, the covariace of the surface of the convex hull of the point cloud is used to extact axis information. Default value is true.
template<typename hybrid_volume_iterator , typename hybrid_type >
void OpenTissue::geometry::hybrid_volume_fit ( hybrid_volume_iterator  begin,
hybrid_volume_iterator  end,
hybrid_type &  hybrid 
)

Fit a hybrid to enclose a collection of volumes/hybrids.

The collection could be hybrid instances, or pointers to hybrids or volume adapters etc..

Parameters:
begin An iterator to a hybrid, pointer volume adapter, etc..
end An iterator to a hybrid, pointer volume adapter, etc..
hybrid Upon return contains the resulting hybrid.
template<typename vector_type >
bool OpenTissue::geometry::is_angle_obtuse ( vector_type const &  p,
vector_type const &  pi,
vector_type const &  pj 
)

Obtuse Angle Testing This method tests if the angle between the two vectors (pi-p) and (pj-p) is greather than /2 radians.

Parameters:
p The common tail point of the two vectors
pi The head point of one vector.
pj The head point of the other vector.
Returns:
If angle is obtuse then the return value is true otherwise it is false.
template<typename vector_type >
bool OpenTissue::geometry::is_triangle_obtuse ( vector_type const &  p,
vector_type const &  pi,
vector_type const &  pj 
)

Obtuse Triangle Testing. If any corner of an triangle is obtuse then the triangle is considered to be obtuse.

Parameters:
p First vertex of triangle.
pi Second vertex of triangle.
pj Third vertex of triangle.
Returns:
If triangle is obtuse then the return value is true otherwise it is false.
template<typename quadric_type >
bool OpenTissue::geometry::is_valid_ellipsoid ( quadric_type const &  Q  ) 

Test if Quadris is a valid ellipsoid

Parameters:
Q The quadric.
Returns:
If the specified quadric can be transformed into a valid ellipsoid then the return value is true otherwise it is false.
template<typename real_type , typename vector3_type >
Quadric<real_type> OpenTissue::geometry::make_cylinder_quadric ( vector3_type const &  center,
vector3_type const &  axis0,
real_type const &  radius0,
vector3_type const &  axis1,
real_type const &  radius1 
)
template<typename T >
Plane< typename math::BasicMathTypes< T, size_t> > OpenTissue::geometry::make_plane ( math::Vector3< T > const &  n,
T const &  w 
) [inline]

Factory method making it easier to create planes on the fly.

Parameters:
n The outward normal of the wanted plane.
w The distance from origo along the normal vector.
Returns:
The newly created plane.
template<typename vector3_type >
Quadric<typename vector3_type::value_type> OpenTissue::geometry::make_plane_product_quadric ( vector3_type const &  p,
vector3_type const &  np,
vector3_type const &  q,
vector3_type const &  nq 
)
template<typename real_type , typename vector3_type >
Quadric<real_type> OpenTissue::geometry::make_sphere_quadric ( real_type const &  radius,
vector3_type const &  center 
)
template<typename vector3_iterator , typename obb_type >
void OpenTissue::geometry::obb_fit ( vector3_iterator  begin,
vector3_iterator  end,
obb_type &  obb,
bool const &  use_convex_surface = true 
)

OBB Covariance Fit. This method uses covariance analysis to fit an good ``tight'' fitting enclosing OBB around a given point cloud.

Example Usage:

std::vector<vector3<real_type> > points(100); ... fill in coordinate values of points ... OBB<real_type> obb; obb_fit(points.begin(),points.end(),obb)

Note that you could equally well use it as

vector3<real_type> * points = new vector<vector3<real_type>[100]; ... fill in coordinate values of points ... OBB<real_type> obb; obb_fit(points,points+100,obb)

Parameters:
begin Iterator to first point
end Iterator to one past the last point
obb Upon return this argument holds the fitted OBB.
use_convex_surface If this argument is set to true, the covariace of the surface of the convex hull of the point cloud is used to extact axis information. Default value is true.
template<typename real_type , typename vector3_type >
unsigned int OpenTissue::geometry::obb_z_slice ( vector3_type const   vertices[8],
real_type  z,
vector3_type  slice[8] 
)

OBB Z Slicer. Vertex numbers:

v4 +---------------+ v7 /| /| / | / | / | / | / | / | / | / | / | / | v5 +---------------+ v6 | | | | | | | | | | v0 +--------|------+ v3 | / | / | / | / | / | / | / | / | / | / |/ |/ v1 +---------------+v2

Parameters:
vertices Vertices of an OBB box.
z The z-value of the z-plane.
slice Upon return this array holds the vertices of the intersecting polygonal slice.
Returns:
The number of vertices in the polygonal intersection.
template<typename T >
std::ostream& OpenTissue::geometry::operator<< ( std::ostream &  o,
Plane< T > const &  p 
)
template<typename T >
std::istream& OpenTissue::geometry::operator>> ( std::istream &  i,
Plane< T > &  p 
)
template<typename vector3_iterator , typename prism_type >
void OpenTissue::geometry::prism_fit ( vector3_iterator  begin,
vector3_iterator  end,
prism_type &  prism,
bool const &  use_convex_surface = true 
)

Prism Fit. This computes a``tight'' fitting enclosing Prism around a given point cloud.

Example Usage:

std::vector<vector3<real_type> > points(100); ... fill in coordinate values of points ... Prism< ... > prism; prism_fit(points.begin(),points.end(),prism)

Note that you could equally well use it as

vector3<real_type> * points = new vector<vector3<real_type>[100]; ... fill in coordinate values of points ... Prism< ... > aabb; prism_fit(points,points+100,prism)

Parameters:
begin Iterator to first point
end Iterator to one past the last point
prism Upon return this argument holds the fitted prism.
template<typename real_type , typename vector3_type , typename vector3_iterator >
Quadric<real_type> OpenTissue::geometry::spherical_growth ( vector3_type const &  p,
vector3_type const &  n,
vector3_iterator  begin,
vector3_iterator  end,
real_type radius,
vector3_type q 
)

Spherical Growth. Grows a sphere at point p in the direction of -n, such that the sphere will be the largest empty sphere.

NOTE: Supposed to be used with ellipsoid_growing_fit(...).

Parameters:
p A surface point on the sphere
n Outward surface normal at the point p.
begin Iterator to first point
end Iterator to one position past the last point
q Upon return holds the surface point on the sphere, that caused the largest radius.
radius Upon return this argument holds the value of the radius of the inner largest empty sphere, with p on its surface and normal n. Sphere center is given by: c = p - radius*n.
Returns:
A quadric representing the grown sphere.