48 [[nodiscard]]
inline double op_union(
double d1,
double d2) {
49 return std::min(d1, d2);
71 return std::max(d1, d2);
95 return std::max(d1, -d2);
127 if (k <= 0.0)
return std::min(d1, d2);
128 double h = std::clamp(0.5 + 0.5 * (d1 - d2) / k, 0.0, 1.0);
129 return d1 * (1.0 - h) + d2 * h - k * h * (1.0 - h);
150 if (k <= 0.0)
return std::max(d1, d2);
151 double h = std::clamp(0.5 - 0.5 * (d1 - d2) / k, 0.0, 1.0);
152 return d1 * (1.0 - h) + d2 * h + k * h * (1.0 - h);
173 if (k <= 0.0)
return std::max(d1, -d2);
174 double h = std::clamp(0.5 - 0.5 * (d2 + d1) / k, 0.0, 1.0);
175 return d1 * (1.0 - h) + (-d2) * h + k * h * (1.0 - h);
200 [[nodiscard]]
inline double op_round(
double d,
double r) {
223 [[nodiscard]]
inline double op_onion(
double d,
double thickness) {
224 return std::abs(d) - thickness;
252 auto wrap = [](
double v,
double c) {
253 return c > 0.0 ? v - c * std::round(v / c) : v;
255 return Point3D(wrap(p.x(), cell.x()),
256 wrap(p.y(), cell.y()),
257 wrap(p.z(), cell.z()));
280 return Point3D(offset + std::abs(p.x() - offset), p.y(), p.z());
300 return Point3D(p.x(), std::abs(p.y()), p.z());
314 return Point3D(p.x(), p.y(), std::abs(p.z()));
369 double c = std::cos(-angle_rad);
370 double s = std::sin(-angle_rad);
371 return Point3D(p.x() * c - p.z() * s, p.y(), p.x() * s + p.z() * c);
398 return Point3D(p.x() / s.x(), p.y() / s.y(), p.z() / s.z());
427 double c = std::cos(amount * p.y());
428 double s = std::sin(amount * p.y());
429 return Point3D(p.x() * c - p.z() * s, p.y(), p.x() * s + p.z() * c);
458 double c = std::cos(k * p.x());
459 double s = std::sin(k * p.x());
460 return Point3D(c * p.x() - s * p.y(), s * p.x() + c * p.y(), p.z());
489 q.x() > 0.0 ? p.x() - std::copysign(h.x(), p.x()) : 0.0,
490 q.y() > 0.0 ? p.y() - std::copysign(h.y(), p.y()) : 0.0,
491 q.z() > 0.0 ? p.z() - std::copysign(h.z(), p.z()) : 0.0
516 double c = std::cos(k * p.x());
517 double s = std::sin(k * p.x());
518 return Point3D(p.x(), p.y() * c - p.z() * s, p.y() * s + p.z() * c);
546 double amplitude,
double frequency) {
547 double noise = std::sin(p.x() * frequency) *
548 std::sin(p.y() * frequency) *
549 std::sin(p.z() * frequency);
550 return d + amplitude * noise;
foundation::Vector3D Vector3D
双精度三维向量(重新导出)
foundation::Point3D Point3D
双精度三维点(重新导出)
double op_intersection(double d1, double d2)
布尔交集: A ∩ B
Point3D op_rotate(const Point3D &p, double angle_rad)
绕 Y 轴旋转(逆变换)
Point3D op_scale(const Point3D &p, const Point3D &s)
非均匀缩放(逆变换)
double op_difference(double d1, double d2)
布尔差集: A \ B
Point3D op_twist(const Point3D &p, double amount)
绕 Y 轴的扭曲变换
Point3D op_cheap_bend(const Point3D &p, double k)
简化弯曲变换(绕 X 轴弯曲 YZ 平面)
double op_onion(double d, double thickness)
洋葱皮/壳层修饰: 取绝对值后减去厚度
Point3D op_bend(const Point3D &p, double k)
弯曲变换(绕 Z 轴弯曲 XZ 平面)
Point3D op_mirror_y(const Point3D &p)
镜像对称(Y=0 平面)
Point3D op_repeat(const Point3D &p, const Point3D &cell)
无限重复(周期复制)
double op_union(double d1, double d2)
布尔并集: A ∪ B
double op_smooth_difference(double d1, double d2, double k)
平滑差集(带混合过渡)
Point3D op_elongate(const Point3D &p, const Point3D &h)
拉伸/压扁域变形(消除拉伸方向上的内部体积)
Point3D op_mirror_z(const Point3D &p)
镜像对称(Z=0 平面)
Point3D op_mirror_x(const Point3D &p, double offset=0.0)
镜像对称(X=0 平面),可选偏移
Point3D op_translate(const Point3D &p, const Point3D &offset)
空间平移(逆变换)
double op_displace(double d, const Point3D &p, double amplitude, double frequency)
正弦波位移扰动
double op_round(double d, double r)
圆角偏移: 将等值面向外扩展 r 单位
double op_smooth_union(double d1, double d2, double k)
平滑并集(带混合过渡)
double op_smooth_intersection(double d1, double d2, double k)
平滑交集(带混合过渡)