HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_BoundingCone.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_BoundingCone.h (UT Library, C++)
7  *
8  * COMMENTS: A cone centered at the origin with a given direction and
9  * half-angle.
10  */
11 
12 #ifndef __UT_BoundingCone_h__
13 #define __UT_BoundingCone_h__
14 
15 #include "UT_API.h"
16 #include "UT_Vector3.h"
17 
19 public:
21  {
22  myDir = 0;
23  myAngle = 0;
24  }
25 
26  // Cone angles are measured from the center to the edge of the cone.
27  UT_BoundingCone(const UT_Vector3 &dir, float angle)
28  : myDir(dir)
29  , myAngle(angle)
30  {
31  myDir.normalize();
32  }
33 
34  const UT_Vector3 &getDir() const { return myDir; }
35  float getAngle() const { return myAngle; }
36 
37  // Initialize the direction vector and set the angle to 0
38  void initBounds(const UT_Vector3 &dir);
39 
40  // Enlarge the cone so that it encloses the given direction vector.
41  void enlargeBounds(const UT_Vector3 &dir);
42 
43  // Tests for any intersection between two cones
44  bool intersects(const UT_BoundingCone &cone) const;
45 
46  // Find the intersection of this bounding cone with another cone and
47  // store the result in this. The result will be a conservative bound,
48  // since the exact intersection may not be a cone. If the cones are
49  // disjoint, the angle for this cone will be set to 0 and this method
50  // will return false.
51  bool computeIntersection(const UT_BoundingCone &cone);
52 
53  void dump();
54 
55 private:
56  UT_Vector3 myDir;
57  float myAngle;
58 };
59 
60 #endif
UT_BoundingCone(const UT_Vector3 &dir, float angle)
#define UT_API
Definition: UT_API.h:12
T angle(const Vec2< T > &v1, const Vec2< T > &v2)
Definition: Vec2.h:480
const UT_Vector3 & getDir() const
bool intersects(const Box< Vec3< T > > &b, const Line3< T > &r, Vec3< T > &ip)
Definition: ImathBoxAlgo.h:728
float getAngle() const