MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
maia::lpt Namespace Reference

Namespaces

namespace  baseProperty
 
namespace  cell
 
namespace  collector
 

Classes

class  findPartId
 
struct  partType
 
struct  partTypeEllipsoid
 
struct  sendQueueType
 
class  sort_particleAfterCellIds
 
class  sort_particleAfterDiameter
 
class  sort_particleAfterPartIds
 
class  sort_particleAfterTemperature
 
class  sort_respawnParticleAfterCellIds
 
class  sortDesc_particleAfterDiameter
 
struct  subDomainCollector
 
struct  subDomainCollectorEllipsoid
 
struct  Timers_
 

Typedefs

template<MInt nDim>
using ellipsListIterator = typename std::vector< LPTEllipsoidal< nDim > >::iterator
 
template<MInt nDim>
using ellipsListIteratorConst = typename std::vector< LPTEllipsoidal< nDim > >::const_iterator
 
template<MInt nDim>
using partListIterator = typename std::vector< LPTSpherical< nDim > >::iterator
 
template<MInt nDim>
using partListIteratorConst = typename std::vector< LPTSpherical< nDim > >::const_iterator
 

Functions

template<MInt nDim>
MBool inactiveParticle (const LPTSpherical< nDim > &particle)
 
template<MInt nDim>
MBool activeParticle (const LPTSpherical< nDim > &particle)
 
template<MInt nDim>
MBool inactiveEllipsoid (const LPTEllipsoidal< nDim > &particle)
 
template<MInt nDim>
MBool activeEllipsoid (const LPTEllipsoidal< nDim > &particle)
 
MFloat scalarProduct (const MFloat *a, const MFloat *b, const MInt length)
 
void slerp (const MFloat *before, const MFloat *now, const MFloat time, MFloat *result, const MInt length)
 
void matrixMultiplyLeft (MFloat left[3][3], MFloat right[3][3])
 Matrix multiplication; matrix right is changed and contains the result. More...
 
void matrixMultiplyRight (MFloat left[3][3], MFloat right[3][3])
 Matrix multiplication; matrix left is changed and contains the result. More...
 
MInt randomVectorInCone (MFloat *vec, const MFloat *coneAxis, const MFloat length, const MFloat openingAngle, const MInt dist, std::mt19937_64 &PRNG, const MFloat distCoeff=0.0, const MFloat nozzleAngle=0.0)
 Generate a random vector in a cone defined by its opening angle. More...
 
void randomPointInCircle (MFloat *vec, const MFloat *normalDirection, const MFloat diameter, std::mt19937_64 &PRNG)
 
void randomPointOnCircle (MFloat *vec, const MFloat *normalDirection, const MFloat diameter, std::mt19937_64 &PRNG, const MInt circleSplit=1, const MInt splitNo=0)
 
void pointOnCircle (MFloat *vec, const MFloat *normalDirection, const MFloat diameter, MFloat phi)
 
MFloat rosinRammler (const MFloat min, const MFloat mean, const MFloat max, const MFloat spread, std::mt19937_64 &PRNG)
 
MFloat NTDistribution (const MFloat x_mean, std::mt19937_64 &PRNG)
 

Typedef Documentation

◆ ellipsListIterator

template<MInt nDim>
using maia::lpt::ellipsListIterator = typedef typename std::vector<LPTEllipsoidal<nDim> >::iterator

Definition at line 30 of file lptlib.h.

◆ ellipsListIteratorConst

template<MInt nDim>
using maia::lpt::ellipsListIteratorConst = typedef typename std::vector<LPTEllipsoidal<nDim> >::const_iterator

Definition at line 32 of file lptlib.h.

◆ partListIterator

template<MInt nDim>
using maia::lpt::partListIterator = typedef typename std::vector<LPTSpherical<nDim> >::iterator

Definition at line 35 of file lptlib.h.

◆ partListIteratorConst

