Skip to main content

MergeObj

Struct MergeObj 

Source
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>

Source

pub const fn new(xcoord: T1, ycoord: T2) -> MergeObj<T1, T2>

Creates a new MergeObj with the given x and y coordinates.

§Arguments
  • xcoord - The x-coordinate value
  • ycoord - The y-coordinate value
§Examples
use physdes::merge_obj::MergeObj;
let obj = MergeObj::new(3, 4);
assert_eq!(obj.get_impl().xcoord, 3);
Source

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 space
  • ycoord - 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 - 5
Source

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>
where T1: MinDist<T1>, T2: MinDist<T2>,

Source

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>
where T1: MinDist<T1> + Enlarge<i32, Output = T1> + Intersect<T1, Output = T1>, T2: MinDist<T2> + Enlarge<i32, Output = T2> + Intersect<T2, Output = T2>,

Source

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
Source

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
Source

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:

  1. Computing the minimum distance $d$ between the two objects
  2. Enlarging each by a portion of that distance: $$\text{trr}_1 = \text{enlarge}(self,; \alpha),\quad \text{trr}_2 = \text{enlarge}(other,; d - \alpha)$$
  3. 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

Trait Implementations§

Source§

impl<T1: Clone, T2: Clone> Clone for MergeObj<T1, T2>

Source§

fn clone(&self) -> MergeObj<T1, T2>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T1: Copy, T2: Copy> Copy for MergeObj<T1, T2>

Source§

impl<T1: Debug, T2: Debug> Debug for MergeObj<T1, T2>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T1: Default, T2: Default> Default for MergeObj<T1, T2>

Source§

fn default() -> MergeObj<T1, T2>

Returns the “default value” for a type. Read more
Source§

impl<T1: Eq, T2: Eq> Eq for MergeObj<T1, T2>

Source§

impl<T1: Hash, T2: Hash> Hash for MergeObj<T1, T2>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T1: PartialEq, T2: PartialEq> PartialEq for MergeObj<T1, T2>

Source§

fn eq(&self, other: &MergeObj<T1, T2>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T1: PartialEq, T2: PartialEq> StructuralPartialEq for MergeObj<T1, T2>

Auto Trait Implementations§

§

impl<T1, T2> Freeze for MergeObj<T1, T2>
where T1: Freeze, T2: Freeze,

§

impl<T1, T2> RefUnwindSafe for MergeObj<T1, T2>

§

impl<T1, T2> Send for MergeObj<T1, T2>
where T1: Send, T2: Send,

§

impl<T1, T2> Sync for MergeObj<T1, T2>
where T1: Sync, T2: Sync,

§

impl<T1, T2> Unpin for MergeObj<T1, T2>
where T1: Unpin, T2: Unpin,

§

impl<T1, T2> UnsafeUnpin for MergeObj<T1, T2>
where T1: UnsafeUnpin, T2: UnsafeUnpin,

§

impl<T1, T2> UnwindSafe for MergeObj<T1, T2>
where T1: UnwindSafe, T2: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.