OpenLB 1.7
Searching...
No Matches
olb::sdf Namespace Reference

## Functions

template<typename T >
mix (T a, T b, T h) any_platform

template<typename T0 , typename T1 , typename T2 >
decltype(T0 {} *T1 {} *T2 {}) clamp (T0 x, T1 a, T2 b) any_platform

template<typename T >
Vector< bool, 3 > isSymmetric (std::function< T(const Vector< T, 3 > &)> sdf, Vector< T, 3 > center) any_platform
A rough test for symmetry.

template<typename T , unsigned D>
sphere (Vector< T, D > p, T r) any_platform
Exact signed distance to the surface of circle (in 2D) or sphere (in 3D).

template<typename T >
box (Vector< T, 2 > p, Vector< T, 2 > b) any_platform
Exact signed distance to the surface of two-dimensional cuboid.

template<typename T >
box (Vector< T, 3 > p, Vector< T, 3 > b) any_platform
Exact signed distance to the surface of three-dimensional cuboid.

template<typename T >
triangle (Vector< T, 2 > p, Vector< T, 2 > a, Vector< T, 2 > b, Vector< T, 2 > c) any_platform
Exact signed distance to the surface of two-dimensional triangle.

template<typename T >
cylinder (Vector< T, 3 > p, Vector< T, 3 > a, Vector< T, 3 > ba, T baba, T r) any_platform
Exact signed distance to the surface of three-dimensional cylinder.

template<typename T >
cylinder (Vector< T, 3 > p, Vector< T, 3 > a, Vector< T, 3 > b, T r) any_platform
Calculate signed distance to the surface of three-dimensional cylinder defined by the centers of the two extremities and the radius.

template<typename T >
cone (Vector< T, 3 > p, Vector< T, 3 > a, Vector< T, 3 > ba, T baba, T ra, T rb) any_platform
Exact signed distance to the surface of three-dimensional (capped) cone.

template<typename T >
cone (Vector< T, 3 > p, Vector< T, 3 > a, Vector< T, 3 > b, T ra, T rb) any_platform
Calculate signed distance to the surface of three-dimensional capped cone defined by the centers of the two extremities and the corresponding radius.

template<typename T >
ellipsoid (Vector< T, 3 > p, Vector< T, 3 > r) any_platform
Calculate the NOT EXACT (!) signed distance to the surface of three-dimensional ellipsoid.

template<typename T >
torus (Vector< T, 3 > p, Vector< T, 2 > t) any_platform
Exact signed distance to the surface of a torus placed in the XZ-plane of the coordinate system.

template<typename T >
solidAngle (Vector< T, 3 > p, Vector< T, 2 > c, T r) any_platform
Exact signed distance to the surface of a solid angle which represents a combination of a cone (axis y=0 to y=r) and a sphere.

template<typename T , unsigned D>
Vector< T, D > translate (Vector< T, D > p, Vector< T, D > origin) any_platform
Translation: The output of this function is used for the calculation of the signed distance to translated/shifted objects.

template<typename T >
Vector< T, 3 > flip (Vector< T, 3 > p) any_platform

template<typename T >
subtraction (T a, T b) any_platform
Volume of a is subtracted from b.

template<typename T >
unify (T a, T b) any_platform
Volume of a and volume of b are combined as a new object.

template<typename T >
intersection (T a, T b) any_platform
Volume which is shared by a and b creates a new object.

template<typename T >
smooth_union (T a, T b, T k) any_platform

template<typename T >
smooth_subtraction (T a, T b, T k) any_platform

template<typename T >
smooth_intersection (T a, T b, T k) any_platform

template<typename T >
rounding (T a, T r) any_platform
Computes a layer of a constant thickness around the surface.

template<typename T , bool symmetryCheck = true>
elongation (std::function< T(const Vector< T, 3 > &)> sdf, const Vector< T, 3 > &p, const Vector< T, 3 > &h, const Vector< T, 3 > &center=(T(0))) any_platform
Elongation splits the object in 2 (4 or 8) parts, moves them apart and connects them again The object has to be placed in the origin of the coodinate system.

template<typename T , unsigned D>
scale (std::function< T(const Vector< T, D > &)> sdf, const Vector< T, D > &p, T s, const Vector< T, D > &center=(T(0))) any_platform
Function to scale a geometry The object has to be placed in the origin of the coodinate system.

