Klamp't  0.9.0
TriangleSampler.h
1 #ifndef TRIANGLE_SAMPLER_H
2 #define TRIANGLE_SAMPLER_H
3
4 #include <KrisLibrary/math3d/Triangle2D.h>
5 #include <KrisLibrary/math3d/Triangle3D.h>
6 #include <vector>
7 #include <KrisLibrary/math/sample.h>
8
9 namespace Klampt {
10  using namespace std;
11  using namespace Math3D;
12
19 {
20  void InitAreas();
21  void Clear() { tris.clear(); areas.clear(); sumAreas.clear(); }
22  inline Real TotalArea() const { return sumAreas.back(); }
23  inline int SampleTri() const { return CumulativeWeightedSample(sumAreas); }
24  void SamplePointOnTri(int tri,Vector2& pt) const;
25  void SamplePoint(Vector2& pt) const;
26  void SamplePoints(int num,std::vector<Vector2>& pts) const;
27  void SamplePoints(int num,std::vector<int>& tris,std::vector<Vector2>& pts) const;
28
29  std::vector<Triangle2D> tris;
30  std::vector<Real> areas;
31  std::vector<Real> sumAreas;
32 };
33
40 {
41  void InitAreas();
42  void Clear() { tris.clear(); areas.clear(); sumAreas.clear(); }
43  inline Real TotalArea() const { return sumAreas.back(); }
44  inline int SampleTri() const { return CumulativeWeightedSample(sumAreas); }
45  void SamplePointOnTri(int tri,Vector3& pt) const;
46  void SamplePoint(Vector3& pt) const;
47  void SamplePoints(int num,std::vector<Vector3>& pts) const;
48  void SamplePoints(int num,std::vector<int>& tris,std::vector<Vector3>& pts) const;
49
50  std::vector<Triangle3D> tris;
51  std::vector<Real> areas;
52  std::vector<Real> sumAreas;
53 };
54
55 } //namespace Klampt
56
57 #endif
58
Samples points in a list of 3d triangles.
Definition: TriangleSampler.h:39
Samples points in a list of 2d triangles.
Definition: TriangleSampler.h:18
Definition: ContactDistance.h:6