template<MInt nDim>
using maia::lpt::partListIteratorConst = typedef typename std::vector<LPTSpherical<nDim> >::const_iterator

Definition at line 37 of file lptlib.h.

Function Documentation

◆ activeEllipsoid()

template<MInt nDim>
MBool maia::lpt::activeEllipsoid ( const LPTEllipsoidal< nDim > &  particle)
inline

Definition at line 144 of file lptlib.h.

144 {
145 return (!particle.isInvalid());
146}
BitsetType::reference isInvalid()
Definition: lptbase.h:151

◆ activeParticle()

template<MInt nDim>
MBool maia::lpt::activeParticle ( const LPTSpherical< nDim > &  particle)
inline

Definition at line 134 of file lptlib.h.

134 {
135 return (!particle.isInvalid());
136}

◆ inactiveEllipsoid()

template<MInt nDim>
MBool maia::lpt::inactiveEllipsoid ( const LPTEllipsoidal< nDim > &  particle)
inline

Definition at line 139 of file lptlib.h.

139 {
140 return particle.isInvalid();
141}

◆ inactiveParticle()

template<MInt nDim>
MBool maia::lpt::inactiveParticle ( const LPTSpherical< nDim > &  particle)
inline

Definition at line 129 of file lptlib.h.

129 {
130 return particle.isInvalid();
131}

◆ matrixMultiplyLeft()

void maia::lpt::matrixMultiplyLeft ( MFloat  left[3][3],
MFloat  right[3][3] 
)
inline

LPT::matrixMultiplyLeft(MFloat left[3][3], MFloat right[3][3])

Feb-2011

Author
Rudie Kunnen

Definition at line 194 of file lptlib.h.

194 {
195 TRACE();
196
197 MFloat temp[3][3];
198 for(MInt i = 0; i < 3; i++) {
199 for(MInt j = 0; j < 3; j++) {
200 temp[i][j] = right[i][j];
201 right[i][j] = 0.0;
202 }
203 }
204
205 for(MInt i = 0; i < 3; i++) {
206 for(MInt j = 0; j < 3; j++) {
207 for(MInt k = 0; k < 3; k++) {
208 right[i][j] += left[i][k] * temp[k][j];
209 }
210 }
211 }
212}
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52

◆ matrixMultiplyRight()

void maia::lpt::matrixMultiplyRight ( MFloat  left[3][3],
MFloat  right[3][3] 
)
inline

LPT::matrixMultiplyRight(MFloat left[3][3], MFloat right[3][3])

Feb-2011

Author
Rudie Kunnen

Definition at line 220 of file lptlib.h.

220 {
221 TRACE();
222
223 MFloat temp[3][3];
224 for(MInt i = 0; i < 3; i++) {
225 for(MInt j = 0; j < 3; j++) {
226 temp[i][j] = left[i][j];
227 left[i][j] = 0.0;
228 }
229 }
230
231 for(MInt i = 0; i < 3; i++) {
232 for(MInt j = 0; j < 3; j++) {
233 for(MInt k = 0; k < 3; k++) {
234 left[i][j] += temp[i][k] * right[k][j];
235 }
236 }
237 }
238}

◆ NTDistribution()

MFloat maia::lpt::NTDistribution ( const MFloat  x_mean,
std::mt19937_64 &  PRNG 
)
inline

Nukiyama-Tanasawa distribution function, used as a normal-velocity ditribution for spray-wall interaction as in: Spray/wall interaction models for multidimensional engine simulation Z.Han, Z. Xu, N. Trigui Int. J. Engine Research Vol. 1 No. 1 2000

Author
Tim Wegmann
Parameters
[in]PRNGrandom number used once
Date
January 2023

Definition at line 601 of file lptlib.h.

601 {
602 std::uniform_real_distribution<MFloat> uni(0.0, 1.0);
603 const MFloat x = uni(PRNG);
604
605 return 4 / sqrt(M_PI) * POW2(x) / x_mean * exp(-POW2(x / x_mean));
606}
constexpr Real POW2(const Real x)
Definition: functions.h:119