template<typename T >
signedDistanceToPorosity (T signedDist, T eps) any_platform
Converts signed distance to values for the smooth epsilon boundary.

template<typename T >
bool evalSolidVolumeFraction (T output[], T signedDist, T eps) any_platform

## ◆ box() [1/2]

template<typename T >
 T olb::sdf::box ( Vector< T, 2 > p, Vector< T, 2 > b )

Exact signed distance to the surface of two-dimensional cuboid.

Parameters
 p point for which the distance to the surface is calculated b vector containing half side lengths to describe the cuboid

Definition at line 115 of file sdf.h.

116{
117 Vector<T, 2> q = abs(p) - b;
118 return norm(maxv(q, Vector<T, 2>(0.0))) +
119 util::min(util::max({q[0], q[1]}), T());
120}
Plain old scalar vector.
Definition vector.h:47
std::enable_if_t< std::is_arithmetic< T >::type::value, T > abs(T x)
Definition util.h:396
constexpr Vector< T, D > maxv(const ScalarVector< T, D, IMPL > &v, const ScalarVector< T, D, IMPL_ > &w)
Definition vector.h:400
constexpr T norm(const ScalarVector< T, D, IMPL > &a)
Euclidean vector norm.

References olb::abs(), olb::util::max(), olb::maxv(), olb::util::min(), and olb::norm().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ box() [2/2]

template<typename T >
 T olb::sdf::box ( Vector< T, 3 > p, Vector< T, 3 > b )

Exact signed distance to the surface of three-dimensional cuboid.

Parameters
 p point for which the distance to the surface is calculated b vector containing half side lengths to describe the cuboid

Definition at line 128 of file sdf.h.

129{
130 Vector<T, 3> q = abs(p) - b;
131 return norm(maxv(q, Vector<T, 3>(0.0))) +
132 util::min(util::max({q[0], q[1], q[2]}), T());
133}

References olb::abs(), olb::util::max(), olb::maxv(), olb::util::min(), and olb::norm().

Here is the call graph for this function:

## ◆ clamp()

template<typename T0 , typename T1 , typename T2 >
 decltype(T0 {} *T1 {} *T2 {}) olb::sdf::clamp ( T0 x, T1 a, T2 b )

Definition at line 50 of file sdf.h.

50 {} * T1 {} * T2 {}) clamp(T0 x, T1 a, T2 b) any_platform
51{
52 if (x < a) {
53 return a;
54 }
55 else if (x > b) {
56 return b;
57 }
58 else {
59 return x;
60 }
61}
decltype(T0 {} *T1 {} *T2 {}) clamp(T0 x, T1 a, T2 b) any_platform
Definition sdf.h:50
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:78
Here is the caller graph for this function:

## ◆ cone() [1/2]

template<typename T >
 T olb::sdf::cone ( Vector< T, 3 > p, Vector< T, 3 > a, Vector< T, 3 > b, T ra, T rb )

Calculate signed distance to the surface of three-dimensional capped cone defined by the centers of the two extremities and the corresponding radius.

For the calculation of a cone, the second radius is set to zero

Parameters
 p point for which the distance to the surface is calculated a vector containing center of the first circular end of the capped cone b vector containing center of the second circular end of the capped cone or the apex of the cone ra radius of the first circular end of the capped cone rb radius of the second circular end of the capped cone

Definition at line 241 of file sdf.h.

242{
243 Vector<T, 3> ba = b - a;
244 T baba = ba * ba;
245 return sdf::cone(p, a, ba, baba, ra, rb);
246}

References cone().

Here is the call graph for this function:

## ◆ cone() [2/2]

template<typename T >
 T olb::sdf::cone ( Vector< T, 3 > p, Vector< T, 3 > a, Vector< T, 3 > ba, T baba, T ra, T rb )

Exact signed distance to the surface of three-dimensional (capped) cone.

Parameters
 p point for which the distance to the surface is calculated a vector containing center of the first circular end of the (capped) cone ba vector representing the axis of the (capped) cone baba length of the cone height squared

Definition at line 210 of file sdf.h.

