12#ifndef PBAT_GEOMETRY_SDF_UNARYNODE_H
13#define PBAT_GEOMETRY_SDF_UNARYNODE_H
16#include "pbat/HostDevice.h"
18#include "pbat/math/linalg/mini/BinaryOperations.h"
19#include "pbat/math/linalg/mini/UnaryOperations.h"
38template <common::CArithmetic TScalar>
70template <common::CArithmetic TScalar>
97 return sdf(pp) + min(max(q(0), max(q(1), q(2))),
ScalarType(0));
105template <common::CArithmetic TScalar>
126 template <
class FSdf>
137template <common::CArithmetic TScalar>
158 template <
class FSdf>
162 return abs(
sdf(p)) -
t;
170template <common::CArithmetic TScalar>
181 template <
class FSdf>
195template <common::CArithmetic TScalar>
221 template <
class FSdf>
226 clamp(round(p(0) /
s), -
l(0),
l(0)),
227 clamp(round(p(1) /
s), -
l(1),
l(1)),
228 clamp(round(p(2) /
s), -
l(2),
l(2))};
238template <common::CArithmetic TScalar>
259 template <
class FSdf>
263 ScalarType sp = 2 * std::numbers::pi_v<ScalarType> /
n;
272 Vec3<ScalarType> r1{cosa1 * p(0) + sina1 * p(1), -sina1 * p(0) + cosa1 * p(1), p(2)};
273 Vec3<ScalarType> r2{cosa2 * p(0) + sina2 * p(1), -sina2 * p(0) + cosa2 * p(1), p(2)};
274 return min(
sdf(r1),
sdf(r2));
282template <common::CArithmetic TScalar>
305 template <
class FSdf>
311 g(0)*sin(
f(0)*p(0)) *
312 g(1)*sin(
f(1)*p(1)) *
323template <common::CArithmetic TScalar>
344 template <
class FSdf>
359template <common::CArithmetic TScalar>
380 template <
class FSdf>
This file defines common type definitions used in the SDF module.
Concepts for common types.
Namespace for signed distance functions (SDFs) and related operations.
Definition BinaryNode.cpp:3
math::linalg::mini::SVector< TScalar, 3 > Vec3
3D vector type
Definition TypeDefs.h:23
math::linalg::mini::Zeros< TScalar, 3, 1 > Zero3
3D zero vector type
Definition TypeDefs.h:38
Bend()=default
Default constructor.
PBAT_HOST_DEVICE ScalarType Eval(Vec3< ScalarType > const &p, FSdf &&sdf) const
Evaluate the signed distance function at a point.
Definition UnaryNode.h:381
TScalar ScalarType
Scalar type.
Definition UnaryNode.h:362
Bend(ScalarType k_)
Construct a new Bend object.
Definition UnaryNode.h:372
ScalarType k
Bend factor.
Definition UnaryNode.h:363
Bump(Vec3< ScalarType > const &f_, Vec3< ScalarType > const &g_)
Construct a new Bump object.
Definition UnaryNode.h:297
Bump()=default
Default constructor.
Vec3< ScalarType > f
Frequency along each axis.
Definition UnaryNode.h:286
TScalar ScalarType
Scalar type.
Definition UnaryNode.h:285
Vec3< ScalarType > g
Amplitude of the wave displacement.
Definition UnaryNode.h:287
PBAT_HOST_DEVICE ScalarType Eval(Vec3< ScalarType > const &p, FSdf &&sdf) const
Evaluate the signed distance function at a point.
Definition UnaryNode.h:306
Vec3< ScalarType > h
Elongation vector.
Definition UnaryNode.h:74
Elongate(Vec3< ScalarType > const &h_)
Construct a new Elongate object.
Definition UnaryNode.h:83
TScalar ScalarType
Scalar type.
Definition UnaryNode.h:73
PBAT_HOST_DEVICE ScalarType Eval(Vec3< ScalarType > const &p, FSdf &&sdf) const
Evaluate the signed distance function at a point.
Definition UnaryNode.h:92
Elongate()=default
Default constructor.
Onion()=default
Default constructor.
ScalarType t
Onion thickness.
Definition UnaryNode.h:141
PBAT_HOST_DEVICE ScalarType Eval(Vec3< ScalarType > const &p, FSdf &&sdf) const
Evaluate the signed distance function at a point.
Definition UnaryNode.h:159
Onion(ScalarType t_)
Construct a new Onion object.
Definition UnaryNode.h:150
TScalar ScalarType
Scalar type.
Definition UnaryNode.h:140
TScalar ScalarType
Scalar type.
Definition UnaryNode.h:198
ScalarType s
Uniform repetition spacing.
Definition UnaryNode.h:199
Repeat(ScalarType s_, Vec3< ScalarType > const &l_)
Construct a new Repeat object.
Definition UnaryNode.h:213
PBAT_HOST_DEVICE ScalarType Eval(Vec3< ScalarType > const &p, FSdf &&sdf) const
Evaluate the signed distance function at a point.
Definition UnaryNode.h:222
Repeat()=default
Default constructor.
Vec3< ScalarType > l
Half number of repetitions along each axis.
Definition UnaryNode.h:200
RotationalRepeat()=default
Default constructor.
ScalarType n
Number of repetitions.
Definition UnaryNode.h:242
TScalar ScalarType
Scalar type.
Definition UnaryNode.h:241
PBAT_HOST_DEVICE ScalarType Eval(Vec3< ScalarType > const &p, FSdf &&sdf) const
Evaluate the signed distance function at a point.
Definition UnaryNode.h:260
RotationalRepeat(ScalarType n_)
Construct a new RotationalRepeat object.
Definition UnaryNode.h:251
Round(ScalarType r_)
Construct a new Round object.
Definition UnaryNode.h:118
TScalar ScalarType
Scalar type.
Definition UnaryNode.h:108
PBAT_HOST_DEVICE ScalarType Eval(Vec3< ScalarType > const &p, FSdf &&sdf) const
Evaluate the signed distance function at a point.
Definition UnaryNode.h:127
ScalarType r
Rounding radius.
Definition UnaryNode.h:109
Round()=default
Default constructor.
Scale()=default
Default constructor.
ScalarType s
Scaling factor.
Definition UnaryNode.h:42
Scale(ScalarType s_)
Construct a new Scale object.
Definition UnaryNode.h:51
PBAT_HOST_DEVICE ScalarType Eval(Vec3< ScalarType > const &p, FSdf &&sdf) const
Evaluate the signed distance function at a point.
Definition UnaryNode.h:60
TScalar ScalarType
Scalar type.
Definition UnaryNode.h:41
Symmetrization operation along the x axis.
Definition UnaryNode.h:172
TScalar ScalarType
Scalar type.
Definition UnaryNode.h:173
PBAT_HOST_DEVICE ScalarType Eval(Vec3< ScalarType > p, FSdf &&sdf) const
Evaluate the signed distance function at a point.
Definition UnaryNode.h:182
TScalar ScalarType
Scalar type.
Definition UnaryNode.h:326
ScalarType k
Twist factor.
Definition UnaryNode.h:327
PBAT_HOST_DEVICE ScalarType Eval(Vec3< ScalarType > const &p, FSdf &&sdf) const
Evaluate the signed distance function at a point.
Definition UnaryNode.h:345
Twist()=default
Default constructor.
Twist(ScalarType k_)
Construct a new Twist object.
Definition UnaryNode.h:336
Base struct for all unary nodes.
Definition UnaryNode.h:31