pub struct HexGridHomography<F: Float = f32> {
pub h_img_from_rect: Homography<F>,
pub h_rect_from_img: Homography<F>,
pub min_q: i32,
pub min_r: i32,
pub max_q: i32,
pub max_r: i32,
pub px_per_cell: F,
pub rect_width: usize,
pub rect_height: usize,
/* private fields */
}Expand description
A global homography mapping between rectified hex grid space and image space.
Rectified coordinates map axial (q, r) to 2D using:
x = px_per_cell * (q + r * 0.5)
y = px_per_cell * (r * sqrt(3) / 2)Fields§
§h_img_from_rect: Homography<F>Maps rectified coordinates to image coordinates.
h_rect_from_img: Homography<F>Maps image coordinates to rectified coordinates.
min_q: i32Axial bounding box (with margin).
min_r: i32§max_q: i32§max_r: i32§px_per_cell: FRectified pixels per grid cell edge.
rect_width: usizeRectified image dimensions.
rect_height: usizeImplementations§
Source§impl<F: Float> HexGridHomography<F>
impl<F: Float> HexGridHomography<F>
Sourcepub fn from_corners(
corners: &HashMap<GridIndex, Point2<F>>,
px_per_cell: F,
margin_cells: F,
) -> Result<Self, HexRectifyError>
pub fn from_corners( corners: &HashMap<GridIndex, Point2<F>>, px_per_cell: F, margin_cells: F, ) -> Result<Self, HexRectifyError>
Compute a global homography from hex grid corners to a rectified coordinate system.
corners: map from axial grid index(q=i, r=j)to image position.px_per_cell: rectified pixels per grid cell edge.margin_cells: extra margin around the grid bounding box (in cell units).
Sourcepub fn rect_to_img(&self, p_rect: Point2<F>) -> Point2<F>
pub fn rect_to_img(&self, p_rect: Point2<F>) -> Point2<F>
Map a point from rectified space to image space.
Sourcepub fn img_to_rect(&self, p_img: Point2<F>) -> Point2<F>
pub fn img_to_rect(&self, p_img: Point2<F>) -> Point2<F>
Map a point from image space to rectified space.
Sourcepub fn axial_to_rect(&self, q: F, r: F) -> Point2<F>
pub fn axial_to_rect(&self, q: F, r: F) -> Point2<F>
Convert axial coordinates (q, r) to rectified pixel coordinates.
This does not apply the homography — it maps grid indices to the
rectified coordinate system directly. The result is in the same shifted
frame used by the stored homography, so it can be passed to
rect_to_img.
Trait Implementations§
Source§impl<F: Clone + Float> Clone for HexGridHomography<F>
impl<F: Clone + Float> Clone for HexGridHomography<F>
Source§fn clone(&self) -> HexGridHomography<F>
fn clone(&self) -> HexGridHomography<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<F> Freeze for HexGridHomography<F>where
F: Freeze,
impl<F> RefUnwindSafe for HexGridHomography<F>where
F: RefUnwindSafe,
impl<F> Send for HexGridHomography<F>
impl<F> Sync for HexGridHomography<F>
impl<F> Unpin for HexGridHomography<F>where
F: Unpin,
impl<F> UnsafeUnpin for HexGridHomography<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for HexGridHomography<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
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>,
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>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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
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>,
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)
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>,
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
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>,
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
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.