212{
213 T rba = rb - ra;
214 T papa = (p - a) * (p - a);
215 T paba = (p - a) * (ba) / baba;
216 // x distance to the axis of the cone
217 // note: abs() prevents from negative values, e.g. caused by rounding errors
218 T x = util::sqrt(util::abs(papa - paba * paba * baba));
219 // cax and cay for the distances to the caps
220 T cax = util::max(0.0, x - ((paba < 0.5) ? ra : rb));
221 T cay = util::abs(paba - 0.5) - 0.5;
222 // cbx and cby for the distance to the side wall
223 T k = rba * rba + baba;
224 T f = clamp((rba * (x - ra) + paba * baba) / k, 0.0, 1.0);
225 T cbx = x - ra - f * rba;
226 T cby = paba - f;
227 T s = (cbx < 0.0 && cay < 0.0) ? -1.0 : 1.0;
228 return s * util::sqrt(util::min(cax * cax + cay * cay * baba,
229 cbx * cbx + cby * cby * baba));
230}

References olb::util::abs(), clamp(), olb::util::max(), olb::util::min(), and olb::util::sqrt().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ cylinder() [1/2]

template<typename T >
 T olb::sdf::cylinder ( Vector< T, 3 > p, Vector< T, 3 > a, Vector< T, 3 > b, T r )

Calculate signed distance to the surface of three-dimensional cylinder defined by the centers of the two extremities and the radius.

Parameters
 p point for which the distance to the surface is calculated a vector containing center of the first circular end of the cylinder b vector containing center of the second circular end of the cylinder r radius of the cylinder

Definition at line 195 of file sdf.h.

196{
197 Vector<T, 3> ba = b - a;
198 T baba = ba * ba;
199 return sdf::cylinder(p, a, ba, baba, r);
200}

References cylinder().

Here is the call graph for this function:

## ◆ cylinder() [2/2]

template<typename T >
 T olb::sdf::cylinder ( Vector< T, 3 > p, Vector< T, 3 > a, Vector< T, 3 > ba, T baba, T r )

Exact signed distance to the surface of three-dimensional cylinder.

Parameters
 p point for which the distance to the surface is calculated a vector containing center of the first circular end of the cylinder ba vector representing the axis of the cylinder baba length of the cylinder height squared

Definition at line 172 of file sdf.h.

174{
175 const Vector<T, 3> pa = p - a;
176 const T paba = pa * ba;
177 const T x = norm(pa * baba - ba * paba) - r * baba;
178 const T y = util::abs(paba - baba * T {0.5}) - baba * T {0.5};
179 const T x2 = x * x;
180 const T y2 = y * y * baba;
181 const T d = (util::max(x, y) < T {0})
182 ? -util::min(x2, y2)
183 : (((x > T {0}) ? x2 : T {0}) + ((y > T {0}) ? y2 : T {0}));
184 return util::sign(d) * util::sqrt(util::abs(d)) / baba;
185}
Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ ellipsoid()

template<typename T >
 T olb::sdf::ellipsoid ( Vector< T, 3 > p, Vector< T, 3 > r )

Calculate the NOT EXACT (!) signed distance to the surface of three-dimensional ellipsoid.

Parameters
 p point for which the distance to the surface is calculated r vector containing half the length of the principal axes

Definition at line 253 of file sdf.h.

254{
255 const Vector<T, 3> a(p[0] / r[0], p[1] / r[1], p[2] / r[2]);
256 T k0 = norm(a);
257 const Vector<T, 3> r2(r[0] * r[0], r[1] * r[1], r[2] * r[2]);
258 const Vector<T, 3> b(p[0] / r2[0], p[1] / r2[1], p[2] / r2[2]);
259 T k1 = norm(b);
260 return (k0 < 1.0) ? (k0 - 1.0) * util::min(util::min(r[0], r[1]), r[2])
261 : k0 * (k0 - 1.0) / k1;
262}

References olb::util::min(), and olb::norm().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ elongation()

template<typename T , bool symmetryCheck = true>
 T olb::sdf::elongation ( std::function< T(const Vector< T, 3 > &)> sdf, const Vector< T, 3 > & p, const Vector< T, 3 > & h, const Vector< T, 3 > & center = (T(0)) )

Elongation splits the object in 2 (4 or 8) parts, moves them apart and connects them again The object has to be placed in the origin of the coodinate system.

Symmetry is required so that the splitted parts are symmetric (check can be disabled)

Parameters
 sdf signed Distance Function of the object which is altered p point for which the distance to the surface is calculated h vector containing the information how far the splitted parts are moved apart center vector containing the center, to shift the object to the origin of the coordinate system for the calculation of the elongation

Definition at line 386 of file sdf.h.

