Lagrange
Loading...
Searching...
No Matches
SweepOptions< Scalar > Class Template Reference

Configuration class for sweep operations on 3D geometry. More...

#include <lagrange/primitive/SweepOptions.h>

Public Types

using Point = Eigen::Matrix<Scalar, 1, 3>
 
using Frame = Eigen::Matrix<Scalar, 3, 3>
 
using Transform = Eigen::Transform<Scalar, 3, Eigen::AffineCompact>
 

Public Member Functions

std::vector< Transform > sample_transforms () const
 Samples transformation matrices along the sweep path.
 
Transform sample_transform (Scalar t) const
 Samples the transformation matrix at a specific parameter t.
 
std::vector< Scalarsample_offsets () const
 Samples offset values along the sweep path.
 
Scalar sample_offset (Scalar t) const
 Samples the offset value at a specific parameter t.
 
void set_pivot (const Point &pivot)
 Sets the pivot point for the sweep transformation.
 
const Point & get_pivot () const
 Gets the current pivot point.
 
void set_normalization (const Transform &normalization)
 Sets the normalization transformation applied to the sweep.
 
const Transform & get_normalization () const
 Gets the current normalization transformation.
 
void set_num_samples (size_t num_samples)
 Sets the number of samples to use along the sweep path.
 
size_t get_num_samples () const
 Gets the current number of samples.
 
void set_periodic (bool periodic)
 Sets whether the sweep should be treated as periodic.
 
bool is_periodic () const
 Checks if the sweep is configured as periodic.
 
void set_domain (std::array< Scalar, 2 > domain)
 Sets the parameter domain for sampling transformations.
 
const std::array< Scalar, 2 > & get_domain () const
 Gets the current parameter domain for sampling transformations.
 
bool is_closed () const
 Checks if the sweep is closed.
 
void set_position_function (std::function< Point(Scalar)> fn)
 Sets the position function that defines the sweep path.
 
bool has_positions () const
 Checks if a position function has been set.
 
void set_frame_function (std::function< Frame(Scalar)> fn)
 Sets the frame function that defines orientation along the sweep path.
 
bool has_frames () const
 Checks if a frame function has been set.
 
void set_twist_function (std::function< Scalar(Scalar)> fn)
 Sets the twist function that defines rotation around the sweep path.
 
bool has_twists () const
 Checks if a twist function has been set.
 
void set_taper_function (std::function< Scalar(Scalar)> fn)
 Sets the taper function that defines scaling along the sweep path.
 
bool has_tapers () const
 Checks if a taper function has been set.
 
void set_offset_function (std::function< Scalar(Scalar)> fn)
 Sets the offset function that defines offsets along the sweep path.
 
bool has_offsets () const
 Checks if an offset function has been set.
 

Static Public Member Functions

static SweepOptions< Scalarlinear_sweep (const Point &from, const Point &to, bool follow_tangent=true)
 Creates a linear sweep configuration from one point to another.
 
static SweepOptions< Scalarcircular_sweep (const Point &p, const Point &axis, Scalar angle=static_cast< Scalar >(2 *lagrange::internal::pi), bool follow_tangent=true)
 Creates a circular sweep configuration around a specified axis.
 

Protected Attributes

Point m_pivot = Point::Zero()
 The pivot point for sweep transformations.
 
Transform m_normalization = Transform::Identity()
 The normalization transformation applied to the sweep.
 
size_t m_num_samples = 16
 The number of samples along the sweep path.
 
bool m_periodic = false
 Whether the sweep is periodic (closed loop)
 
std::array< Scalar, 2 > m_domain = {0, 1}
 The parameter domain for sampling transformations.
 
std::function< Point(Scalar)> m_position_fn
 Function defining positions along the sweep path.
 
std::function< Frame(Scalar)> m_frame_fn
 Function defining frame orientations along the sweep path.
 
std::function< Scalar(Scalar)> m_twist_fn
 Function defining twist angles along the sweep path.
 
std::function< Scalar(Scalar)> m_taper_fn
 Function defining taper scale factors along the sweep path.
 
std::function< Scalar(Scalar)> m_offset_fn
 Function defining offsets along the sweep path.
 

Detailed Description

template<typename Scalar>
class lagrange::primitive::SweepOptions< Scalar >

Configuration class for sweep operations on 3D geometry.

