[][src]Struct vek::bezier::repr_c::QuadraticBezier3

pub struct QuadraticBezier3<T> {
    pub start: Vec3<T>,
    pub ctrl: Vec3<T>,
    pub end: Vec3<T>,
}

A 3D Bézier curve with one control point.

3x3 and 4x4 matrices can be multiplied by a Bézier curve to transform all of its points.

Also note that quadratic Bézier curves are quite bad at approximating circles. See the relevant section of "A Primer on Bézier Curves" for an explanation.

Fields

start: Vec3<T>

Starting point of the curve.

ctrl: Vec3<T>

Control point of the curve.

end: Vec3<T>

End point of the curve.

Methods

impl<T: Real> QuadraticBezier3<T>[src]

pub fn evaluate(self, t: T) -> Vec3<T>[src]

Evaluates the position of the point lying on the curve at interpolation factor t.

This is one of the most important Bézier curve operations, because, in one way or another, it is used to render a curve to the screen. The common use case is to successively evaluate a curve at a set of values that range from 0 to 1, to approximate the curve as an array of line segments which are then rendered.

pub fn evaluate_derivative(self, t: T) -> Vec3<T>[src]

Evaluates the derivative tangent at interpolation factor t, which happens to give a non-normalized tangent vector.

See also normalized_tangent().

pub fn matrix() -> Mat3<T>[src]

Returns the constant matrix M such that, given T = [1, t*t, t*t*t] and P the vector of control points, dot(T * M, P) evalutes the Bezier curve at 't'.

This function name is arguably dubious.

pub fn split(self, t: T) -> (Self, Self)[src]

Splits this quadratic Bézier curve into two curves, at interpolation factor t.

pub fn into_cubic(self) -> CubicBezier3<T>[src]

Elevates this curve into a cubic Bézier curve.

impl<T> QuadraticBezier3<T>[src]

pub fn reversed(self) -> Self[src]

Gets this curve reversed, i.e swaps start with end.

pub fn reverse(&mut self)[src]

Reverses this curve, i.e swaps start with end.

pub fn into_vec3(self) -> Vec3<Vec3<T>>[src]

Converts this curve into a Vec3 of points.

pub fn into_tuple(self) -> (Vec3<T>, Vec3<T>, Vec3<T>)[src]

Converts this curve into a tuple of points.

pub fn into_array(self) -> [Vec3<T>; 3][src]

Converts this curve into an array of points.

impl<T: Real> QuadraticBezier3<T>[src]

pub fn x_inflection(self) -> Option<T>[src]

Returns the evaluation factor that gives an inflection point along the X axis, if any.

pub fn min_x(self) -> T[src]

Returns the evaluation factor that gives the point on the curve which X coordinate is the minimum.

pub fn max_x(self) -> T[src]

Returns the evaluation factor that gives the point on the curve which X coordinate is the maximum.

pub fn x_bounds(self) -> (T, T)[src]

Returns the evaluation factors that give the points on the curve which X coordinates are the respective minimum and maximum.

impl<T: Real> QuadraticBezier3<T>[src]

pub fn y_inflection(self) -> Option<T>[src]

Returns the evaluation factor that gives an inflection point along the Y axis, if any.

pub fn min_y(self) -> T[src]

Returns the evaluation factor that gives the point on the curve which Y coordinate is the minimum.

pub fn max_y(self) -> T[src]

Returns the evaluation factor that gives the point on the curve which Y coordinate is the maximum.

pub fn y_bounds(self) -> (T, T)[src]

Returns the evaluation factors that give the points on the curve which Y coordinates are the respective minimum and maximum.

impl<T: Real> QuadraticBezier3<T>[src]

pub fn z_inflection(self) -> Option<T>[src]

Returns the evaluation factor that gives an inflection point along the Z axis, if any.

pub fn min_z(self) -> T[src]

Returns the evaluation factor that gives the point on the curve which Z coordinate is the minimum.

pub fn max_z(self) -> T[src]

Returns the evaluation factor that gives the point on the curve which Z coordinate is the maximum.

pub fn z_bounds(self) -> (T, T)[src]

Returns the evaluation factors that give the points on the curve which Z coordinates are the respective minimum and maximum.

impl<T: Real> QuadraticBezier3<T>[src]

pub fn normalized_tangent(self, t: T) -> Vec3<T> where
    T: Sum
[src]

Evaluates the normalized tangent at interpolation factor t.

pub fn length_by_discretization(self, step_count: u16) -> T where
    T: Sum + From<u16>, 
[src]

Approximates the curve's length by subdividing it into step_count+1 segments.

pub fn aabr(self) -> Aabr<T>[src]

Gets the Axis-Aligned Bounding Rectangle for this curve.

On 3D curves, this discards the z values.

pub fn flipped_x(self) -> Self[src]

Returns this curve, flipping the x coordinate of each of its points.

pub fn flipped_y(self) -> Self[src]

Returns this curve, flipping the y coordinate of each of its points.

pub fn flip_x(&mut self)[src]

