31 #ifndef __HDK_UT_SolidAngle_h__
32 #define __HDK_UT_SolidAngle_h__
40 namespace HDK_Sample {
67 if (alength == 0 || blength == 0 || clength == 0)
79 const T numerator =
dot(qa,
cross(qb-qa, qc-qa));
86 const T denominator =
T(1) +
dot(qa,qb) +
dot(qa,qc) +
dot(qb,qc);
88 return T(2)*SYSatan2(numerator, denominator);
119 if (lengths[0] ==
T(0) || lengths[1] ==
T(0) || lengths[2] ==
T(0) || lengths[3] ==
T(0))
140 bary[0] =
dot(v[3],
cross(v23,diag13));
141 bary[1] = -
dot(v[2],
cross(v23,diag02));
142 bary[2] = -
dot(v[1],
cross(v01,diag13));
143 bary[3] =
dot(v[0],
cross(v01,diag02));
145 const T dot01 =
dot(v[0],v[1]);
146 const T dot12 =
dot(v[1],v[2]);
147 const T dot23 =
dot(v[2],v[3]);
148 const T dot30 =
dot(v[3],v[0]);
154 if (bary[0]*bary[2] < bary[1]*bary[3])
157 const T numerator012 = bary[3];
158 const T numerator023 = bary[1];
159 const T dot02 =
dot(v[0],v[2]);
163 if (numerator012 !=
T(0))
165 const T denominator012 =
T(1) + dot01 + dot12 + dot02;
166 omega = SYSatan2(numerator012, denominator012);
168 if (numerator023 !=
T(0))
170 const T denominator023 =
T(1) + dot02 + dot23 + dot30;
171 omega += SYSatan2(numerator023, denominator023);
177 const T numerator013 = -bary[2];
178 const T numerator123 = -bary[0];
179 const T dot13 =
dot(v[1],v[3]);
183 if (numerator013 !=
T(0))
185 const T denominator013 =
T(1) + dot01 + dot13 + dot30;
186 omega = SYSatan2(numerator013, denominator013);
188 if (numerator123 !=
T(0))
190 const T denominator123 =
T(1) + dot12 + dot23 + dot13;
191 omega += SYSatan2(numerator123, denominator123);
202 template<
typename T,
typename S>
215 const int ntriangles,
216 const int *
const triangle_points,
221 {
init(ntriangles, triangle_points, npoints, positions,
order); }
227 const int ntriangles,
228 const int *
const triangle_points,
231 const int order = 2);
238 {
return myNTriangles == 0; }
247 static constexpr
uint BVH_N = 4;
253 const int *myTrianglePoints;
274 const T numerator =
cross(qa, qb);
282 const T denominator =
dot(qa,qb);
285 return SYSatan2(numerator, denominator);
293 template<
typename T,
typename S>
307 const int *
const segment_points,
312 {
init(nsegments, segment_points, npoints, positions,
order); }
319 const int *
const segment_points,
322 const int order = 2);
329 {
return myNSegments == 0; }
338 static constexpr
uint BVH_N = 4;
344 const int *mySegmentPoints;
UT_SolidAngle()
This is outlined so that we don't need to include UT_BVHImpl.h.
UT_SolidAngle(const int ntriangles, const int *const triangle_points, const int npoints, const UT_Vector3T< S > *const positions, const int order=2)
GLboolean GLboolean GLboolean GLboolean a
constexpr SYS_FORCE_INLINE T length() const noexcept
~UT_SolidAngle()
This is outlined so that we don't need to include UT_BVHImpl.h.
bool isClear() const
Returns true if this is clear.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
T UTsignedSolidAngleQuad(const UT_Vector3T< T > &a, const UT_Vector3T< T > &b, const UT_Vector3T< T > &c, const UT_Vector3T< T > &d, const UT_Vector3T< T > &query)
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
void clear()
Frees myTree and myData, and clears the rest.
void init(const int nsegments, const int *const segment_points, const int npoints, const UT_Vector2T< S > *const positions, const int order=2)
T computeSolidAngle(const UT_Vector3T< T > &query_point, const T accuracy_scale=T(2.0)) const
GLdouble GLdouble GLint GLint order
GLboolean GLboolean GLboolean b
void init(const int ntriangles, const int *const triangle_points, const int npoints, const UT_Vector3T< S > *const positions, const int order=2)
T computeAngle(const UT_Vector2T< T > &query_point, const T accuracy_scale=T(2.0)) const
T UTsignedAngleSegment(const UT_Vector2T< T > &a, const UT_Vector2T< T > &b, const UT_Vector2T< T > &query)
bool isClear() const
Returns true if this is clear.
constexpr SYS_FORCE_INLINE bool isZero() const noexcept
UT_SubtendedAngle()
This is outlined so that we don't need to include UT_BVHImpl.h.
UT_SubtendedAngle(const int nsegments, const int *const segment_points, const int npoints, const UT_Vector2T< S > *const positions, const int order=2)
void clear()
Frees myTree and myData, and clears the rest.
~UT_SubtendedAngle()
This is outlined so that we don't need to include UT_BVHImpl.h.
T UTsignedSolidAngleTri(const UT_Vector3T< T > &a, const UT_Vector3T< T > &b, const UT_Vector3T< T > &c, const UT_Vector3T< T > &query)
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)
GLsizei GLenum GLenum GLuint GLenum GLsizei * lengths