◆ pointOnCircle()

void maia::lpt::pointOnCircle ( MFloat vec,
const MFloat normalDirection,
const MFloat  diameter,
MFloat  phi 
)
inline

Obtain a point within a circular plane given a diameter and angle.

Author
Sven Berger
Date
August 2018
Parameters
[out]vecPoint within the defined sphere.
[in]normalDirectionThe circluar plane normal direction vector.
[in]diameterDiameter of the circle.
[in]phiAngle of the point

Definition at line 528 of file lptlib.h.

528 {
529 MFloat centerAxis[3]{};
530 std::copy_n(normalDirection, 3, &centerAxis[0]);
531
532 // 1. normalize centerAxis
533 maia::math::normalize(&centerAxis[0], 3);
534
535 // 2. find orthonormal basis to centerAxis
536 // 2.1 choose a linear independent vector to centerAxis that lies in the plane a v1 * centerAxis = 1
537 MFloat v1[3]{};
538 MFloat temp[3]{};
539
540
541 if(std::abs(centerAxis[0]) > 0.0) {
542 v1[0] = 1.0 / centerAxis[0];
543 } else if(std::abs(centerAxis[1]) > 0.0) {
544 v1[1] = 1.0 / centerAxis[1];
545 } else {
546 v1[2] = 1.0 / centerAxis[2];
547 }
548
549 if(std::abs(normalDirection[0]) < std::numeric_limits<MFloat>::epsilon()) {
550 v1[0] = 1.0;
551 } else if(std::abs(normalDirection[1]) < std::numeric_limits<MFloat>::epsilon()) {
552 v1[1] = 1.0;
553 } else if(std::abs(normalDirection[2]) < std::numeric_limits<MFloat>::epsilon()) {
554 v1[2] = 1.0;
555 }
556
557 // 2.2 Use this vector to determine the first basis vector by calculating v1 = v1 x centerAxis
558 std::copy_n(&v1[0], 3, &temp[0]);
559 maia::math::cross(&temp[0], &centerAxis[0], &v1[0]);
560
561 // 2.3 Calculate crossproduct of v1 and centerAxis to determine the last vector v2
562 MFloat v2[3]{};
563 maia::math::cross(&v1[0], &centerAxis[0], &v2[0]);
564
565 // 2.4 Normalize v1 and v2
566 maia::math::normalize(&v1[0], 3);
567 maia::math::normalize(&v2[0], 3);
568
569 // 3. Use orthonormal basis to determine points on circle
570 vec[0] = 0.5 * diameter * (cos(phi) * v1[0] + sin(phi) * v2[0]);
571 vec[1] = 0.5 * diameter * (cos(phi) * v1[1] + sin(phi) * v2[1]);
572 vec[2] = 0.5 * diameter * (cos(phi) * v1[2] + sin(phi) * v2[2]);
573}
T cos(const T a, const T b, const T x)
Cosine slope filter.
Definition: filter.h:125
void cross(const T *const u, const T *const v, T *const c)
Definition: maiamath.h:101
void normalize(std::array< T, N > &u)
Definition: maiamath.h:191

◆ randomPointInCircle()

void maia::lpt::randomPointInCircle ( MFloat vec,
const MFloat normalDirection,
const MFloat  diameter,
std::mt19937_64 &  PRNG 
)
inline

Obtain a point within a circle with a diameter around the origin.

Author
Sven Berger
Date
March 2017
Parameters
[out]vecPoint within the defined sphere.
[in]normalDirectionThe circles normal direction vector.
[in]diameterDiameter of the circle.
[in]PRNGtwo randon numbers are generated!

Definition at line 383 of file lptlib.h.