SweepOptions provides a flexible framework for defining sweep transformations that can be applied to 2D profiles to generate 3D geometry. It supports various types of sweeps including linear and circular sweeps, with additional control over frame orientation, twist, taper, and offset along the sweep path.

Template Parameters
ScalarThe scalar type used for computations (e.g., float, double).

Member Function Documentation

◆ linear_sweep()

template<typename Scalar>
SweepOptions< Scalar > linear_sweep ( const Point & from,
const Point & to,
bool follow_tangent = true )
static

Creates a linear sweep configuration from one point to another.

Parameters
fromThe starting point of the linear sweep relative to the pivot.
toThe ending point of the linear sweep relative to the pivot.
follow_tangentWhether the sweep frame should follow the tangent direction.
Returns
A SweepOptions configured for linear sweep.

◆ circular_sweep()

template<typename Scalar>
SweepOptions< Scalar > circular_sweep ( const Point & p,
const Point & axis,
Scalar angle = static_cast<Scalar>(2 * lagrange::internal::pi),
bool follow_tangent = true )
static

Creates a circular sweep configuration around a specified axis.

Parameters
pA point defining a point on the circular sweep path relative to the pivot.
axisThe axis of rotation for the circular sweep (should be normalized).
angleThe angle of the circular sweep in radians (default is 2 * pi for a full circle).
follow_tangentWhether the sweep frame should follow the tangent direction.
Returns
A SweepOptions configured for circular sweep.
Note
The sweep setting will be periodic if the angle is a non-zero multiple of 2 * pi.
Warning
The axis vector should be normalized for predictable results.

Example:

Point(1, 0, 0), // radius 1 circle in XY plane
Point(0, 0, 1) // around Z axis
);
static SweepOptions< Scalar > circular_sweep(const Point &p, const Point &axis, Scalar angle=static_cast< Scalar >(2 *lagrange::internal::pi), bool follow_tangent=true)
Creates a circular sweep configuration around a specified axis.
Definition SweepOptions.cpp:149

◆ sample_transforms()

template<typename Scalar>
std::vector< typename SweepOptions< Scalar >::Transform > sample_transforms ( ) const

Samples transformation matrices along the sweep path.

Returns
A vector of transformation matrices with size equal to get_num_samples().

◆ sample_transform()

template<typename Scalar>
SweepOptions< Scalar >::Transform sample_transform ( Scalar t) const

Samples the transformation matrix at a specific parameter t.

Parameters
tThe parameter value in the domain.
Returns
The transformation matrix at the specified parameter t.

◆ sample_offsets()

template<typename Scalar>
std::vector< Scalar > sample_offsets ( ) const

Samples offset values along the sweep path.

Returns
A vector of offset values sampled along the sweep path.

◆ sample_offset()

template<typename Scalar>
Scalar sample_offset ( Scalar t) const

Samples the offset value at a specific parameter t.

Parameters
tThe parameter value in the domain.
Returns
The offset value at the specified parameter t.

◆ set_pivot()

template<typename Scalar>
void set_pivot ( const Point & pivot)
inline

Sets the pivot point for the sweep transformation.

Pivot point is the relative origin for the sweep transformations. It is typically set at the center of the profile being swept. By default, it is set to the origin (0, 0, 0).

Parameters
pivotThe pivot point to use for transformations.
See also
get_pivot, set_normalization

◆ get_pivot()

template<typename Scalar>
const Point & get_pivot ( ) const
inline

Gets the current pivot point.

Returns
The current pivot point.

◆ set_normalization()

template<typename Scalar>
void set_normalization ( const Transform & normalization)
inline

Sets the normalization transformation applied to the sweep.

Normalization is typically used to normalize the profile curve to fit in a unit box centered at the origin. All sweep transformations will be relative to this normalized space. The default normalization is the identity transformation, meaning no normalization is applied.

Parameters
normalizationThe normalization transformation to apply.
Note
The transformation should be invertible for proper sweep generation.
Warning
Transformations with zero determinant will cause undefined behavior.

◆ get_normalization()

template<typename Scalar>
const Transform & get_normalization ( ) const
inline

Gets the current normalization transformation.

Returns
The current normalization transformation.

◆ set_num_samples()

template<typename Scalar>
void set_num_samples ( size_t num_samples)
inline

Sets the number of samples to use along the sweep path.

The default number of samples is 16.

