Trait trackball::Clamp

source ·
pub trait Clamp<N: Copy + RealField>: Send + Sync + Debug + 'static {
    // Required methods
    fn target(&self, frame: &Frame<N>) -> Option<Plane<N>>;
    fn eye(&self, frame: &Frame<N>) -> Option<Plane<N>>;
    fn up(&self, frame: &Frame<N>) -> Option<Plane<N>>;

    // Provided methods
    fn loops(&self) -> usize { ... }
    fn compute(
        &self,
        frame: &Frame<N>,
        scope: &Scope<N>,
        delta: &Delta<N>
    ) -> Option<(Delta<N>, usize)> { ... }
}
Expand description

Clamp wrt abstract boundary conditions of Frame and Scope.

Specific boundary conditions are defined by trait implementations (e.g., Bound).

Exceeding a boundary condition is communicated by specifying an exceeded plane. If the plane is orthogonal to Delta, it is completely stopped. If not, it glides along the plane. In this case, the direction of Delta is changed by projecting the exceeded position onto the boundary plane and finding the Delta from initial to projected position. This projected Delta is repeatedly revalidated wrt boundary conditions until no new boundary plane is exceeded. For orthogonal boundary conditions (e.g., a box), revalidation usually passes after one, two, or three loops whenever zero, one, or two boundary conditions intersect (i.e., face, edge, or corner).

Required Methods§

source

fn target(&self, frame: &Frame<N>) -> Option<Plane<N>>

Exceeded boundary plane for target position in world space.

Must return None if target position satisfies all boundary conditions.

source

fn eye(&self, frame: &Frame<N>) -> Option<Plane<N>>

Exceeded boundary plane for eye position in world space.

Must return None if eye position satisfies all boundary conditions.

source

fn up(&self, frame: &Frame<N>) -> Option<Plane<N>>

Exceeded boundary plane for up position in world space.

Must return None if up position satisfies all boundary conditions.

Provided Methods§

source

fn loops(&self) -> usize

Maximum loops due to maximum possible boundary plane intersections.

Measure to break out of validation loop as last resort. Default is 100. Round boundary conditions require more loops whereas flat ones should stop with the 3rd validation (i.e., a corner) for each validated position (e.g., target, eye).

source

fn compute( &self, frame: &Frame<N>, scope: &Scope<N>, delta: &Delta<N> ) -> Option<(Delta<N>, usize)>

Computes clamped Delta wrt abstract boundary conditions of Frame and Scope.

Returns None if Delta satisfies all boundary conditions.

Implementors§

source§

impl<N: Copy + RealField> Clamp<N> for Bound<N>