384 {
385 MFloat centerAxis[3]{};
386 std::copy_n(normalDirection, 3, &centerAxis[0]);
387
388 // 1. normalize centerAxis
389 maia::math::normalize(&centerAxis[0], 3);
390
391 // 2. find orthonormal basis to centerAxis
392 // 2.1 choose a linear independent vector to centerAxis that lies in the plane a v1 * centerAxis = 1
393 MFloat v1[3]{};
394 MFloat temp[3]{};
395
396
397 if(std::abs(centerAxis[0]) > 0.0) {
398 v1[0] = 1.0 / centerAxis[0];
399 } else if(std::abs(centerAxis[1]) > 0.0) {
400 v1[1] = 1.0 / centerAxis[1];
401 } else {
402 v1[2] = 1.0 / centerAxis[2];
403 }
404
405 if(std::abs(normalDirection[0]) < std::numeric_limits<MFloat>::epsilon()) {
406 v1[0] = 1.0;
407 } else if(std::abs(normalDirection[1]) < std::numeric_limits<MFloat>::epsilon()) {
408 v1[1] = 1.0;
409 } else if(std::abs(normalDirection[2]) < std::numeric_limits<MFloat>::epsilon()) {
410 v1[2] = 1.0;
411 }
412
413 // 2.2 Use this vector to determine the first basis vector by calculating v1 = v1 x centerAxis
414 std::copy_n(&v1[0], 3, &temp[0]);
415 maia::math::cross(&temp[0], &centerAxis[0], &v1[0]);
416
417 // 2.3 Calculate crossproduct of v1 and centerAxis to determine the last vector v2
418 MFloat v2[3]{};
419 maia::math::cross(&v1[0], &centerAxis[0], &v2[0]);
420
421 // 2.4 Normalize v1 and v2
422 maia::math::normalize(&v1[0], 3);
423 maia::math::normalize(&v2[0], 3);
424
425 // 3. Use orthonormal basis to determine points on circle
426
427 // angle of the point within the sphere
428 std::uniform_real_distribution<MFloat> dist0_2Pi(0, 2 * M_PI);
429 // distance of the point from the origin within the sphere
430 std::uniform_real_distribution<MFloat> randRadius(0, 1);
431
432 MFloat phi = 0;
433 MFloat radius = 0;
434#ifdef _OPENMP
435#pragma omp critical
436#endif
437 {
438 // determine random angle in unit circle
439 phi = dist0_2Pi(PRNG);
440
441 // random Radius in the unit circle
442 radius = randRadius(PRNG);
443 }
444
445 vec[0] = 0.5 * diameter * radius * (cos(phi) * v1[0] + sin(phi) * v2[0]);
446 vec[1] = 0.5 * diameter * radius * (cos(phi) * v1[1] + sin(phi) * v2[1]);
447 vec[2] = 0.5 * diameter * radius * (cos(phi) * v1[2] + sin(phi) * v2[2]);
448}

◆ randomPointOnCircle()

void maia::lpt::randomPointOnCircle ( MFloat vec,
const MFloat normalDirection,
const MFloat  diameter,
std::mt19937_64 &  PRNG,
const MInt  circleSplit = 1,
const MInt  splitNo = 0 
)
inline

Obtain a random point on a circle

Author
Sven Berger
Date
August 2018
Parameters
[out]vecPoint within the defined sphere.
[in]normalDirectionThe circles normal direction vector.
[in]diameterDiameter of the circle.
[in]PRNGrandom number used once
[in]circleSplitSplit circle into this number of sections
[in]splitNoDetermine point within this partial circle

Definition at line 459 of file lptlib.h.

