pub trait Clamp:
Send
+ Sync
+ Debug
+ 'static {
// Required methods
fn target(&self, frame: Frame) -> Option<Plane>;
fn eye(&self, frame: Frame) -> Option<Plane>;
fn up(&self, frame: Frame) -> Option<Plane>;
// Provided methods
fn loops(&self) -> usize { ... }
fn compute(
&self,
frame: Frame,
scope: Scope,
delta: Delta,
) -> Option<(Delta, 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 in world space.
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).
Positions moving on spheres (e.g., the eye orbiting around the target) are projected onto the
circle where the sphere intersects the boundary plane. The up axis is treated as position on
the unit sphere. Delta::Scale glides by keeping its ratio but moving its pivot such that
the exceeded position is projected onto the boundary plane, i.e., scaling turns partially into
sliding. It stops where boundary planes moving along with the frame (e.g., distance bounds)
are reached.
Required Methods§
Sourcefn target(&self, frame: Frame) -> Option<Plane>
fn target(&self, frame: Frame) -> Option<Plane>
Exceeded boundary plane for target position in world space.
Must return None if target position satisfies all boundary conditions.
Provided Methods§
Sourcefn loops(&self) -> usize
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). When reached, Delta
stops at the boundary instead of gliding along it.