Flips the x coordinate of all points of this curve.

pub fn flip_y(&mut self)[src]

Flips the y coordinate of all points of this curve.

pub fn binary_search_point_by_steps(
    self,
    p: Vec3<T>,
    steps: u16,
    epsilon: T
) -> (T, Vec3<T>) where
    T: Sum + From<u16>, 
[src]

Searches for the point lying on this curve that is closest to p.

steps is the number of points to sample in the curve for the "broad phase" that takes place before the binary search.

epsilon denotes the desired precision for the result. The higher it is, the sooner the algorithm will finish, but the result would be less satisfactory.

Panics

Panics if epsilon is less than or equal to T::epsilon().
epsilon must be positive and not approximately equal to zero.

pub fn binary_search_point<I>(
    self,
    p: Vec3<T>,
    coarse: I,
    half_interval: T,
    epsilon: T
) -> (T, Vec3<T>) where
    T: Sum,
    I: IntoIterator<Item = (T, Vec3<T>)>, 
[src]

Searches for the point lying on this curve that is closest to p.

For an example usage, see the source code of binary_search_point_by_steps().

coarse is an iterator over pairs of (interpolation_value, point) that are assumed to, together, represent a discretization of the curve.
This parameter is used for a "broad phase" - the point yielded by coarse that is closest to p is the starting point for the binary search.
coarse may very well yield a single pair; Also, it was designed so that, if you already have the values handy, there is no need to recompute them.
This function doesn't panic if coarse yields no element, but then it would be very unlikely for the result to be satisfactory.

half_interval is the starting value for the half of the binary search interval.

epsilon denotes the desired precision for the result. The higher it is, the sooner the algorithm will finish, but the result would be less satisfactory.

Panics

Panics if epsilon is less than or equal to T::epsilon().
epsilon must be positive and not approximately equal to zero.

impl<T: Real> QuadraticBezier3<T>[src]

pub fn aabb(self) -> Aabb<T>[src]

Gets the Axis-Aligned Bounding Box for this curve.

pub fn flipped_z(self) -> Self[src]

Returns this curve, flipping the y coordinate of each of its points.

pub fn flip_z(&mut self)[src]

Flips the x coordinate of all points of this curve.

impl<T> QuadraticBezier3<T>[src]

pub fn into_2d(self) -> QuadraticBezier2<T>[src]

Converts this 3D curve to a 2D one, dropping the z elements.

Trait Implementations

impl<T: Zero> From<QuadraticBezier2<T>> for QuadraticBezier3<T>[src]

impl<T> From<Vec3<Vec3<T>>> for QuadraticBezier3<T>[src]

impl<T> From<QuadraticBezier3<T>> for Vec3<Vec3<T>>[src]

impl<T: Real> From<LineSegment3<T>> for QuadraticBezier3<T>[src]

impl<T: Real> From<Range<Vec3<T>>> for QuadraticBezier3<T>[src]

impl<T> From<QuadraticBezier3<T>> for QuadraticBezier2<T>[src]

impl<T: Real> From<QuadraticBezier3<T>> for CubicBezier3<T>[src]

impl<T: Debug> Debug for QuadraticBezier3<T>[src]

impl<T: PartialEq> PartialEq<QuadraticBezier3<T>> for QuadraticBezier3<T>[src]

impl<T: Eq> Eq for QuadraticBezier3<T>[src]

impl<T> Mul<QuadraticBezier3<T>> for Rows3<T> where
    T: Real + MulAdd<T, T, Output = T>, 
[src]

type Output = QuadraticBezier3<T>

The resulting type after applying the * operator.

impl<T> Mul<QuadraticBezier3<T>> for Cols3<T> where
    T: Real + MulAdd<T, T, Output = T>, 
[src]

type Output = QuadraticBezier3<T>

The resulting type after applying the * operator.

impl<T> Mul<QuadraticBezier3<T>> for Rows4<T> where
    T: Real + MulAdd<T, T, Output = T>, 
[src]

type Output = QuadraticBezier3<T>

The resulting type after applying the * operator.

impl<T> Mul<QuadraticBezier3<T>> for Cols4<T> where
    T: Real + MulAdd<T, T, Output = T>, 
[src]

type Output = QuadraticBezier3<T>

The resulting type after applying the * operator.

impl<T: Hash> Hash for QuadraticBezier3<T>[src]

impl<T: Copy> Copy for QuadraticBezier3<T>[src]

impl<T> StructuralPartialEq for QuadraticBezier3<T>[src]

impl<T> StructuralEq for QuadraticBezier3<T>[src]

impl<T: Clone> Clone for QuadraticBezier3<T>[src]

impl<T: Default> Default for QuadraticBezier3<T>[src]

Auto Trait Implementations

impl<T> Unpin for QuadraticBezier3<T> where
    T: Unpin

impl<T> Send for QuadraticBezier3<T> where
    T: Send

impl<T> Sync for QuadraticBezier3<T> where
    T: Sync

impl<T> UnwindSafe for QuadraticBezier3<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for QuadraticBezier3<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.