460 {
461 MFloat centerAxis[3]{};
462 std::copy_n(normalDirection, 3, &centerAxis[0]);
463
464 // 1. normalize centerAxis
465 maia::math::normalize(&centerAxis[0], 3);
466
467 // 2. find orthonormal basis to centerAxis
468 // 2.1 choose a linear independent vector to centerAxis that lies in the plane a v1 * centerAxis = 1
469 MFloat v1[3]{};
470 MFloat temp[3]{};
471
472
473 if(std::abs(centerAxis[0]) > 0.0) {
474 v1[0] = 1.0 / centerAxis[0];
475 } else if(std::abs(centerAxis[1]) > 0.0) {
476 v1[1] = 1.0 / centerAxis[1];
477 } else {
478 v1[2] = 1.0 / centerAxis[2];
479 }
480
481 if(std::abs(normalDirection[0]) < std::numeric_limits<MFloat>::epsilon()) {
482 v1[0] = 1.0;
483 } else if(std::abs(normalDirection[1]) < std::numeric_limits<MFloat>::epsilon()) {
484 v1[1] = 1.0;
485 } else if(std::abs(normalDirection[2]) < std::numeric_limits<MFloat>::epsilon()) {
486 v1[2] = 1.0;
487 }
488
489 // 2.2 Use this vector to determine the first basis vector by calculating v1 = v1 x centerAxis
490 std::copy_n(&v1[0], 3, &temp[0]);
491 maia::math::cross(&temp[0], &centerAxis[0], &v1[0]);
492
493 // 2.3 Calculate crossproduct of v1 and centerAxis to determine the last vector v2
494 MFloat v2[3]{};
495 maia::math::cross(&v1[0], &centerAxis[0], &v2[0]);
496
497 // 2.4 Normalize v1 and v2
498 maia::math::normalize(&v1[0], 3);
499 maia::math::normalize(&v2[0], 3);
500
501 // 3. Use orthonormal basis to determine points on circle
502 const MFloat splitCircle = (2.0 * M_PI / static_cast<MFloat>(circleSplit));
503
504 // angle of the point within the sphere
505 std::uniform_real_distribution<MFloat> dist0_2Pi(splitCircle * splitNo, splitCircle * (splitNo + 1));
506
507 MFloat phi = 0;
508#ifdef _OPENMP
509#pragma omp critical
510#endif
511 {
512 phi = dist0_2Pi(PRNG); // determine random angle in unit circle
513 }
514
515
516 vec[0] = 0.5 * diameter * (cos(phi) * v1[0] + sin(phi) * v2[0]);
517 vec[1] = 0.5 * diameter * (cos(phi) * v1[1] + sin(phi) * v2[1]);
518 vec[2] = 0.5 * diameter * (cos(phi) * v1[2] + sin(phi) * v2[2]);
519}

◆ randomVectorInCone()

MInt maia::lpt::randomVectorInCone ( MFloat vec,
const MFloat coneAxis,
const MFloat  length,
const MFloat  openingAngle,
const MInt  dist,
std::mt19937_64 &  PRNG,
const MFloat  distCoeff = 0.0,
const MFloat  nozzleAngle = 0.0 
)
inline
Author
Sven Berger
Date
July 2015
Parameters
[out]vecVector of a movement in the defined cone using the provided distribution.
[in]coneAxisCenter axis of the cone.
[in]lengthLength of the cone.
[in]openingAngleOpening angle of the cone. (Note: This means the full opening angle! It inside this function to obtain the cone angle!)
[in]PRNGrandom number used unknown number of times!

Definition at line 252 of file lptlib.h.

