@@ -177,73 +177,6 @@ struct conditionalAbsOrMax_helper<T NBL_PARTIAL_REQ_BOT(concepts::FloatingPointL
177
177
return max <T>(condAbs, limit);
178
178
}
179
179
};
180
-
181
- struct trigonometry
182
- {
183
- using this_t = trigonometry;
184
-
185
- static this_t create ()
186
- {
187
- this_t retval;
188
- retval.tmp0 = 0 ;
189
- retval.tmp1 = 0 ;
190
- retval.tmp2 = 0 ;
191
- retval.tmp3 = 0 ;
192
- retval.tmp4 = 0 ;
193
- retval.tmp5 = 0 ;
194
- return retval;
195
- }
196
-
197
- static this_t create (float cosA, float cosB, float cosC, float sinA, float sinB, float sinC)
198
- {
199
- this_t retval;
200
- retval.tmp0 = cosA;
201
- retval.tmp1 = cosB;
202
- retval.tmp2 = cosC;
203
- retval.tmp3 = sinA;
204
- retval.tmp4 = sinB;
205
- retval.tmp5 = sinC;
206
- return retval;
207
- }
208
-
209
- float getArccosSumofABC_minus_PI ()
210
- {
211
- const bool AltminusB = tmp0 < (-tmp1);
212
- const float cosSumAB = tmp0 * tmp1 - tmp3 * tmp4;
213
- const bool ABltminusC = cosSumAB < (-tmp2);
214
- const bool ABltC = cosSumAB < tmp2;
215
- // apply triple angle formula
216
- const float absArccosSumABC = acos<float >(clamp <float >(cosSumAB * tmp2 - (tmp0 * tmp4 + tmp3 * tmp1) * tmp5, -1.f , 1.f ));
217
- return ((AltminusB ? ABltC : ABltminusC) ? (-absArccosSumABC) : absArccosSumABC) + ((AltminusB || ABltminusC) ? numbers::pi<float > : (-numbers::pi<float >));
218
- }
219
-
220
- static void combineCosForSumOfAcos (float cosA, float cosB, float biasA, float biasB, NBL_REF_ARG (float ) out0, NBL_REF_ARG (float ) out1)
221
- {
222
- const float bias = biasA + biasB;
223
- const float a = cosA;
224
- const float b = cosB;
225
- const bool reverse = abs<float >(min <float >(a, b)) > max <float >(a, b);
226
- const float c = a * b - sqrt<float >((1.0f - a * a) * (1.0f - b * b));
227
-
228
- if (reverse)
229
- {
230
- out0 = -c;
231
- out1 = bias + numbers::pi<float >;
232
- }
233
- else
234
- {
235
- out0 = c;
236
- out1 = bias;
237
- }
238
- }
239
-
240
- float tmp0;
241
- float tmp1;
242
- float tmp2;
243
- float tmp3;
244
- float tmp4;
245
- float tmp5;
246
- };
247
180
}
248
181
249
182
// @ return abs(x) if cond==true, max(x,0.0) otherwise
@@ -253,38 +186,6 @@ T conditionalAbsOrMax(bool cond, T x, T limit)
253
186
return impl::conditionalAbsOrMax_helper<T>::__call (cond, x, limit);
254
187
}
255
188
256
- float getArccosSumofABC_minus_PI (float cosA, float cosB, float cosC, float sinA, float sinB, float sinC)
257
- {
258
- impl::trigonometry trig = impl::trigonometry::create (cosA, cosB, cosC, sinA, sinB, sinC);
259
- return trig.getArccosSumofABC_minus_PI ();
260
- }
261
-
262
- void combineCosForSumOfAcos (float cosA, float cosB, float biasA, float biasB, NBL_REF_ARG (float ) out0, NBL_REF_ARG (float ) out1)
263
- {
264
- impl::trigonometry trig = impl::trigonometry::create ();
265
- impl::trigonometry::combineCosForSumOfAcos (cosA, cosB, biasA, biasB, trig.tmp0, trig.tmp1);
266
- out0 = trig.tmp0;
267
- out1 = trig.tmp1;
268
- }
269
-
270
- // returns acos(a) + acos(b)
271
- float getSumofArccosAB (float cosA, float cosB)
272
- {
273
- impl::trigonometry trig = impl::trigonometry::create ();
274
- impl::trigonometry::combineCosForSumOfAcos (cosA, cosB, 0.0f , 0.0f , trig.tmp0, trig.tmp1);
275
- return acos<float >(trig.tmp0) + trig.tmp1;
276
- }
277
-
278
- // returns acos(a) + acos(b) + acos(c) + acos(d)
279
- float getSumofArccosABCD (float cosA, float cosB, float cosC, float cosD)
280
- {
281
- impl::trigonometry trig = impl::trigonometry::create ();
282
- impl::trigonometry::combineCosForSumOfAcos (cosA, cosB, 0.0f , 0.0f , trig.tmp0, trig.tmp1);
283
- impl::trigonometry::combineCosForSumOfAcos (cosC, cosD, 0.0f , 0.0f , trig.tmp2, trig.tmp3);
284
- impl::trigonometry::combineCosForSumOfAcos (trig.tmp0, trig.tmp2, trig.tmp1, trig.tmp3, trig.tmp4, trig.tmp5);
285
- return acos<float >(trig.tmp4) + trig.tmp5;
286
- }
287
-
288
189
template<typename Lhs, typename Rhs NBL_FUNC_REQUIRES (concepts::Matricial<Lhs> && concepts::Matricial<Rhs> && (matrix_traits<Lhs>::ColumnCount == matrix_traits<Rhs>::RowCount))
289
190
typename cpp_compat_intrinsics_impl::mul_helper<Lhs, Rhs>::return_t applyChainRule (Lhs dFdG, Rhs dGdR)
290
191
{
0 commit comments