Struct vek::bezier::repr_c::CubicBezier3 [−][src]
pub struct CubicBezier3<T> { pub start: Vec3<T>, pub ctrl0: Vec3<T>, pub ctrl1: Vec3<T>, pub end: Vec3<T>, }
Expand description
A 3D Bézier curve with two control points.
3x3 and 4x4 matrices can be multiplied by a Bézier curve to transform all of its points.
Fields
start: Vec3<T>
Expand description
Starting point of the curve.
ctrl0: Vec3<T>
Expand description
First control point of the curve, associated with start
.
ctrl1: Vec3<T>
Expand description
Second control point of the curve, associated with end
.
end: Vec3<T>
Expand description
End point of the curve.
Implementations
impl<T: Real> CubicBezier3<T>
[src]
impl<T: Real> CubicBezier3<T>
[src]pub fn evaluate(self, t: T) -> Vec3<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]
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() -> Mat4<T>
[src]
pub fn matrix() -> Mat4<T>
[src]Returns the constant matrix M such that,
given T = [1, t*t, t*t*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; 2]
[src]
pub fn split(self, t: T) -> [Self; 2]
[src]Splits this cubic Bézier curve into two curves, at interpolation factor t
.
pub fn unit_quarter_circle() -> Self
[src]
pub fn unit_quarter_circle() -> Self
[src]Gets the cubic Bézier curve that approximates a unit quarter circle.
You can build a good-looking circle out of 4 curves by applying symmetries to this curve.
pub fn unit_circle() -> [Self; 4]
[src]
pub fn unit_circle() -> [Self; 4]
[src]Gets the 4 cubic Bézier curves that, used together, approximate a unit quarter circle.
The returned tuple is (north-east, north-west, south-west, south-east)
.
impl<T> CubicBezier3<T>
[src]
impl<T> CubicBezier3<T>
[src]pub fn reversed(self) -> Self
[src]
pub fn reversed(self) -> Self
[src]Gets this curve reversed, i.e swaps start
with end
and ctrl0
with ctrl1
.
pub fn into_tuple(self) -> (Vec3<T>, Vec3<T>, Vec3<T>, Vec3<T>)
[src]
pub fn into_tuple(self) -> (Vec3<T>, Vec3<T>, Vec3<T>, Vec3<T>)
[src]Converts this curve into a tuple of points.
pub fn into_array(self) -> [Vec3<T>; 4]
[src]
pub fn into_array(self) -> [Vec3<T>; 4]
[src]Converts this curve into an array of points.
impl<T: Real> CubicBezier3<T>
[src]
impl<T: Real> CubicBezier3<T>
[src]pub fn x_inflections(self) -> Option<(T, Option<T>)>
[src]
pub fn x_inflections(self) -> Option<(T, 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]
pub fn min_x(self) -> T
[src]Returns the evaluation factor that gives the point on the curve which X coordinate is the minimum.
impl<T: Real> CubicBezier3<T>
[src]
impl<T: Real> CubicBezier3<T>
[src]pub fn y_inflections(self) -> Option<(T, Option<T>)>
[src]
pub fn y_inflections(self) -> Option<(T, 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]
pub fn min_y(self) -> T
[src]Returns the evaluation factor that gives the point on the curve which Y coordinate is the minimum.
impl<T: Real> CubicBezier3<T>
[src]
impl<T: Real> CubicBezier3<T>
[src]pub fn z_inflections(self) -> Option<(T, Option<T>)>
[src]
pub fn z_inflections(self) -> Option<(T, 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]
pub fn min_z(self) -> T
[src]Returns the evaluation factor that gives the point on the curve which Z coordinate is the minimum.
impl<T: Real> CubicBezier3<T>
[src]
impl<T: Real> CubicBezier3<T>
[src]pub fn normalized_tangent(self, t: T) -> Vec3<T> where
T: Add<T, Output = T>,
[src]
pub fn normalized_tangent(self, t: T) -> Vec3<T> where
T: Add<T, Output = T>,
[src]Evaluates the normalized tangent at interpolation factor t
.
pub fn length_by_discretization(self, step_count: u16) -> T where
T: Add<T, Output = T> + From<u16>,
[src]
pub fn length_by_discretization(self, step_count: u16) -> T where
T: Add<T, Output = T> + From<u16>,
[src]Approximates the curve’s length by subdividing it into step_count+1 segments.
pub fn aabr(self) -> Aabr<T>
[src]
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]
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]
pub fn flipped_y(self) -> Self
[src]Returns this curve, flipping the y
coordinate of each of its points.
pub fn binary_search_point_by_steps(
self,
p: Vec3<T>,
steps: u16,
epsilon: T
) -> (T, Vec3<T>) where
T: Add<T, Output = T> + From<u16>,
[src]
pub fn binary_search_point_by_steps(
self,
p: Vec3<T>,
steps: u16,
epsilon: T
) -> (T, Vec3<T>) where
T: Add<T, Output = T> + 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: Add<T, Output = T>,
I: IntoIterator<Item = (T, Vec3<T>)>,
[src]
pub fn binary_search_point<I>(
self,
p: Vec3<T>,
coarse: I,
half_interval: T,
epsilon: T
) -> (T, Vec3<T>) where
T: Add<T, Output = T>,
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> CubicBezier3<T>
[src]
impl<T: Real> CubicBezier3<T>
[src]impl<T> CubicBezier3<T>
[src]
impl<T> CubicBezier3<T>
[src]pub fn into_2d(self) -> CubicBezier2<T>
[src]
pub fn into_2d(self) -> CubicBezier2<T>
[src]Converts this 3D curve to a 2D one, dropping the z
elements.
Trait Implementations
impl<T: Clone> Clone for CubicBezier3<T>
[src]
impl<T: Clone> Clone for CubicBezier3<T>
[src]fn clone(&self) -> CubicBezier3<T>
[src]
fn clone(&self) -> CubicBezier3<T>
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for CubicBezier3<T>
[src]
impl<T: Debug> Debug for CubicBezier3<T>
[src]impl<T: Default> Default for CubicBezier3<T>
[src]
impl<T: Default> Default for CubicBezier3<T>
[src]fn default() -> CubicBezier3<T>
[src]
fn default() -> CubicBezier3<T>
[src]Returns the “default value” for a type. Read more
impl<'de, T> Deserialize<'de> for CubicBezier3<T> where
T: Deserialize<'de>,
[src]
impl<'de, T> Deserialize<'de> for CubicBezier3<T> where
T: Deserialize<'de>,
[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
impl<T: Zero> From<CubicBezier2<T>> for CubicBezier3<T>
[src]
impl<T: Zero> From<CubicBezier2<T>> for CubicBezier3<T>
[src]fn from(c: CubicBezier2<T>) -> Self
[src]
fn from(c: CubicBezier2<T>) -> Self
[src]Performs the conversion.
impl<T> From<CubicBezier3<T>> for Vec4<Vec3<T>>
[src]
impl<T> From<CubicBezier3<T>> for Vec4<Vec3<T>>
[src]fn from(v: CubicBezier3<T>) -> Self
[src]
fn from(v: CubicBezier3<T>) -> Self
[src]Performs the conversion.
impl<T> From<CubicBezier3<T>> for CubicBezier2<T>
[src]
impl<T> From<CubicBezier3<T>> for CubicBezier2<T>
[src]fn from(c: CubicBezier3<T>) -> Self
[src]
fn from(c: CubicBezier3<T>) -> Self
[src]Performs the conversion.
impl<T: Real + Lerp<T, Output = T>> From<LineSegment3<T>> for CubicBezier3<T>
[src]
impl<T: Real + Lerp<T, Output = T>> From<LineSegment3<T>> for CubicBezier3<T>
[src]fn from(line_segment: LineSegment3<T>) -> Self
[src]
fn from(line_segment: LineSegment3<T>) -> Self
[src]Performs the conversion.
impl<T: Real> From<QuadraticBezier3<T>> for CubicBezier3<T>
[src]
impl<T: Real> From<QuadraticBezier3<T>> for CubicBezier3<T>
[src]fn from(b: QuadraticBezier3<T>) -> Self
[src]
fn from(b: QuadraticBezier3<T>) -> Self
[src]Performs the conversion.
impl<T> From<Vec4<Vec3<T>>> for CubicBezier3<T>
[src]
impl<T> From<Vec4<Vec3<T>>> for CubicBezier3<T>
[src]impl<T: Hash> Hash for CubicBezier3<T>
[src]
impl<T: Hash> Hash for CubicBezier3<T>
[src]impl<T> Mul<CubicBezier3<T>> for Rows3<T> where
T: Real + MulAdd<T, T, Output = T>,
[src]
impl<T> Mul<CubicBezier3<T>> for Rows3<T> where
T: Real + MulAdd<T, T, Output = T>,
[src]type Output = CubicBezier3<T>
type Output = CubicBezier3<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: CubicBezier3<T>) -> CubicBezier3<T>
[src]
fn mul(self, rhs: CubicBezier3<T>) -> CubicBezier3<T>
[src]Performs the *
operation. Read more
impl<T> Mul<CubicBezier3<T>> for Cols3<T> where
T: Real + MulAdd<T, T, Output = T>,
[src]
impl<T> Mul<CubicBezier3<T>> for Cols3<T> where
T: Real + MulAdd<T, T, Output = T>,
[src]type Output = CubicBezier3<T>
type Output = CubicBezier3<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: CubicBezier3<T>) -> CubicBezier3<T>
[src]
fn mul(self, rhs: CubicBezier3<T>) -> CubicBezier3<T>
[src]Performs the *
operation. Read more
impl<T> Mul<CubicBezier3<T>> for Rows4<T> where
T: Real + MulAdd<T, T, Output = T>,
[src]
impl<T> Mul<CubicBezier3<T>> for Rows4<T> where
T: Real + MulAdd<T, T, Output = T>,
[src]type Output = CubicBezier3<T>
type Output = CubicBezier3<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: CubicBezier3<T>) -> CubicBezier3<T>
[src]
fn mul(self, rhs: CubicBezier3<T>) -> CubicBezier3<T>
[src]Performs the *
operation. Read more
impl<T> Mul<CubicBezier3<T>> for Cols4<T> where
T: Real + MulAdd<T, T, Output = T>,
[src]
impl<T> Mul<CubicBezier3<T>> for Cols4<T> where
T: Real + MulAdd<T, T, Output = T>,
[src]type Output = CubicBezier3<T>
type Output = CubicBezier3<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: CubicBezier3<T>) -> CubicBezier3<T>
[src]
fn mul(self, rhs: CubicBezier3<T>) -> CubicBezier3<T>
[src]Performs the *
operation. Read more
impl<T: PartialEq> PartialEq<CubicBezier3<T>> for CubicBezier3<T>
[src]
impl<T: PartialEq> PartialEq<CubicBezier3<T>> for CubicBezier3<T>
[src]fn eq(&self, other: &CubicBezier3<T>) -> bool
[src]
fn eq(&self, other: &CubicBezier3<T>) -> bool
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &CubicBezier3<T>) -> bool
[src]
fn ne(&self, other: &CubicBezier3<T>) -> bool
[src]This method tests for !=
.
impl<T> Serialize for CubicBezier3<T> where
T: Serialize,
[src]
impl<T> Serialize for CubicBezier3<T> where
T: Serialize,
[src]impl<T: Copy> Copy for CubicBezier3<T>
[src]
impl<T: Eq> Eq for CubicBezier3<T>
[src]
impl<T> StructuralEq for CubicBezier3<T>
[src]
impl<T> StructuralPartialEq for CubicBezier3<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for CubicBezier3<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for CubicBezier3<T> where
T: Send,
T: Send,
impl<T> Sync for CubicBezier3<T> where
T: Sync,
T: Sync,
impl<T> Unpin for CubicBezier3<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for CubicBezier3<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,