rtcGeometry3D.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008
00003  * Robert Bosch LLC
00004  * Research and Technology Center North America
00005  * Palo Alto, California
00006  *
00007  * All rights reserved.
00008  *
00009  *------------------------------------------------------------------------------
00010  * project ....: PUMA: Probablistic Unsupervised Model Acquisition
00011  * file .......: Geometry.h
00012  * authors ....: Benjamin Pitzer
00013  * organization: Robert Bosch LLC
00014  * creation ...: 03/28/2008
00015  * modified ...: $Date: 2008-08-14 19:00:23 -0700 (Thu, 14 Aug 2008) $
00016  * changed by .: $Author: wg75pal $
00017  * revision ...: $Revision: 344 $
00018  */
00019 #ifndef GEOMETRY3D_H
00020 #define GEOMETRY3D_H
00021 
00022 //== INCLUDES ==================================================================
00023 #include <rtc/rtcVec3.h>
00024 
00025 namespace rtc {
00026 
00027 // two vectors, a and b, starting from c
00028 float dot(const Vec3f &a, const Vec3f &b);
00029 // two vectors, a and b
00030 Vec3f cross(const Vec3f &a, const Vec3f &b);
00031 // two vectors, a and b, starting from c
00032 Vec3f cross(const Vec3f &a, const Vec3f &b, const Vec3f &c);
00033 float dist2(const Vec3f &a, const Vec3f &b);
00034 float dist(const Vec3f &a, const Vec3f &b);
00035 // linear interpolation
00036 Vec3f lerp(float t, const Vec3f &a, const Vec3f &b);
00037 // is the point centered at c within the box centered at bc, with radius br?
00038 bool point_within_bounds(const Vec3f &c, const Vec3f &bc, float br);
00039 // is the ball centered at b with radius r
00040 // fully within the box centered at bc, with radius br?
00041 bool ball_within_bounds(const Vec3f &b, float r,
00042                         const Vec3f &bc, float br);
00043 // is the ball centered at b with radius r
00044 // fully within the box centered from min to max?
00045 bool ball_within_bounds(const Vec3f &b, float r,
00046                         const Vec3f &min,
00047                         const Vec3f &max);
00048 // does the ball centered at b, with radius r,
00049 // intersect the box centered at bc, with radius br?
00050 bool bounds_overlap_ball(const Vec3f &b, float r,
00051                          const Vec3f &bc, float br);
00052 bool bounds_overlap_ball(const Vec3f &b, float r,
00053                          const Vec3f &min, const Vec3f &max);
00054 // calculate barycentric coordinates of the point p
00055 // (already on the triangle plane) with normal vector n
00056 // and two edge vectors v1 and v2,
00057 // starting from a common vertex t0
00058 void bary_fast(const Vec3f& p, const Vec3f& n,
00059                const Vec3f &t0, const Vec3f& v1,
00060                const Vec3f& v2, float &b1, float &b2, float &b3);
00061 bool closer_on_lineseg(const Vec3f &x, Vec3f &cp, const Vec3f &a,
00062                        const Vec3f &b, float &d2);
00063 void distance_point_line(const Vec3f &x, const Vec3f &a,
00064                          const Vec3f &b, float &d2, Vec3f &cp);
00065 void distance_point_tri(const Vec3f &x, const Vec3f &t1,
00066                         const Vec3f &t2, const Vec3f &t3,
00067                         float &d2, Vec3f &cp);
00068 bool closer_on_tri(const Vec3f &x, Vec3f &cp,
00069                    const Vec3f &t1, const Vec3f &t2,
00070                    const Vec3f &t3, float &d2);
00071 // calculate the intersection of a line going through p
00072 // to direction dir with a plane spanned by t1,t2,t3
00073 // (modified from Graphics Gems, p.299)
00074 bool line_plane_X(const Vec3f& p, const Vec3f& dir,
00075                   const Vec3f& t1, const Vec3f& t2,
00076                   const Vec3f& t3,
00077                   Vec3f &x, float &dist);
00078 bool line_plane_X(const Vec3f& p, const Vec3f& dir,
00079                   const Vec3f& nrm, float d, Vec3f &x, float &dist);
00080 // calculate barycentric coordinates of the point p
00081 // on triangle t1 t2 t3
00082 void bary(const Vec3f& p,
00083           const Vec3f& t1, const Vec3f& t2, const Vec3f& t3,
00084           float &b1, float &b2, float &b3);
00085 // calculate barycentric coordinates for the intersection of
00086 // a line starting from p, going to direction dir, and the plane
00087 // of the triangle t1 t2 t3
00088 bool bary(const Vec3f& p, const Vec3f& dir,
00089           const Vec3f& t1, const Vec3f& t2, const Vec3f& t3,
00090           float &b1, float &b2, float &b3);
00091 // calculate the intersection of a line starting from p,
00092 // going to direction dir, and the triangle t1 t2 t3
00093 bool line_tri_X(const Vec3f& p, const Vec3f& dir,
00094                 const Vec3f& t1, const Vec3f& t2, const Vec3f& t3,
00095                 Vec3f& x, float& d);
00096 
00097 bool closer_on_line(const Vec3f &x, const Vec3f &a, const Vec3f &b, float &d2, Vec3f &cp);
00098 void dist_to_line(const Vec3f &x, const Vec3f &a, const Vec3f &b, float &d, Vec3f &cp);
00099 float dist_to_line(const Vec3f &x, const Vec3f &a, const Vec3f &b);
00100 
00101 // calculates the area of an triangle (t1 t2 t3)
00102 template <class T> inline T rtc_triangle_area(const Vec3<T>& t1, const Vec3<T>& t2, const Vec3<T>& t3)
00103 {
00104   const Vec3<T> v1 = t2-t1;
00105   const Vec3<T> v2 = t3-t1;
00106   const Vec3<T> t = v1.cross(v2);
00107   return T(0.5)*t.norm();
00108 }
00109 
00110 //=============================================================================
00111 } // namespace rtc
00112 //=============================================================================
00113 #endif


rtc
Author(s): Benjamin Pitzer
autogenerated on Thu Jan 2 2014 11:04:53