HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Data Fields | Friends
tt::BezierCurve Struct Reference

#include <TTauri/Foundation/BezierCurve.hpp>

Public Types

enum class  Type : uint8_t { None , Linear , Quadratic , Cubic }
 
enum class  Color : uint8_t { Yellow , Magenta , Cyan , White }
 

Public Member Functions

 BezierCurve (BezierCurve const &other) noexcept=default
 
 BezierCurve (BezierCurve &&other) noexcept=default
 
BezierCurveoperator= (BezierCurve const &other) noexcept=default
 
BezierCurveoperator= (BezierCurve &&other) noexcept=default
 
 BezierCurve (vec const P1, vec const P2, Color color=Color::White) noexcept
 
 BezierCurve (vec const P1, vec const C1, vec const P2, Color color=Color::White) noexcept
 
 BezierCurve (vec const P1, vec const C1, vec const C2, vec const P2, Color color=Color::White) noexcept
 
 BezierCurve (Type const type, vec const P1, vec const C1, vec const C2, vec const P2, Color color=Color::White) noexcept
 
bool has_red () const noexcept
 
bool has_green () const noexcept
 
bool has_blue () const noexcept
 
vec pointAt (float const t) const noexcept
 
vec tangentAt (float const t) const noexcept
 
results< float, 3 > solveXByY (float const y) const noexcept
 
results< float, 3 > solveTForNormalsIntersectingPoint (vec P) const noexcept
 
float sdf_distance (vec P) const noexcept
 Find the distance from the point to the curve.
 
std::pair< BezierCurve, BezierCurvecubicSplit (float const t) const noexcept
 
std::pair< BezierCurve, BezierCurvequadraticSplit (float const t) const noexcept
 
std::pair< BezierCurve, BezierCurvelinearSplit (float const t) const noexcept
 
std::pair< BezierCurve, BezierCurvesplit (float const t) const noexcept
 
void subdivideUntilFlat_impl (std::vector< BezierCurve > &r, float const minimumFlatness) const noexcept
 
std::vector< BezierCurvesubdivideUntilFlat (float const tolerance) const noexcept
 
float flatness () const noexcept
 
template<typename M , std::enable_if_t< is_mat_v< M >, int > = 0>
BezierCurveoperator*= (M const rhs) noexcept
 
BezierCurve toParrallelLine (float const offset) const noexcept
 

Data Fields

Type type
 
Color color
 
vec P1
 First point.
 
vec C1
 Control point.
 
vec C2
 Control point.
 
vec P2
 Last point.
 

Friends

bool operator== (BezierCurve const &lhs, BezierCurve const &rhs) noexcept
 
template<typename M , std::enable_if_t< is_mat_v< M >, int > = 0>
BezierCurve operator* (M const &lhs, BezierCurve const &rhs) noexcept
 
BezierCurve operator~ (BezierCurve const &rhs) noexcept
 

Detailed Description

Bezier Curve A linear, quadratic or cubic bezier curve.

Constructor & Destructor Documentation

◆ BezierCurve() [1/4]

tt::BezierCurve::BezierCurve ( vec const P1,
vec const P2,
Color color = Color::White )
inlinenoexcept

Construct a linear bezier-curve.

◆ BezierCurve() [2/4]

tt::BezierCurve::BezierCurve ( vec const P1,
vec const C1,
vec const P2,
Color color = Color::White )
inlinenoexcept

Construct a quadratic bezier-curve.

◆ BezierCurve() [3/4]

tt::BezierCurve::BezierCurve ( vec const P1,
vec const C1,
vec const C2,
vec const P2,
Color color = Color::White )
inlinenoexcept

Construct a cubic bezier-curve.

◆ BezierCurve() [4/4]

tt::BezierCurve::BezierCurve ( Type const type,
vec const P1,
vec const C1,
vec const C2,
vec const P2,
Color color = Color::White )
inlinenoexcept

Construct a bezier-curve of any type.

Member Function Documentation

◆ cubicSplit()

std::pair< BezierCurve, BezierCurve > tt::BezierCurve::cubicSplit ( float const t) const
inlinenoexcept