254 {
255 using namespace std;
256
257 MFloat centerAxis[3]{};
258 MFloat v1[3]{};
259 MFloat v2[3]{};
260 MFloat temp[3]{};
261 MInt nPRNGCall = 0;
262
263 const MFloat correctedOpeningAngle = openingAngle - 2.0 * nozzleAngle;
264
265 std::copy_n(coneAxis, 3, &centerAxis[0]);
266 // angle between center cone axis and cone shell
267 MFloat distedAngle = 0;
269 //~68% of all particles are within in the center cone for distCoeff = 1.0
270 normal_distribution<MFloat> distAngle(0, distCoeff * correctedOpeningAngle);
271 // reject angles that are too large
272 do {
273 distedAngle = distAngle(PRNG);
274 nPRNGCall++;
275 } while(distedAngle > correctedOpeningAngle);
276 } else {
277 // uniform
278 distedAngle = correctedOpeningAngle;
279 }
280
281 // NOTE: actually half-cone angle
282 const MFloat coneAngleRad = (distedAngle / 360) * M_PI;
283
284 ASSERT(abs(coneAxis[0]) > std::numeric_limits<MFloat>::epsilon()
285 || abs(coneAxis[1]) > std::numeric_limits<MFloat>::epsilon()
286 || abs(coneAxis[2]) > std::numeric_limits<MFloat>::epsilon(),
287 "ERROR: ConeAxis cannot be Zero!");
288 ASSERT(openingAngle <= 360, "ERROR: Opening angle cannot be larger than 360 degrees!");
289
290 // 1. normalize centerAxis
291 maia::math::normalize(&centerAxis[0], 3);
292
293 // 2. find orthonormal basis to centerAxis
294 // 2.1 choose a linear independent vector to centerAxis
295 // that lies in the plane a * centerAxis = 1
296 if(abs(centerAxis[0]) > 0.0) {
297 v1[0] = 1.0 / centerAxis[0];
298 } else if(abs(centerAxis[1]) > 0.0) {
299 v1[1] = 1.0 / centerAxis[1];
300 } else {
301 v1[2] = 1.0 / centerAxis[2];
302 }
303
304 if(abs(coneAxis[0]) < std::numeric_limits<MFloat>::epsilon()) {
305 v1[0] = 1.0;
306 } else if(abs(coneAxis[1]) < std::numeric_limits<MFloat>::epsilon()) {
307 v1[1] = 1.0;
308 } else if(abs(coneAxis[2]) < std::numeric_limits<MFloat>::epsilon()) {
309 v1[2] = 1.0;
310 }
311
312 // 2.2 Use this vector to determine the first basis vector
313 // by calculating v1 = v1 x centerAxis
314 std::copy_n(&v1[0], 3, &temp[0]);
315 maia::math::cross(&temp[0], &centerAxis[0], &v1[0]);
316
317 // 2.3 Calculate crossproduct of v1 and centerAxis to determine the last vector v2
318 maia::math::cross(&v1[0], &centerAxis[0], &v2[0]);
319
320 // 2.4 Normalize v1 and v2
321 maia::math::normalize(&v1[0], 3);
322 maia::math::normalize(&v2[0], 3);
323
324 // 3. Use orthonormal basis to determine points on spherical cap
325 uniform_real_distribution<MFloat> dist0_2Pi(0, 2 * M_PI);
326 // the formulation of the random number in the cos-range
327 // and then taking the acos ensures the angle is in the range of:
328 // -coneAngle -> coneAngle
329 // when overlayed with second angle phi in the range of [ 0 -> 2 PI]
330 uniform_real_distribution<MFloat> randAngle(cos(coneAngleRad), 1);
331
332 MFloat phi = 0;
333 MFloat omega = coneAngleRad;
334#ifdef _OPENMP
335#pragma omp critical
336#endif
337 {
338 // determine random point on unit circle
339 phi = dist0_2Pi(PRNG);
340 nPRNGCall++;
341
342 // random angle in the given opening angle i.e in the range of [coneAngel -> 0]
343 omega = acos(randAngle(PRNG));
344 nPRNGCall++;
345 }
346
348 // avoid tan-formulation as omega is a random angle
349 vec[0] = sin(omega) * (cos(phi) * v1[0] + sin(phi) * v2[0]) + cos(omega) * centerAxis[0];
350 vec[1] = sin(omega) * (cos(phi) * v1[1] + sin(phi) * v2[1]) + cos(omega) * centerAxis[1];
351 vec[2] = sin(omega) * (cos(phi) * v1[2] + sin(phi) * v2[2]) + cos(omega) * centerAxis[2];
352
353 } else {
354 // coneAngleRad must be in definition region of tan!
355 // i.e. -pi/2 -> pi/2
356 vec[0] = tan(omega) * (cos(phi) * v1[0] + sin(phi) * v2[0]) + centerAxis[0];
357 vec[1] = tan(omega) * (cos(phi) * v1[1] + sin(phi) * v2[1]) + centerAxis[1];
358 vec[2] = tan(omega) * (cos(phi) * v1[2] + sin(phi) * v2[2]) + centerAxis[2];
359 // NOTE: at this point the resulting vector has the given magnitude plus the
360 // overlaying random tangential velocity component!
361 // used in some formulations of the secondary break-up!
362 }
363
364 // normalize result
365 // NOTE: in this case the resulting vector has the given magnitude
366 maia::math::normalize(vec, 3);
367
368
369 vec[0] *= length;
370 vec[1] *= length;
371 vec[2] *= length;
372
373 return nPRNGCall;
374}
@ PART_EMITT_DIST_GAUSSIAN
Definition: enums.h:348
@ PART_EMITT_DIST_NONE
Definition: enums.h:348
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)
Definition: pointbox.h:54