389{
390 Vector<T, 3> q = abs(p - center) - h;
391 Vector<T, 3> p_elong = p - center;
392 // elongation requires symmetry e.g. for elongation in x --> plane of symmetry = YZ-plane
393 Vector<bool, 3> sdfIsSymmetric;
394 if constexpr (symmetryCheck) {
395 sdfIsSymmetric = isSymmetric(sdf, center);
396 }
397
398 if (h[0] != 0) {
399 p_elong[0] = util::max(q[0], 0.);
400 if constexpr (symmetryCheck) {
401 if (!sdfIsSymmetric[0]) {
402 std::cout << "Warning: symmetry in x is not met" << std::endl;
403 }
404 }
405 }
406
407 if (h[1] != 0) {
408 p_elong[1] = util::max(q[1], 0.);
409 if constexpr (symmetryCheck) {
410 if (!sdfIsSymmetric[1]) {
411 std::cout << "Warning: symmetry in y is not met" << std::endl;
412 }
413 }
414 }
415
416 if (h[2] != 0) {
417 p_elong[2] = util::max(q[2], 0.);
418 if constexpr (symmetryCheck) {
419 if (!sdfIsSymmetric[2]) {
420 std::cout << "Warning: symmetry in z is not met" << std::endl;
421 }
422 }
423 }
424
425 // Second term needed in case of 3D-Elongation if all parts of Vector q are negative
426 return sdf(p_elong + center) + util::min(util::max({q[0], q[1], q[2]}), 0.);
427}
constexpr int q() any_platform
Vector< bool, 3 > isSymmetric(std::function< T(const Vector< T, 3 > &)> sdf, Vector< T, 3 > center) any_platform
A rough test for symmetry.
Definition sdf.h:65

References olb::abs(), isSymmetric(), olb::util::max(), and olb::util::min().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ evalSolidVolumeFraction()

template<typename T >
 bool olb::sdf::evalSolidVolumeFraction ( T output[], T signedDist, T eps )

Definition at line 453 of file sdf.h.

454{
455 T const halfEps = .5 * eps;
456 if (signedDist <= -halfEps) {
457 output[0] = 1.;
458 return true;
459 }
460 else if (signedDist < halfEps) {
461 output[0] = signedDistanceToPorosity(signedDist, eps);
462 return true;
463 }
464 output[0] = 0.;
465 return false;
466}

References signedDistanceToPorosity().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ flip()

template<typename T >
 Vector< T, 3 > olb::sdf::flip ( Vector< T, 3 > p )

Definition at line 305 of file sdf.h.

306{
307 return {p[1], p[0], p[2]};
308}

## ◆ intersection()

template<typename T >
 T olb::sdf::intersection ( T a, T b )

Volume which is shared by a and b creates a new object.

The returned distance is not exact if the signed Distance of both objects points to the part of the surface which is removed for creating the combined object

Parameters
 a signed Distance of the first object b signed Distance of the second object

Definition at line 341 of file sdf.h.

342{
343 return util::max(a, b);
344}

References olb::util::max().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ isSymmetric()

template<typename T >
 Vector< bool, 3 > olb::sdf::isSymmetric ( std::function< T(const Vector< T, 3 > &)> sdf, Vector< T, 3 > center )

A rough test for symmetry.

Definition at line 65 of file sdf.h.

67{
69
70 isSymmetric[0] = sdf(Vector<T, 3> {1., 1., 1.} + center) ==
71 sdf(Vector<T, 3> {-1., 1., 1.} + center) &&
72 sdf(Vector<T, 3> {1., -1., 1.} + center) ==
73 sdf(Vector<T, 3> {-1., -1., 1.} + center) &&
74 sdf(Vector<T, 3> {1., 1., -1.} + center) ==
75 sdf(Vector<T, 3> {-1., 1., -1.} + center) &&
76 sdf(Vector<T, 3> {1., -1., -1.} + center) ==
77 sdf(Vector<T, 3> {-1., -1., -1.} + center);
78 isSymmetric[1] = sdf(Vector<T, 3> {1., 1., 1.} + center) ==
79 sdf(Vector<T, 3> {1., -1., 1.} + center) &&
80 sdf(Vector<T, 3> {-1., 1., 1.} + center) ==
81 sdf(Vector<T, 3> {-1., -1., 1.} + center) &&
82 sdf(Vector<T, 3> {1., 1., -1.} + center) ==
83 sdf(Vector<T, 3> {1., -1., -1.} + center) &&
84 sdf(Vector<T, 3> {-1., 1., -1.} + center) ==
85 sdf(Vector<T, 3> {-1., -1., -1.} + center);
86 isSymmetric[2] = sdf(Vector<T, 3> {1., 1., 1.} + center) ==
87 sdf(Vector<T, 3> {1., 1., -1.} + center) &&
88 sdf(Vector<T, 3> {-1., 1., 1.} + center) ==
89 sdf(Vector<T, 3> {-1., 1., -1.} + center) &&
90 sdf(Vector<T, 3> {1., -1., 1.} + center) ==
91 sdf(Vector<T, 3> {1., -1., -1.} + center) &&
92 sdf(Vector<T, 3> {-1., -1., 1.} + center) ==
93 sdf(Vector<T, 3> {-1., -1., -1.} + center);
94
95 return isSymmetric;
96}

