Skip to main content

RegionSize

Struct RegionSize 

Source
pub struct RegionSize<const N: usize>{ /* private fields */ }
Expand description

Image size in pixels, used to generate a screen-to-world matrix

The screen coordinate space is the following:

       0 ------------> width
       |             |
       |             |
       |             |
       V--------------
  height

The map from screen to world coordinates (generated by screen_to_world) is as following:

      -1           y = +1
       0-------------^-------------> width
       |             |             |
       |             |             |
       |             |             |
  x = -1 <-----------0-------------> x = +1
       |             |             |
       |             |             |
       |             V             |
       V---------- y = -1 ---------
  height

(with +z pointing out of the screen)

Note that the Y axis is reversed between screen and world coordinates: screen coordinates have +y pointing down, but world coordinates have it pointing up. For both X and Y coordinates, the +1 value is located one pixel beyond the edge of the screen region (off the right edge for X, and off the top edge for Y).

If the render region is not square, then the shorter axis is clamped to ±1 and the longer axis will exceed that value.

Implementations§

Source§

impl<const N: usize> RegionSize<N>

Apologies for the terrible trait bounds; they’re necessary to persuade the internals to type-check, but shouldn’t be noticeable to library users.

Source

pub fn screen_to_world( &self, ) -> OMatrix<f32, <Const<N> as DimNameAdd<Const<1>>>::Output, <Const<N> as DimNameAdd<Const<1>>>::Output>

Builds a matrix that converts from screen to world coordinates

See the struct docstring for a diagram of this mapping.

Source

pub fn width(&self) -> u32

Returns the width of the image (in pixels or voxels)

Source

pub fn height(&self) -> u32

Returns the height of the image (in pixels or voxels)

Source§

impl RegionSize<2>

Source

pub fn new(width: u32, height: u32) -> Self

Builds a new ImageSize object from width and height in pixels

Source

pub fn transform_point(&self, p: Point2<i32>) -> Point2<f32>

Transforms a point from screen to world coordinates

Source§

impl RegionSize<3>

Source

pub fn new(width: u32, height: u32, depth: u32) -> Self

Builds a new VoxelSize object from width, height, and depth in voxels

Source

pub fn depth(&self) -> u32

Returns the depth of the image (in voxels)

Source

pub fn transform_point(&self, p: Point3<i32>) -> Point3<f32>

Transforms a point from screen to world coordinates

Trait Implementations§

Source§

impl<const N: usize> Clone for RegionSize<N>

Source§

fn clone(&self) -> RegionSize<N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Debug for RegionSize<N>

Source§

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

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

impl<const N: usize> Default for RegionSize<N>

Source§

fn default() -> Self

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

impl<const N: usize> From<u32> for RegionSize<N>

Builds a RegionSize with the same dimension on all axes

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> Index<usize> for RegionSize<N>

Source§

type Output = u32

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<const N: usize> PartialEq for RegionSize<N>

Source§

fn eq(&self, other: &RegionSize<N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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<const N: usize> Copy for RegionSize<N>

Source§

impl<const N: usize> Eq for RegionSize<N>

Source§

impl<const N: usize> StructuralPartialEq for RegionSize<N>

Auto Trait Implementations§

§

impl<const N: usize> !Freeze for RegionSize<N>

§

impl<const N: usize> !RefUnwindSafe for RegionSize<N>

§

impl<const N: usize> !Send for RegionSize<N>

§

impl<const N: usize> !Sync for RegionSize<N>

§

impl<const N: usize> !Unpin for RegionSize<N>

§

impl<const N: usize> !UnsafeUnpin for RegionSize<N>

§

impl<const N: usize> !UnwindSafe for RegionSize<N>

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,