20 #ifndef vtk_m_worklet_cellmetrics_CellMinAngleMetric_h
21 #define vtk_m_worklet_cellmetrics_CellMinAngleMetric_h
40 #define UNUSED(expr) (void)(expr);
52 template <
typename OutType,
typename Po
intCoordVecType,
typename CellShapeType>
54 const PointCoordVecType& pts,
74 template <
typename OutType,
typename Po
intCoordVecType>
76 const PointCoordVecType& pts,
77 vtkm::CellShapeTagTriangle,
86 using Scalar = OutType;
87 using CollectionOfPoints = PointCoordVecType;
88 using Vector =
typename PointCoordVecType::ComponentType;
90 const Scalar l0 = GetTriangleL0Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
91 const Scalar l1 = GetTriangleL1Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
92 const Scalar l2 = GetTriangleL2Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
94 if (l0 <= Scalar(0.0) || l1 <= Scalar(0.0) || l2 <= Scalar(0.0))
99 const Scalar oneEightyOverPi = (Scalar)57.2957795131;
100 const Scalar two(2.0);
101 const Scalar q0 =
vtkm::ACos(((l1 * l1) + (l2 * l2) - (l0 * l0)) / (two * l1 * l2));
102 const Scalar q1 =
vtkm::ACos(((l2 * l2) + (l0 * l0) - (l1 * l1)) / (two * l2 * l0));
103 const Scalar q2 =
vtkm::ACos(((l0 * l0) + (l1 * l1) - (l2 * l2)) / (two * l0 * l1));
105 const Scalar q = vtkm::Min(q0, vtkm::Min(q1, q2));
107 const Scalar qInDegrees = q * oneEightyOverPi;
120 template <
typename OutType,
typename Po
intCoordVecType>
122 const PointCoordVecType& pts,
123 vtkm::CellShapeTagQuad,
131 using Scalar = OutType;
132 using CollectionOfPoints = PointCoordVecType;
133 using Vector =
typename PointCoordVecType::ComponentType;
135 const Scalar l0 = GetQuadL0Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
136 const Scalar l1 = GetQuadL1Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
137 const Scalar l2 = GetQuadL2Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
138 const Scalar l3 = GetQuadL3Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
140 if (l0 <= Scalar(0.0) || l1 <= Scalar(0.0) || l2 <= Scalar(0.0) || l3 <= Scalar(0.0))
145 const Scalar alpha0 = GetQuadAlpha0<Scalar, Vector, CollectionOfPoints>(pts);
146 const Scalar alpha1 = GetQuadAlpha1<Scalar, Vector, CollectionOfPoints>(pts);
147 const Scalar alpha2 = GetQuadAlpha2<Scalar, Vector, CollectionOfPoints>(pts);
148 const Scalar alpha3 = GetQuadAlpha3<Scalar, Vector, CollectionOfPoints>(pts);
150 const Scalar s0 = alpha0 < Scalar(0.0) ? Scalar(1.0) : Scalar(0.0);
151 const Scalar s1 = alpha1 < Scalar(0.0) ? Scalar(1.0) : Scalar(0.0);
152 const Scalar s2 = alpha2 < Scalar(0.0) ? Scalar(1.0) : Scalar(0.0);
153 const Scalar s3 = alpha3 < Scalar(0.0) ? Scalar(1.0) : Scalar(0.0);
155 const Vector L0 = GetQuadL0<Scalar, Vector, CollectionOfPoints>(pts);
156 const Vector L1 = GetQuadL1<Scalar, Vector, CollectionOfPoints>(pts);
157 const Vector L2 = GetQuadL2<Scalar, Vector, CollectionOfPoints>(pts);
158 const Vector L3 = GetQuadL3<Scalar, Vector, CollectionOfPoints>(pts);
162 const Scalar neg1(-1.0);
163 const Scalar oneEightyOverPi = (Scalar)57.2957795131;
164 const Scalar threeSixty(360.0);
166 (vtkm::Pow(neg1, s0) *
vtkm::ACos(neg1 * (
static_cast<Scalar
>(vtkm::Dot(L0, L1)) / (l0 * l1))) *
170 (vtkm::Pow(neg1, s1) *
vtkm::ACos(neg1 * (
static_cast<Scalar
>(vtkm::Dot(L1, L2)) / (l1 * l2))) *
174 (vtkm::Pow(neg1, s2) *
vtkm::ACos(neg1 * (
static_cast<Scalar
>(vtkm::Dot(L2, L3)) / (l2 * l3))) *
178 (vtkm::Pow(neg1, s3) *
vtkm::ACos(neg1 * (
static_cast<Scalar
>(vtkm::Dot(L3, L0)) / (l3 * l0))) *
182 const Scalar q = vtkm::Min(q0, vtkm::Min(q1, vtkm::Min(q2, q3)));
188 #endif // vtk_m_worklet_cellmetrics_CellMinAngleMetric_h