pub struct XJunctionValidator<F: Float = f32> {
pub min_spacing: F,
pub max_spacing: F,
pub tolerance_rad: F,
}Expand description
Validator for square grids of X-junction corners with known orientation.
Designed for ChESS-like features where each corner has an orientation angle (mod π) and adjacent corners on a chessboard pattern have orthogonal orientations. The edge between two neighbors is at ~45° to both orientations.
§PointData
F — the corner’s orientation angle in radians (mod π, undirected axis).
§Example
use projective_grid::{GridGraph, GridGraphParams, NeighborCandidate};
use projective_grid::square::validators::XJunctionValidator;
use nalgebra::Point2;
use std::f32::consts::FRAC_PI_4;
let positions = vec![
Point2::new(0.0f32, 0.0), Point2::new(10.0, 0.0),
Point2::new(0.0, 10.0), Point2::new(10.0, 10.0),
];
// Alternating orientations (π/4 and 3π/4) like a chessboard
let orientations = vec![FRAC_PI_4, 3.0 * FRAC_PI_4, 3.0 * FRAC_PI_4, FRAC_PI_4];
let validator = XJunctionValidator {
min_spacing: 5.0,
max_spacing: 15.0,
tolerance_rad: 15.0f32.to_radians(),
};
let graph = GridGraph::build(
&positions, &orientations, &validator, &GridGraphParams::default(),
);Fields§
§min_spacing: FMinimum acceptable neighbor distance (pixels).
max_spacing: FMaximum acceptable neighbor distance (pixels).
tolerance_rad: FAngular tolerance (radians) for orthogonality and 45° edge alignment checks.
Trait Implementations§
Source§impl<F: Float> NeighborValidator<F> for XJunctionValidator<F>
impl<F: Float> NeighborValidator<F> for XJunctionValidator<F>
Source§type PointData = F
type PointData = F
Per-point data beyond position (e.g., orientation, cluster label).
Use
() if no extra data is needed.Source§fn validate(
&self,
_source_index: usize,
source_data: &F,
candidate: &NeighborCandidate<F>,
candidate_data: &F,
) -> Option<(NeighborDirection, F)>
fn validate( &self, _source_index: usize, source_data: &F, candidate: &NeighborCandidate<F>, candidate_data: &F, ) -> Option<(NeighborDirection, F)>
Validate whether
candidate is a valid grid neighbor of the point
at source_index. Returns (direction, score) where lower score
is better, or None to reject.Auto Trait Implementations§
impl<F> Freeze for XJunctionValidator<F>where
F: Freeze,
impl<F> RefUnwindSafe for XJunctionValidator<F>where
F: RefUnwindSafe,
impl<F> Send for XJunctionValidator<F>
impl<F> Sync for XJunctionValidator<F>
impl<F> Unpin for XJunctionValidator<F>where
F: Unpin,
impl<F> UnsafeUnpin for XJunctionValidator<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for XJunctionValidator<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Casts the value.
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.