◆ rosinRammler()

MFloat maia::lpt::rosinRammler ( const MFloat  min,
const MFloat  mean,
const MFloat  max,
const MFloat  spread,
std::mt19937_64 &  PRNG 
)
inline

rosin-rammler distribition function, used as initial droplet size distribution as in: LARGE EDDY SIMULATION OF HIGH-VELOCITY FUEL SPRAYS: STUDYING MESH RESOLUTION AND BREAKUP MODEL EFFECTS FOR SPRAY A A. Wehrfritz, V. Vuorinen, O. Kaario, & M. Larmi Atomization and Sprays, 23 (5): 419–442 (2013)

Author
Tim Wegmann
Parameters
[in]PRNGrandom number used once
Date
March 2021

Definition at line 584 of file lptlib.h.

585 {
586 const MFloat K = 1.0 - exp(-pow((max - min) / mean, spread));
587
588 std::uniform_real_distribution<MFloat> uni(0.0, 1.0);
589 const MFloat x = uni(PRNG);
590
591 return min + mean * pow(-log(1.0 - x * K), 1.0 / spread);
592}

◆ scalarProduct()

MFloat maia::lpt::scalarProduct ( const MFloat a,
const MFloat b,
const MInt  length 
)
inline

Definition at line 149 of file lptlib.h.

149 {
150 MFloat returnValue = F0;
151 for(MInt count = 0; count < length; ++count) {
152 returnValue += a[count] * b[count];
153 }
154 return returnValue;
155}
Definition: contexttypes.h:19

◆ slerp()

void maia::lpt::slerp ( const MFloat before,
const MFloat now,
const MFloat  time,
MFloat result,
const MInt  length 
)
inline

Definition at line 157 of file lptlib.h.

157 {
158 // TRACE();
159 MFloat dotP = scalarProduct(before, now, length);
160 if(dotP < 0) {
161 dotP = -dotP;
162 for(MInt count = 0; count < length; ++count) {
163 result[count] = -now[count];
164 }
165 } else {
166 for(MInt count = 0; count < length; ++count) {
167 result[count] = now[count];
168 }
169 }
170
171 if(dotP < 0.95) {
172 MFloat angle = acos(dotP);
173 MFloat sint1 = sin(angle * (1 - time));
174 MFloat sint = sin(angle * time);
175 MFloat sinA = sin(angle);
176 for(MInt count = 0; count < length; ++count) {
177 result[count] = (before[count] * sint1 + result[count] * sint) / sinA;
178 }
179 } else {
180 for(MInt count = 0; count < length; ++count) {
181 result[count] = before[count] * (F1 - time) + result[count] * time;
182 }
183 }
184 maia::math::normalize(result, length);
185}
MFloat scalarProduct(const MFloat *a, const MFloat *b, const MInt length)
Definition: lptlib.h:149