References isSymmetric().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ mix()

template<typename T >
 T olb::sdf::mix ( T a, T b, T h )

Definition at line 44 of file sdf.h.

45{
46 return b * (1.0 - h) + a * h;
47}
Here is the caller graph for this function:

## ◆ rounding()

template<typename T >
 T olb::sdf::rounding ( T a, T r )

Computes a layer of a constant thickness around the surface.

Parameters
 a signed Distance of the object r layer thickness

Definition at line 372 of file sdf.h.

373{
374 return a - r;
375}
Here is the caller graph for this function:

## ◆ scale()

template<typename T , unsigned D>
 T olb::sdf::scale ( std::function< T(const Vector< T, D > &)> sdf, const Vector< T, D > & p, T s, const Vector< T, D > & center = (T(0)) )

Function to scale a geometry The object has to be placed in the origin of the coodinate system.

Parameters
 sdf signed Distance Function of the object which is altered p point for which the distance to the surface is calculated s scaling factor center vector containing the center, to shift the object to the origin of the coordinate system for the calculation of the elongation

Definition at line 437 of file sdf.h.

439{
440 return sdf((p - center) / s) * s;
441}
Here is the caller graph for this function:

## ◆ signedDistanceToPorosity()

template<typename T >
 T olb::sdf::signedDistanceToPorosity ( T signedDist, T eps )

Converts signed distance to values for the smooth epsilon boundary.

Definition at line 446 of file sdf.h.

447{
448 const T d = signedDist + .5 * eps;
449 return util::pow(util::cos(M_PI2 * d / eps), 2);
450}
#define M_PI2
Definition sdf.h:36

References olb::util::cos(), M_PI2, and olb::util::pow().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ smooth_intersection()

template<typename T >
 T olb::sdf::smooth_intersection ( T a, T b, T k )

Definition at line 361 of file sdf.h.

362{
363 T h = clamp(0.5 - 0.5 * (b - a) / k, 0.0, 1.0);
364 return mix(b, a, h) + k * h * (1.0 - h);
365}
T mix(T a, T b, T h) any_platform
Definition sdf.h:44

References clamp(), and mix().

Here is the call graph for this function:

## ◆ smooth_subtraction()

template<typename T >
 T olb::sdf::smooth_subtraction ( T a, T b, T k )

Definition at line 354 of file sdf.h.

355{
356 T h = clamp(0.5 - 0.5 * (b + a) / k, 0.0, 1.0);
357 return mix(b, -a, h) + k * h * (1.0 - h);
358}

References clamp(), and mix().

Here is the call graph for this function:

## ◆ smooth_union()

template<typename T >
 T olb::sdf::smooth_union ( T a, T b, T k )

Definition at line 347 of file sdf.h.

348{
349 T h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);
350 return mix(a, b, h) - k * h * (1.0 - h);
351}

References clamp(), and mix().

Here is the call graph for this function:

## ◆ solidAngle()

template<typename T >
 T olb::sdf::solidAngle ( Vector< T, 3 > p, Vector< T, 2 > c, T r )

Exact signed distance to the surface of a solid angle which represents a combination of a cone (axis y=0 to y=r) and a sphere.

Parameters
 p point for which the distance to the surface is calculated c[0] sin of the angle c[1] cos of the angle r radius of the sphere

Definition at line 286 of file sdf.h.