Parameters
num_samplesThe number of samples (must be at least 2).
Exceptions
std::runtime_errorif num_samples is less than 2.

◆ get_num_samples()

template<typename Scalar>
size_t get_num_samples ( ) const
inline

Gets the current number of samples.

Returns
The current number of samples.

◆ set_periodic()

template<typename Scalar>
void set_periodic ( bool periodic)
inline

Sets whether the sweep should be treated as periodic.

A sweep is periodic (with period 1) if all transformation functions satisfy: f(t) = f(t + 1) for any t, where f represents position, frame, twist, taper, or offset functions. This is useful for closed sweep paths like circles or loops.

Parameters
periodicTrue if the sweep is periodic (e.g., closed loops).
Note
When periodic=true, sampling will ensure proper connectivity at domain boundaries.

◆ is_periodic()

template<typename Scalar>
bool is_periodic ( ) const
inline

Checks if the sweep is configured as periodic.

Returns
True if the sweep is periodic, false otherwise.

◆ set_domain()

template<typename Scalar>
void set_domain ( std::array< Scalar, 2 > domain)
inline

Sets the parameter domain for sampling transformations.

Parameters
domainA 2-element array defining the start and end of the parameter domain.
Note
The domain must satisfy domain[0] < domain[1].

◆ get_domain()

template<typename Scalar>
const std::array< Scalar, 2 > & get_domain ( ) const
inline

Gets the current parameter domain for sampling transformations.

Returns
A 2-element array representing the start and end of the parameter domain.

◆ is_closed()

template<typename Scalar>
bool is_closed ( ) const
inline

Checks if the sweep is closed.

A sweep is considered closed if it is periodic and the total length of the sweep path is equal to 1 up to floating point error.

Returns
True if the sweep is closed, false otherwise.

◆ set_position_function()

template<typename Scalar>
void set_position_function ( std::function< Point(Scalar)> fn)
inline

Sets the position function that defines the sweep path.

Parameters
fnA function that maps parameter values to 3D positions along the sweep path.

◆ has_positions()

template<typename Scalar>
bool has_positions ( ) const
inline

Checks if a position function has been set.

Returns
True if a position function is defined, false otherwise.

◆ set_frame_function()

template<typename Scalar>
void set_frame_function ( std::function< Frame(Scalar)> fn)
inline

Sets the frame function that defines orientation along the sweep path.

The frame function defines a local coordinate system at each point along the sweep path. Each frame should be orthonormal with determinant +1. The last column/basis of the frame matrix should represent the tangent vector of the sweep path at that point.

Parameters
fnA function that maps parameter values in [0,1] to 3x3 orthonormal matrices.

◆ has_frames()

template<typename Scalar>
bool has_frames ( ) const
inline

Checks if a frame function has been set.

Returns
True if a frame function is defined, false otherwise.

◆ set_twist_function()

template<typename Scalar>
void set_twist_function ( std::function< Scalar(Scalar)> fn)
inline

Sets the twist function that defines rotation around the sweep path.

The twist function applies additional rotation around the sweep path tangent vector. Twist values are interpreted as radians of rotation.

Parameters
fnA function that maps parameter values in [0,1] to twist angles in radians.

◆ has_twists()

template<typename Scalar>
bool has_twists ( ) const
inline

Checks if a twist function has been set.

Returns
True if a twist function is defined, false otherwise.

◆ set_taper_function()

template<typename Scalar>
void set_taper_function ( std::function< Scalar(Scalar)> fn)
inline

Sets the taper function that defines scaling along the sweep path.

The taper function applies uniform scaling to the profile at each point along the sweep. A taper value of 1.0 means no scaling, values > 1.0 expand, values < 1.0 contract.

Parameters
fnA function that maps parameter values in [0,1] to positive scale factors.

◆ has_tapers()

template<typename Scalar>
bool has_tapers ( ) const
inline

Checks if a taper function has been set.

Returns
True if a taper function is defined, false otherwise.

◆ set_offset_function()

template<typename Scalar>
void set_offset_function ( std::function< Scalar(Scalar)> fn)
inline

Sets the offset function that defines offsets along the sweep path.

Parameters
fnA function that maps parameter values to offset distances.

◆ has_offsets()

template<typename Scalar>
bool has_offsets ( ) const
inline

Checks if an offset function has been set.

Returns
True if an offset function is defined, false otherwise.

The documentation for this class was generated from the following files: