pub struct MergeObj<T1, T2> { /* private fields */ }Expand description
Represents a merge object that encapsulates a point with coordinates of type T1 and T2.
The MergeObj struct is used for geometric operations such as distance calculation, enlargement, intersection, and merging with other merge objects.
§Examples
use physdes::merge_obj::MergeObj;
let merge_obj = MergeObj::new(3, 4);
let internal_point = merge_obj.get_impl();
assert_eq!(internal_point.xcoord, 3);
assert_eq!(internal_point.ycoord, 4);Implementations§
Source§impl<T1, T2> MergeObj<T1, T2>
impl<T1, T2> MergeObj<T1, T2>
Sourcepub const fn construct(xcoord: i32, ycoord: i32) -> MergeObj<i32, i32>
pub const fn construct(xcoord: i32, ycoord: i32) -> MergeObj<i32, i32>
Constructs a MergeObj<i32, i32> from raw coordinates by applying
the transform (x+y, x-y) to the internal point:
$$(x’, y’) = (x + y,; x - y)$$
This transform maps the point into a rotated coordinate space used for Manhattan-distance-based merging operations.
§Arguments
xcoord- The x-coordinate in the original spaceycoord- The y-coordinate in the original space
§Examples
use physdes::merge_obj::MergeObj;
let obj = MergeObj::<i32, i32>::construct(4, 5);
let internal = obj.get_impl();
assert_eq!(internal.xcoord, 9); // 4 + 5
assert_eq!(internal.ycoord, -1); // 4 - 5Sourcepub fn get_impl(&self) -> &Point<T1, T2>
pub fn get_impl(&self) -> &Point<T1, T2>
Returns a reference to the internal Point of the MergeObj
§Examples
use physdes::merge_obj::MergeObj;
let merge_obj = MergeObj::new(3, 4);
let internal_point = merge_obj.get_impl();
assert_eq!(internal_point.xcoord, 3);
assert_eq!(internal_point.ycoord, 4);Source§impl<T1, T2> MergeObj<T1, T2>
impl<T1, T2> MergeObj<T1, T2>
Sourcepub fn min_dist_with(&self, other: &MergeObj<T1, T2>) -> u32
pub fn min_dist_with(&self, other: &MergeObj<T1, T2>) -> u32
Computes the minimum Manhattan distance between two MergeObj values.
Returns the Chebyshev distance in rotated space, corresponding to Manhattan distance in the original space:
$$d = \max(|x_1 - x_2|,; |y_1 - y_2|)$$
§Arguments
other- The other merge object to measure distance to
§Examples
use physdes::merge_obj::MergeObj;
let a = MergeObj::<i32, i32>::construct(0, 0);
let b = MergeObj::<i32, i32>::construct(3, 4);
assert_eq!(a.min_dist_with(&b), 7);Source§impl<T1, T2> MergeObj<T1, T2>
impl<T1, T2> MergeObj<T1, T2>
Sourcepub fn enlarge_with(&self, alpha: i32) -> MergeObj<T1, T2>
pub fn enlarge_with(&self, alpha: i32) -> MergeObj<T1, T2>
Enlarges this merge object by a given margin, producing a new MergeObj
whose coordinates are expanded outward by alpha in all directions:
$$x \to [x - \alpha,; x + \alpha],\qquad y \to [y - \alpha,; y + \alpha]$$
§Arguments
alpha- The margin to add around each coordinate
Sourcepub fn intersect_with(&self, other: &MergeObj<T1, T2>) -> MergeObj<T1, T2>
pub fn intersect_with(&self, other: &MergeObj<T1, T2>) -> MergeObj<T1, T2>
Computes the intersection of this merge object with another.
Returns a new MergeObj whose coordinates are the component-wise
intersection of the two operands.
§Arguments
other- The other merge object to intersect with
Sourcepub fn merge_with(&self, other: &MergeObj<T1, T2>) -> MergeObj<T1, T2>
pub fn merge_with(&self, other: &MergeObj<T1, T2>) -> MergeObj<T1, T2>
Merges this merge object with another by computing the midpoint region between them.
The merge is performed by:
- Computing the minimum distance $d$ between the two objects
- Enlarging each by a portion of that distance: $$\text{trr}_1 = \text{enlarge}(self,; \alpha),\quad \text{trr}_2 = \text{enlarge}(other,; d - \alpha)$$
- Intersecting the enlarged regions to find the merge result: $$\text{result} = \text{trr}_1 \cap \text{trr}_2$$
This is the core operation of the DME (Deferred Merge Embedding) algorithm.
§Arguments
other- The other merge object to merge with