287{
288 Vector<T, 2> q {norm(Vector<T, 2> {p[0], p[2]}), p[1]};
289 T l = norm(q) - r;
290 T m = norm(q - c * clamp(q * c, 0.0, r));
291 return util::max(l, m * util::sign(c[1] * q[0] - c[0] * q[1]));
292}

References clamp(), olb::util::max(), olb::norm(), and olb::util::sign().

Here is the call graph for this function:

## ◆ sphere()

template<typename T , unsigned D>
 T olb::sdf::sphere ( Vector< T, D > p, T r )

Exact signed distance to the surface of circle (in 2D) or sphere (in 3D).

Parameters
 p point for which the distance to the surface is calculated r radius describing the geometry

Definition at line 104 of file sdf.h.

105{
106 return norm(p) - r;
107}

References olb::norm().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ subtraction()

template<typename T >
 T olb::sdf::subtraction ( T a, T b )

Volume of a is subtracted from b.

The returned distance is not exact if the signed Distance of both objects points to the part of the surface which is removed for creating the combined object

Parameters
 a signed Distance of the first object b signed Distance of the second object

Definition at line 317 of file sdf.h.

318{
319 return util::max(-a, b);
320}

References olb::util::max().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ torus()

template<typename T >
 T olb::sdf::torus ( Vector< T, 3 > p, Vector< T, 2 > t )

Exact signed distance to the surface of a torus placed in the XZ-plane of the coordinate system.

Parameters
 p point for which the distance to the surface is calculated t[0] distance center of the tube to center of the torus t[1] radius of the tube

Definition at line 271 of file sdf.h.

272{
273 Vector<T, 2> b {p[0], p[2]};
274 Vector<T, 2> q {norm(b) - t[0], p[1]};
275 return norm(q) - t[1];
276}

References olb::norm().

Here is the call graph for this function:

## ◆ translate()

template<typename T , unsigned D>
 Vector< T, D > olb::sdf::translate ( Vector< T, D > p, Vector< T, D > origin )

Translation: The output of this function is used for the calculation of the signed distance to translated/shifted objects.

Parameters
 p point for which the distance to the surface is calculated origin point to which the object is shifted to

Definition at line 299 of file sdf.h.

300{
301 return p - origin;
302}
Here is the caller graph for this function:

## ◆ triangle()

template<typename T >
 T olb::sdf::triangle ( Vector< T, 2 > p, Vector< T, 2 > a, Vector< T, 2 > b, Vector< T, 2 > c )

Exact signed distance to the surface of two-dimensional triangle.

Parameters
 p point for which the distance to the surface is calculated a vector containing first vertex b vector containing second vertex c vector containing third vertex

Definition at line 143 of file sdf.h.

145{
146 Vector<T, 2> e0 = b - a;
147 Vector<T, 2> v0 = p - a;
148 Vector<T, 2> e1 = c - b;
149 Vector<T, 2> v1 = p - b;
150 Vector<T, 2> e2 = a - c;
151 Vector<T, 2> v2 = p - c;
152 Vector<T, 2> pq0 = v0 - e0 * clamp((v0 * e0) / (e0 * e0), 0., 1.);
153 Vector<T, 2> pq1 = v1 - e1 * clamp((v1 * e1) / (e1 * e1), 0., 1.);
154 Vector<T, 2> pq2 = v2 - e2 * clamp((v2 * e2) / (e2 * e2), 0., 1.);
155 T s = util::sign(e0[0] * e2[1] - e0[1] * e2[0]);
156
157 T dx = util::min(util::min((pq0 * pq0), (pq1 * pq1)), (pq2 * pq2));
158 T dy = util::min(util::min(s * (v0[0] * e0[1] - v0[1] * e0[0]),
159 s * (v1[0] * e1[1] - v1[1] * e1[0])),
160 s * (v2[0] * e2[1] - v2[1] * e2[0]));
161 return -util::sqrt(dx) * util::sign(dy);
162}

References clamp(), olb::util::min(), olb::util::sign(), and olb::util::sqrt().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ unify()

template<typename T >
 T olb::sdf::unify ( T a, T b )

Volume of a and volume of b are combined as a new object.

The returned distance is not exact if the signed Distance of both objects points to the part of the surface which is removed for creating the combined object

Parameters
 a signed Distance of the first object b signed Distance of the second object

Definition at line 329 of file sdf.h.

330{
331 return util::min(a, b);
332}

References olb::util::min().

Here is the call graph for this function:
Here is the caller graph for this function: