pub struct HexGridHomography {
pub h_img_from_rect: Homography,
pub h_rect_from_img: Homography,
pub min_q: i32,
pub min_r: i32,
pub max_q: i32,
pub max_r: i32,
pub px_per_cell: f32,
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: HomographyMaps rectified coordinates to image coordinates.
h_rect_from_img: HomographyMaps image coordinates to rectified coordinates.
min_q: i32Axial bounding box (with margin).
min_r: i32§max_q: i32§max_r: i32§px_per_cell: f32Rectified pixels per grid cell edge.
rect_width: usizeRectified image dimensions.
rect_height: usizeImplementations§
Source§impl HexGridHomography
impl HexGridHomography
Sourcepub fn from_corners(
corners: &HashMap<GridIndex, Point2<f32>>,
px_per_cell: f32,
margin_cells: f32,
) -> Result<Self, HexRectifyError>
pub fn from_corners( corners: &HashMap<GridIndex, Point2<f32>>, px_per_cell: f32, margin_cells: f32, ) -> 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<f32>) -> Point2<f32>
pub fn rect_to_img(&self, p_rect: Point2<f32>) -> Point2<f32>
Map a point from rectified space to image space.
Sourcepub fn img_to_rect(&self, p_img: Point2<f32>) -> Point2<f32>
pub fn img_to_rect(&self, p_img: Point2<f32>) -> Point2<f32>
Map a point from image space to rectified space.
Sourcepub fn axial_to_rect(&self, q: f64, r: f64) -> Point2<f64>
pub fn axial_to_rect(&self, q: f64, r: f64) -> Point2<f64>
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 Clone for HexGridHomography
impl Clone for HexGridHomography
Source§fn clone(&self) -> HexGridHomography
fn clone(&self) -> HexGridHomography
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for HexGridHomography
impl RefUnwindSafe for HexGridHomography
impl Send for HexGridHomography
impl Sync for HexGridHomography
impl Unpin for HexGridHomography
impl UnsafeUnpin for HexGridHomography
impl UnwindSafe for HexGridHomography
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.