11 #ifndef __UT_SolidAngle_h__
12 #define __UT_SolidAngle_h__
19 #define SOLID_ANGLE_USE_BVH 1
20 #if SOLID_ANGLE_USE_BVH
49 if (alength == 0 || blength == 0 || clength == 0)
61 const T numerator =
dot(qa,
cross(qb-qa, qc-qa));
68 const T denominator =
T(1) +
dot(qa,qb) +
dot(qa,qc) +
dot(qb,qc);
70 return T(2)*SYSatan2(numerator, denominator);
101 if (lengths[0] ==
T(0) || lengths[1] ==
T(0) || lengths[2] ==
T(0) || lengths[3] ==
T(0))
122 bary[0] =
dot(v[3],
cross(v23,diag13));
123 bary[1] = -
dot(v[2],
cross(v23,diag02));
124 bary[2] = -
dot(v[1],
cross(v01,diag13));
125 bary[3] =
dot(v[0],
cross(v01,diag02));
127 const T dot01 =
dot(v[0],v[1]);
128 const T dot12 =
dot(v[1],v[2]);
129 const T dot23 =
dot(v[2],v[3]);
130 const T dot30 =
dot(v[3],v[0]);
136 if (bary[0]*bary[2] < bary[1]*bary[3])
139 const T numerator012 = bary[3];
140 const T numerator023 = bary[1];
141 const T dot02 =
dot(v[0],v[2]);
145 if (numerator012 !=
T(0))
147 const T denominator012 =
T(1) + dot01 + dot12 + dot02;
148 omega = SYSatan2(numerator012, denominator012);
150 if (numerator023 !=
T(0))
152 const T denominator023 =
T(1) + dot02 + dot23 + dot30;
153 omega += SYSatan2(numerator023, denominator023);
159 const T numerator013 = -bary[2];
160 const T numerator123 = -bary[0];
161 const T dot13 =
dot(v[1],v[3]);
165 if (numerator013 !=
T(0))
167 const T denominator013 =
T(1) + dot01 + dot13 + dot30;
168 omega = SYSatan2(numerator013, denominator013);
170 if (numerator123 !=
T(0))
172 const T denominator123 =
T(1) + dot12 + dot23 + dot13;
173 omega += SYSatan2(numerator123, denominator123);
179 #if !SOLID_ANGLE_USE_BVH
181 template<
int MAX_ORDER>
182 class UT_RTreeGeneric;
190 template<
typename T,
typename S>
203 const int ntriangles,
204 const int *
const triangle_points,
209 { init(ntriangles, triangle_points, npoints, positions,
order); }
215 const int ntriangles,
216 const int *
const triangle_points,
219 const int order = 2);
226 {
return myNTriangles == 0; }
230 T computeSolidAngle(
const UT_Vector3T<T> &query_point,
const T accuracy_scale =
T(2.0))
const;
235 #if SOLID_ANGLE_USE_BVH
236 static constexpr
uint BVH_N = 4;
245 const int *myTrianglePoints;
250 #undef SOLID_ANGLE_USE_BVH
268 const T numerator =
cross(qa, qb);
276 const T denominator =
dot(qa,qb);
279 return SYSatan2(numerator, denominator);
287 template<
typename T,
typename S>
301 const int *
const segment_points,
306 { init(nsegments, segment_points, npoints, positions,
order); }
313 const int *
const segment_points,
316 const int order = 2);
323 {
return myNSegments == 0; }
327 T computeAngle(
const UT_Vector2T<T> &query_point,
const T accuracy_scale =
T(2.0))
const;
332 static constexpr
uint BVH_N = 4;
338 const int *mySegmentPoints;
GLboolean GLboolean GLboolean GLboolean a
constexpr SYS_FORCE_INLINE T length() const noexcept
UT_SubtendedAngle(const int nsegments, const int *const segment_points, const int npoints, const UT_Vector2T< S > *const positions, const int order=2)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
T UTsignedSolidAngleTri(const UT_Vector3T< T > &a, const UT_Vector3T< T > &b, const UT_Vector3T< T > &c, const UT_Vector3T< T > &query)
UT_SolidAngle(const int ntriangles, const int *const triangle_points, const int npoints, const UT_Vector3T< S > *const positions, const int order=2)
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
GLdouble GLdouble GLint GLint order
GLboolean GLboolean GLboolean b
constexpr SYS_FORCE_INLINE bool isZero() const noexcept
bool isClear() const
Returns true if this is clear.
bool isClear() const
Returns true if this is clear.
T UTsignedAngleSegment(const UT_Vector2T< T > &a, const UT_Vector2T< T > &b, const UT_Vector2T< T > &query)
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)
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)
GLsizei GLenum GLenum GLuint GLenum GLsizei * lengths