# sec_interp.core.utils.geometry_utils.optimization module

Geometry optimization and curvature computation.

class sec_interp.core.utils.geometry_utils.optimization.PreviewOptimizer

  Bases: `object`

  Provides geometric optimization and sampling logic for preview rendering.

  classmethod adaptive_sample(data: list[tuple[float, float]], min_tolerance: float = 0.1, max_tolerance: float = 10.0, max_points: int = 1000) → list[tuple[float, float]]

    Adaptively sample data based on local curvature.

    Parameters:

      - data – List of (x, y) tuples

      - min_tolerance – Minimum tolerance for high-detail areas

      - max_tolerance – Maximum tolerance for low-detail areas

      - max_points – Maximum points to keep (approximate target)

    Returns:

      Adaptively sampled data

  static calculate_curvature(data: list[tuple[float, float]]) → list[float]

    Calculate a simple curvature metric for each point in a line.

    This approximates curvature by the angle deviation between successive segments. High values indicate sharper turns.

    Parameters:

      data – List of (x, y) tuples.

    Returns:

      List of curvature values (angles in degrees), same length as data.

  static decimate(data: list[tuple[float, float]], tolerance: float | None = None, max_points: int = 1000) → list[tuple[float, float]]

    Decimate line data using Douglas-Peucker algorithm.

    Parameters:

      - data – List of (x, y) tuples

      - tolerance – Simplification tolerance (if provided, overrides max_points heuristic)

      - max_points – Maximum points to keep (approximate target if tolerance is None)

    Returns:

      Decimated list of (x, y) tuples