Split a cubic bezier-curve into two cubic bezier-curve.

Parameters
ta relative distance between 0.0 (point P1) and 1.0 (point P2) where to split the curve.
Returns
two cubic bezier-curves.

◆ flatness()

float tt::BezierCurve::flatness ( ) const
inlinenoexcept

Return the flatness of a curve.

Returns
1.0 when completely flat, < 1.0 when curved.

◆ linearSplit()

std::pair< BezierCurve, BezierCurve > tt::BezierCurve::linearSplit ( float const t) const
inlinenoexcept

Split a linear bezier-curve into two linear bezier-curve.

Parameters
ta relative distance between 0.0 (point P1) and 1.0 (point P2) where to split the curve.
Returns
two linear bezier-curves.

◆ pointAt()

vec tt::BezierCurve::pointAt ( float const t) const
inlinenoexcept

Return a point on the bezier-curve. Values of t beyond 0.0 and 1.0 will find a point extrapolated beyond the bezier segment.

Parameters
ta relative distance between 0.0 (point P1) and 1.0 (point P2).
Returns
the coordinates of the point on the curve.

◆ quadraticSplit()

std::pair< BezierCurve, BezierCurve > tt::BezierCurve::quadraticSplit ( float const t) const
inlinenoexcept

Split a quadratic bezier-curve into two quadratic bezier-curve.

Parameters
ta relative distance between 0.0 (point P1) and 1.0 (point P2) where to split the curve.
Returns
two quadratic bezier-curves.

◆ sdf_distance()

float tt::BezierCurve::sdf_distance ( vec P) const
inlinenoexcept

Find the distance from the point to the curve.

◆ solveXByY()

results< float, 3 > tt::BezierCurve::solveXByY ( float const y) const
inlinenoexcept

Return the x values where the curve crosses the y-axis.

Parameters
yy-axis.
Returns
0 to 3, or infinite number of x values.

◆ split()

std::pair< BezierCurve, BezierCurve > tt::BezierCurve::split ( float const t) const
inlinenoexcept

Split a bezier-curve into two bezier-curve of the same type.

Parameters
ta relative distance between 0.0 (point P1) and 1.0 (point P2) where to split the curve.
Returns
two bezier-curves.

◆ subdivideUntilFlat()

std::vector< BezierCurve > tt::BezierCurve::subdivideUntilFlat ( float const tolerance) const
inlinenoexcept

Subdivide a bezier-curve until each are flat enough.

Parameters
tolerancemaximum amount of curviness.
Returns
resulting list of curve segments.

◆ subdivideUntilFlat_impl()

void tt::BezierCurve::subdivideUntilFlat_impl ( std::vector< BezierCurve > & r,
float const minimumFlatness ) const
inlinenoexcept

Subdivide a bezier-curve until each are flat enough.

Parameters
rresulting list of linear segments.
minimumFlatnessminimum amount of flatness of the resulting curve segments.

◆ tangentAt()

vec tt::BezierCurve::tangentAt ( float const t) const
inlinenoexcept

Return a tangent on the bezier-curve. Values of t beyond 0.0 and 1.0 will find a point extrapolated beyond the bezier segment.

Parameters
ta relative distance between 0.0 (point P1) and 1.0 (point P2).
Returns
the tangent-vector at point t on the curve

◆ toParrallelLine()

BezierCurve tt::BezierCurve::toParrallelLine ( float const offset) const
inlinenoexcept

Return a line-segment from a curve at a certain distance.

Parameters
offsetpositive means the parallel line will be on the starboard of the curve.
Returns
line segment offset from the curve.

Friends And Related Symbol Documentation

◆ operator~

BezierCurve operator~ ( BezierCurve const & rhs)
friend

Reverse direction of a curve.

Field Documentation

◆ C1

vec tt::BezierCurve::C1

Control point.

◆ C2

vec tt::BezierCurve::C2

Control point.

◆ P1

vec tt::BezierCurve::P1

First point.

◆ P2

vec tt::BezierCurve::P2

Last point.


The documentation for this struct was generated from the following file: