Struct vek::bezier::repr_c::CubicBezier2 [−][src]
pub struct CubicBezier2<T> {
pub start: Vec2<T>,
pub ctrl0: Vec2<T>,
pub ctrl1: Vec2<T>,
pub end: Vec2<T>,
}
Expand description
A 2D Bézier curve with two control points.
2x2 and 3x3 matrices can be multiplied by a Bézier curve to transform all of its points.
Fields
start: Vec2<T>
Starting point of the curve.
ctrl0: Vec2<T>
First control point of the curve, associated with start
.
ctrl1: Vec2<T>
Second control point of the curve, associated with end
.
end: Vec2<T>
End point of the curve.
Implementations
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.
Evaluates the derivative tangent at interpolation factor t
, which happens to give
a non-normalized tangent vector.
See also normalized_tangent()
.
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.
Splits this cubic Bézier curve into two curves, at interpolation factor t
.
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.
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)
.
Gets this curve reversed, i.e swaps start
with end
and ctrl0
with ctrl1
.
Converts this curve into a tuple of points.
Converts this curve into an array of points.
Returns the evaluation factor that gives an inflection point along the X axis, if any.
Returns the evaluation factor that gives the point on the curve which X coordinate is the minimum.
Returns the evaluation factor that gives the point on the curve which X coordinate is the maximum.
Returns the evaluation factor that gives an inflection point along the Y axis, if any.
Returns the evaluation factor that gives the point on the curve which Y coordinate is the minimum.
Returns the evaluation factor that gives the point on the curve which Y coordinate is the maximum.
Evaluates the normalized tangent at interpolation factor t
.
Approximates the curve’s length by subdividing it into step_count+1 segments.
Gets the Axis-Aligned Bounding Rectangle for this curve.
On 3D curves, this discards the z
values.
Returns this curve, flipping the x
coordinate of each of its points.
Returns this curve, flipping the y
coordinate of each of its points.
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.
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.
Converts this 2D curve to a 3D one, setting the z
elements to zero.
Trait Implementations
Returns the “default value” for a type. Read more
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
type Output = CubicBezier2<T>
type Output = CubicBezier2<T>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = CubicBezier2<T>
type Output = CubicBezier2<T>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = CubicBezier2<T>
type Output = CubicBezier2<T>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = CubicBezier2<T>
type Output = CubicBezier2<T>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl<T> RefUnwindSafe for CubicBezier2<T> where
T: RefUnwindSafe,
impl<T> Send for CubicBezier2<T> where
T: Send,
impl<T> Sync for CubicBezier2<T> where
T: Sync,
impl<T> Unpin for CubicBezier2<T> where
T: Unpin,
impl<T> UnwindSafe for CubicBezier2<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more