pub trait AxisOperations<Point, Input>{
type Error;
// Required methods
fn contains_point(&self, x: &Input) -> bool;
fn get_index_values(&self) -> Vec<Input>;
fn get_values(&self, x: Input) -> Vec<&Decimal>;
fn get_closest_point(&self, x: &Input) -> Result<&Point, Self::Error>;
fn get_point(&self, x: &Input) -> Option<&Point>;
// Provided method
fn merge_indexes(&self, axis: Vec<Input>) -> Vec<Input> { ... }
}Expand description
Trait for handling axis-based operations on geometric structures.
This trait provides methods for efficient lookups and manipulations of points based on their coordinate values. It is designed to work with both 2D curves and 3D surfaces.
§Type Parameters
Point- The complete point type (Point2D for curves, Point3D for surfaces)Input- The input coordinate type (Decimal for curves, Point2D for surfaces)
Required Associated Types§
Required Methods§
Sourcefn contains_point(&self, x: &Input) -> bool
fn contains_point(&self, x: &Input) -> bool
Sourcefn get_index_values(&self) -> Vec<Input>
fn get_index_values(&self) -> Vec<Input>
Returns a vector of references to all index values in the structure.
For curves, this returns x-coordinates. For surfaces, this returns xy-coordinates.
§Returns
Vec<&Input>- Vector of references to index values
Sourcefn get_values(&self, x: Input) -> Vec<&Decimal>
fn get_values(&self, x: Input) -> Vec<&Decimal>
Sourcefn get_closest_point(&self, x: &Input) -> Result<&Point, Self::Error>
fn get_closest_point(&self, x: &Input) -> Result<&Point, Self::Error>
Finds the closest point to the given coordinate value.
§Arguments
x- The reference coordinate value
§Returns
Result<&Point, Self::Error>- The closest point or an error if no points exist
§Errors
Returns the implementation’s Self::Error (typically an
empty-set variant) when the underlying container holds no
points to compare against.
Provided Methods§
Sourcefn merge_indexes(&self, axis: Vec<Input>) -> Vec<Input>
fn merge_indexes(&self, axis: Vec<Input>) -> Vec<Input>
Merges the index values from the current structure with an additional set of indices. This combines self.get_index_values() with the provided axis vector to create a single vector of unique indices.
§Arguments
axis- Additional index values to merge with current structure’s indices
§Returns
Vec<&Input>- Vector containing unique combined indices
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".