Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
impeller::QuadraticPathComponent Struct Reference

#include <path_component.h>

Public Types

using PointProc = std::function< void(const Point &point)>
 

Public Member Functions

 QuadraticPathComponent ()
 
 QuadraticPathComponent (Point ap1, Point acp, Point ap2)
 
Point Solve (Scalar time) const
 
Point SolveDerivative (Scalar time) const
 
void AppendPolylinePoints (Scalar scale_factor, std::vector< Point > &points) const
 
void ToLinearPathComponents (Scalar scale_factor, const PointProc &proc) const
 
std::vector< PointExtrema () const
 
bool operator== (const QuadraticPathComponent &other) const
 
std::optional< Vector2GetStartDirection () const
 
std::optional< Vector2GetEndDirection () const
 

Public Attributes

Point p1
 
Point cp
 
Point p2
 

Detailed Description

Definition at line 43 of file path_component.h.

Member Typedef Documentation

◆ PointProc

using impeller::QuadraticPathComponent::PointProc = std::function<void(const Point& point)>

Definition at line 63 of file path_component.h.

Constructor & Destructor Documentation

◆ QuadraticPathComponent() [1/2]

impeller::QuadraticPathComponent::QuadraticPathComponent ( )
inline

Definition at line 51 of file path_component.h.

51{}

◆ QuadraticPathComponent() [2/2]

impeller::QuadraticPathComponent::QuadraticPathComponent ( Point  ap1,
Point  acp,
Point  ap2 
)
inline

Member Function Documentation

◆ AppendPolylinePoints()

void impeller::QuadraticPathComponent::AppendPolylinePoints ( Scalar  scale_factor,
std::vector< Point > &  points 
) const

Definition at line 103 of file path_component.cc.

105 {
106 ToLinearPathComponents(scale_factor, [&points](const Point& point) {
107 points.emplace_back(point);
108 });
109}
static const int points[]
TPoint< Scalar > Point
Definition point.h:316
void ToLinearPathComponents(Scalar scale_factor, const PointProc &proc) const

◆ Extrema()

std::vector< Point > impeller::QuadraticPathComponent::Extrema ( ) const

Definition at line 122 of file path_component.cc.

122 {
123 CubicPathComponent elevated(*this);
124 return elevated.Extrema();
125}

◆ GetEndDirection()

std::optional< Vector2 > impeller::QuadraticPathComponent::GetEndDirection ( ) const

Definition at line 137 of file path_component.cc.

137 {
138 if (p2 != cp) {
139 return (p2 - cp).Normalize();
140 }
141 if (p2 != p1) {
142 return (p2 - p1).Normalize();
143 }
144 return std::nullopt;
145}

◆ GetStartDirection()

std::optional< Vector2 > impeller::QuadraticPathComponent::GetStartDirection ( ) const

Definition at line 127 of file path_component.cc.

127 {
128 if (p1 != cp) {
129 return (p1 - cp).Normalize();
130 }
131 if (p1 != p2) {
132 return (p1 - p2).Normalize();
133 }
134 return std::nullopt;
135}

◆ operator==()

bool impeller::QuadraticPathComponent::operator== ( const QuadraticPathComponent other) const
inline

Definition at line 69 of file path_component.h.

69 {
70 return p1 == other.p1 && cp == other.cp && p2 == other.p2;
71 }

◆ Solve()

Point impeller::QuadraticPathComponent::Solve ( Scalar  time) const

Definition at line 89 of file path_component.cc.

89 {
90 return {
91 QuadraticSolve(time, p1.x, cp.x, p2.x), // x
92 QuadraticSolve(time, p1.y, cp.y, p2.y), // y
93 };
94}
static Scalar QuadraticSolve(Scalar t, Scalar p0, Scalar p1, Scalar p2)

◆ SolveDerivative()

Point impeller::QuadraticPathComponent::SolveDerivative ( Scalar  time) const

Definition at line 96 of file path_component.cc.

96 {
97 return {
98 QuadraticSolveDerivative(time, p1.x, cp.x, p2.x), // x
99 QuadraticSolveDerivative(time, p1.y, cp.y, p2.y), // y
100 };
101}
static Scalar QuadraticSolveDerivative(Scalar t, Scalar p0, Scalar p1, Scalar p2)

◆ ToLinearPathComponents()

void impeller::QuadraticPathComponent::ToLinearPathComponents ( Scalar  scale_factor,
const PointProc proc 
) const

Definition at line 111 of file path_component.cc.

113 {
114 Scalar line_count =
115 std::ceilf(ComputeQuadradicSubdivisions(scale_factor, *this));
116 for (size_t i = 1; i < line_count; i += 1) {
117 proc(Solve(i / line_count));
118 }
119 proc(p2);
120}
float Scalar
Definition scalar.h:18
Scalar ComputeQuadradicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2)
Point Solve(Scalar time) const

Member Data Documentation

◆ cp

Point impeller::QuadraticPathComponent::cp

Definition at line 47 of file path_component.h.

◆ p1

Point impeller::QuadraticPathComponent::p1

Definition at line 45 of file path_component.h.

◆ p2

Point impeller::QuadraticPathComponent::p2

Definition at line 49 of file path_component.h.


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