pub struct ChipTransform {
pub a: i32,
pub b: i32,
pub c: i32,
pub d: i32,
pub tx: i32,
pub ty: i32,
}Expand description
Affine transformation for chip coordinate mapping.
Formula:
global_x = a * local_x + b * local_y + tx
global_y = c * local_x + d * local_y + ty
Fields§
§a: i32Local X coefficient for affine transform.
b: i32Local Y coefficient for affine transform in X output.
c: i32Local X coefficient for affine transform in Y output.
d: i32Local Y coefficient for affine transform.
tx: i32Translation in X direction.
ty: i32Translation in Y direction.
Implementations§
Source§impl ChipTransform
impl ChipTransform
Sourcepub fn apply(&self, x: u16, y: u16) -> (u16, u16)
pub fn apply(&self, x: u16, y: u16) -> (u16, u16)
Apply transform to local coordinates.
§Note
This method assumes the transform has been validated via validate_bounds().
Using an unvalidated transform may cause incorrect results due to integer overflow.
Sourcepub fn validate_bounds(
&self,
chip_size_x: u16,
chip_size_y: u16,
) -> Result<(), String>
pub fn validate_bounds( &self, chip_size_x: u16, chip_size_y: u16, ) -> Result<(), String>
Validate that this transform produces valid u16 coordinates
for all inputs in the range [0, chip_size_x) x [0, chip_size_y).
This checks all 4 corners of the input space, which is sufficient because affine transforms are linear (extremes occur at corners).
§Errors
Returns an error if the transform maps any corner outside the valid output range.
Trait Implementations§
Source§impl Clone for ChipTransform
impl Clone for ChipTransform
Source§fn clone(&self) -> ChipTransform
fn clone(&self) -> ChipTransform
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more