Atoms Crowd  4.1.0
LocomotionHelper.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <Atoms/Globals.h>
11 #include <AtomsUtils/AtomsMath.h>
12 #include <AtomsUtils/Triangle.h>
13 #include <AtomsUtils/Edge.h>
14 #include <algorithm>
15 #include <vector>
16 #include <map>
17 
18 
19 namespace Atoms
20 {
21  enum LocomotionSort
22  {
23  kGreater = 0,
24  kLess
25  };
26 
27  class ATOMS_EXPORT LocomotionBoundaries
28  {
29  public:
30  AtomsMath::Vector2f min;
31  AtomsMath::Vector2f max;
32  AtomsMath::Vector2f gridSize;
33  };
34 
35  class ATOMS_EXPORT LocomotionDelaunay {
36 
37  public:
38  std::vector<AtomsUtils::Triangle2> triangles;
39 
40  LocomotionBoundaries boundaries;
41 
42  LocomotionDelaunay() { triangles.clear(); }
43  };
44 
46 
51  ATOMS_EXPORT std::vector<AtomsUtils::Triangle2> locomotionTriangulation(const std::vector<AtomsMath::Vector2f> & points, const LocomotionSort xSort = LocomotionSort::kGreater, const LocomotionSort ySort = LocomotionSort::kLess, const float eps = 1e-4);
52 
53  ATOMS_EXPORT bool findTriangleFromPointForLocomotion(const AtomsMath::Vector2f& point, const std::vector<AtomsUtils::Triangle2>& triangles, AtomsMath::Vector3f& barycentricCoords, AtomsUtils::Triangle2& outTriangle);
54 
55 }
AtomsUtils::Triangle2
Triangle 2D class.
Definition: Triangle.h:87
Atoms::locomotionTriangulation
ATOMS_EXPORT std::vector< AtomsUtils::Triangle2 > locomotionTriangulation(const std::vector< AtomsMath::Vector2f > &points, const LocomotionSort xSort=LocomotionSort::kGreater, const LocomotionSort ySort=LocomotionSort::kLess, const float eps=1e-4)
Implements Bowyer-Watson algorithm to generate a Delaunay triangulation for the given positions.
Atoms
Atoms namespace.
Definition: Agent.h:28
Atoms::LocomotionBoundaries
Definition: LocomotionHelper.h:28
Atoms::LocomotionDelaunay
Definition: LocomotionHelper.h:35