Skip to main content

AxisOperations

Trait AxisOperations 

Source
pub trait AxisOperations<Point, Input>
where Input: Hash + Eq + Clone + Ord,
{ 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§

Source

type Error

The type of error that can occur during point operations

Required Methods§

Source

fn contains_point(&self, x: &Input) -> bool

Checks if a coordinate value exists in the structure.

§Arguments
  • x - The coordinate value to check (x for curves, xy-point for surfaces)
§Returns
  • bool - true if the coordinate exists, false otherwise
Source

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
Source

fn get_values(&self, x: Input) -> Vec<&Decimal>

Returns a vector of references to dependent values for a given coordinate.

For curves, returns y-values for a given x-coordinate. For surfaces, returns z-values for a given xy-coordinate.

§Arguments
  • x - The coordinate value to lookup
§Returns
  • Vec<&Decimal> - Vector of references to dependent values
Source

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.

Source

fn get_point(&self, x: &Input) -> Option<&Point>

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

Provided Methods§

Source

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".

Implementors§