EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_AnalyticRayForms.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
15#ifndef EBGEOMETRY_ANALYTICRAYFORMS_HPP
16#define EBGEOMETRY_ANALYTICRAYFORMS_HPP
17
18// Our includes
20#include "EBGeometry_Ray.hpp"
21
22namespace EBGeometry {
23
28template <class T>
29struct RayForm<PlaneSDF<T>>
30{
40 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
41 static inline HitT<T>
43 const PlaneSDF<T>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
44
56 static inline void
57 spans(const PlaneSDF<T>& a_shape,
58 const RayT<T>& a_ray,
59 T a_tMin,
60 T a_tMax,
61 const RayOptions<T>& a_options,
62 bool a_firstOnly,
63 RaySpansT<T>& a_spans) noexcept;
64};
65
70template <class T>
72{
82 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
83 static inline HitT<T>
85 const SphereSDF<T>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
86
98 static inline void
99 spans(const SphereSDF<T>& a_shape,
100 const RayT<T>& a_ray,
101 T a_tMin,
102 T a_tMax,
103 const RayOptions<T>& a_options,
104 bool a_firstOnly,
105 RaySpansT<T>& a_spans) noexcept;
106};
107
112template <class T>
113struct RayForm<BoxSDF<T>>
114{
124 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
125 static inline HitT<T>
126 firstHit(const BoxSDF<T>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
127
139 static inline void
140 spans(const BoxSDF<T>& a_shape,
141 const RayT<T>& a_ray,
142 T a_tMin,
143 T a_tMax,
144 const RayOptions<T>& a_options,
145 bool a_firstOnly,
146 RaySpansT<T>& a_spans) noexcept;
147};
148
153template <class T>
155{
165 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
166 static inline HitT<T>
168 const CylinderSDF<T>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
169
181 static inline void
182 spans(const CylinderSDF<T>& a_shape,
183 const RayT<T>& a_ray,
184 T a_tMin,
185 T a_tMax,
186 const RayOptions<T>& a_options,
187 bool a_firstOnly,
188 RaySpansT<T>& a_spans) noexcept;
189};
190
195template <class T>
197{
207 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
208 static inline HitT<T>
210 const RayT<T>& a_ray,
211 T a_tMin,
212 T a_tMax,
213 const RayOptions<T>& a_options) noexcept;
214
226 static inline void
228 const RayT<T>& a_ray,
229 T a_tMin,
230 T a_tMax,
231 const RayOptions<T>& a_options,
232 bool a_firstOnly,
233 RaySpansT<T>& a_spans) noexcept;
234};
235
240template <class T>
242{
252 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
253 static inline HitT<T>
255 const CapsuleSDF<T>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
256
268 static inline void
269 spans(const CapsuleSDF<T>& a_shape,
270 const RayT<T>& a_ray,
271 T a_tMin,
272 T a_tMax,
273 const RayOptions<T>& a_options,
274 bool a_firstOnly,
275 RaySpansT<T>& a_spans) noexcept;
276};
277
282template <class T>
284{
294 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
295 static inline HitT<T>
297 const EllipsoidSDF<T>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
298
310 static inline void
311 spans(const EllipsoidSDF<T>& a_shape,
312 const RayT<T>& a_ray,
313 T a_tMin,
314 T a_tMax,
315 const RayOptions<T>& a_options,
316 bool a_firstOnly,
317 RaySpansT<T>& a_spans) noexcept;
318};
319
324template <class T>
326{
336 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
337 static inline HitT<T>
339 const CappedConeSDF<T>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
340
352 static inline void
353 spans(const CappedConeSDF<T>& a_shape,
354 const RayT<T>& a_ray,
355 T a_tMin,
356 T a_tMax,
357 const RayOptions<T>& a_options,
358 bool a_firstOnly,
359 RaySpansT<T>& a_spans) noexcept;
360};
361
366template <class T>
368{
378 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
379 static inline HitT<T>
381 const RayT<T>& a_ray,
382 T a_tMin,
383 T a_tMax,
384 const RayOptions<T>& a_options) noexcept;
385
397 static inline void
398 spans(const PolygonPrismSDF<T>& a_shape,
399 const RayT<T>& a_ray,
400 T a_tMin,
401 T a_tMax,
402 const RayOptions<T>& a_options,
403 bool a_firstOnly,
404 RaySpansT<T>& a_spans) noexcept;
405};
406
411template <class T>
412struct RayForm<TubeSDF<T>>
413{
423 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
424 static inline HitT<T>
426 const TubeSDF<T>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
427
439 static inline void
440 spans(const TubeSDF<T>& a_shape,
441 const RayT<T>& a_ray,
442 T a_tMin,
443 T a_tMax,
444 const RayOptions<T>& a_options,
445 bool a_firstOnly,
446 RaySpansT<T>& a_spans) noexcept;
447};
448
453template <class T>
455{
465 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
466 static inline HitT<T>
468 const CutSphereSDF<T>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
469
481 static inline void
482 spans(const CutSphereSDF<T>& a_shape,
483 const RayT<T>& a_ray,
484 T a_tMin,
485 T a_tMax,
486 const RayOptions<T>& a_options,
487 bool a_firstOnly,
488 RaySpansT<T>& a_spans) noexcept;
489};
490
495template <class T>
497{
507 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
508 static inline HitT<T>
510 const WedgeSDF<T>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
511
523 static inline void
524 spans(const WedgeSDF<T>& a_shape,
525 const RayT<T>& a_ray,
526 T a_tMin,
527 T a_tMax,
528 const RayOptions<T>& a_options,
529 bool a_firstOnly,
530 RaySpansT<T>& a_spans) noexcept;
531};
532
533} // namespace EBGeometry
534
535#include "EBGeometry_AnalyticRayFormsImplem.hpp"
536
537#endif
File containing various analytic signed distance fields.
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
Ray queries on any shape: where a ray, or the segment between two points, first crosses its surface (...
Signed distance field for an axis-aligned box (AABB).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:352
Signed distance field for a capped cone (a frustum): a cone cut flat at both ends,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2779
Signed distance field for a capsule (pill shape): a cylinder capped with hemispheres.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1178
Signed distance field for a cut sphere: the part of a sphere above a horizontal plane,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4116
Signed distance field for a finite, flat-capped cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:758
Signed distance field for an ellipsoid with its semi-axes along x, y and z.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2621
Signed distance field for an infinitely long cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1008
Signed distance function for a plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:61
Signed distance field for a regular prism: a regular polygon of n sides, extruded between two end cen...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3294
Signed distance field for a sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:200
Signed distance field for a tube (a pipe): the space between two coaxial cylinders,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3605
Signed distance field for an infinite wedge: a knife edge.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4545
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Where a ray first crosses a surface.
Definition EBGeometry_Ray.hpp:98
static HitT< T > firstHit(const BoxSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the box along a ray.
static void spans(const BoxSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the box over an interval: one span, the box being convex.
static void spans(const CappedConeSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the frustum over an interval: one span, the frustum being convex.
static HitT< T > firstHit(const CappedConeSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the frustum along a ray.
static void spans(const CapsuleSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the capsule over an interval: one span, the capsule being convex.
static HitT< T > firstHit(const CapsuleSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the capsule along a ray.
static HitT< T > firstHit(const CutSphereSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the cut sphere along a ray.
static void spans(const CutSphereSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the cut sphere over an interval: one span, the cut sphere being convex.
static HitT< T > firstHit(const CylinderSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the cylinder along a ray.
static void spans(const CylinderSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the cylinder over an interval: one span, the cylinder being convex.
static HitT< T > firstHit(const EllipsoidSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the ellipsoid along a ray.
static void spans(const EllipsoidSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the ellipsoid over an interval: one span, the ellipsoid being convex.
static void spans(const InfiniteCylinderSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the cylinder over an interval: one span, the cylinder being convex.
static HitT< T > firstHit(const InfiniteCylinderSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the cylinder along a ray.
static void spans(const PlaneSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the plane over an interval: the half-space behind it.
static HitT< T > firstHit(const PlaneSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the plane along a ray.
static HitT< T > firstHit(const PolygonPrismSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the prism along a ray.
static void spans(const PolygonPrismSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the prism over an interval: one span, the prism being convex.
static HitT< T > firstHit(const SphereSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the sphere along a ray.
static void spans(const SphereSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the sphere over an interval: one span, the sphere being convex.
static HitT< T > firstHit(const TubeSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the tube along a ray.
static void spans(const TubeSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the tube over an interval: up to two spans, before and after the hollow.
static HitT< T > firstHit(const WedgeSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the wedge along a ray.
static void spans(const WedgeSDF< T > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the wedge over an interval: one span, the wedge being convex.
How to ray trace a shape directly, instead of marching its signed distance.
Definition EBGeometry_Ray.hpp:401
How a query marches, where a shape has no ray form.
Definition EBGeometry_Ray.hpp:203
Where a ray is inside an object over an interval [t0, t1]: its spans, in order, each from where it en...
Definition EBGeometry_Ray.hpp:296
A ray: the points origin + t * direction.
Definition EBGeometry_Ray.hpp:56