Flutter Impeller
impeller::TPoint< T > Struct Template Reference

#include <point.h>

Public Types

using Type = T
 

Public Member Functions

constexpr TPoint ()=default
 
template<class U >
constexpr TPoint (const TPoint< U > &other)
 
template<class U >
constexpr TPoint (const TSize< U > &other)
 
constexpr TPoint (Type x, Type y)
 
constexpr bool operator== (const TPoint &p) const
 
constexpr bool operator!= (const TPoint &p) const
 
template<class U >
TPoint operator+= (const TPoint< U > &p)
 
template<class U >
TPoint operator+= (const TSize< U > &s)
 
template<class U >
TPoint operator-= (const TPoint< U > &p)
 
template<class U >
TPoint operator-= (const TSize< U > &s)
 
template<class U >
TPoint operator*= (const TPoint< U > &p)
 
template<class U >
TPoint operator*= (const TSize< U > &s)
 
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
TPoint operator*= (U scale)
 
template<class U >
TPoint operator/= (const TPoint< U > &p)
 
template<class U >
TPoint operator/= (const TSize< U > &s)
 
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
TPoint operator/= (U scale)
 
constexpr TPoint operator- () const
 
constexpr TPoint operator+ (const TPoint &p) const
 
template<class U >
constexpr TPoint operator+ (const TSize< U > &s) const
 
constexpr TPoint operator- (const TPoint &p) const
 
template<class U >
constexpr TPoint operator- (const TSize< U > &s) const
 
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr TPoint operator* (U scale) const
 
constexpr TPoint operator* (const TPoint &p) const
 
template<class U >
constexpr TPoint operator* (const TSize< U > &s) const
 
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr TPoint operator/ (U d) const
 
constexpr TPoint operator/ (const TPoint &p) const
 
template<class U >
constexpr TPoint operator/ (const TSize< U > &s) const
 
constexpr Type GetDistanceSquared (const TPoint &p) const
 
constexpr TPoint Min (const TPoint &p) const
 
constexpr TPoint Max (const TPoint &p) const
 
constexpr TPoint Floor () const
 
constexpr TPoint Ceil () const
 
constexpr TPoint Round () const
 
constexpr Type GetDistance (const TPoint &p) const
 
constexpr Scalar GetLengthSquared () const
 
constexpr Scalar GetLength () const
 
Type GetDistanceToSegmentSquared (TPoint p0, TPoint p1) const
 
constexpr Type GetDistanceToSegment (TPoint p0, TPoint p1) const
 
constexpr TPoint Normalize () const
 
constexpr TPoint Abs () const
 
constexpr Type Cross (const TPoint &p) const
 
constexpr Type Dot (const TPoint &p) const
 
constexpr TPoint Reflect (const TPoint &axis) const
 
constexpr TPoint Rotate (const Radians &angle) const
 
constexpr TPoint PerpendicularRight () const
 
constexpr TPoint PerpendicularLeft () const
 
constexpr Radians AngleTo (const TPoint &p) const
 
constexpr TPoint Lerp (const TPoint &p, Scalar t) const
 
constexpr bool IsZero () const
 
 IsFinite () const
 

Static Public Member Functions

static constexpr TPoint< TypeMakeXY (Type x, Type y)
 
template<class U >
static constexpr TPoint Round (const TPoint< U > &other)
 
static constexpr Type Cross (const TPoint &p0, const TPoint &p1, const TPoint &p2)
 

Public Attributes

Type x = {}
 
Type y = {}
 

Detailed Description

template<class T>
struct impeller::TPoint< T >

Definition at line 28 of file point.h.

Member Typedef Documentation

◆ Type

template<class T >
using impeller::TPoint< T >::Type = T

Definition at line 29 of file point.h.

Constructor & Destructor Documentation

◆ TPoint() [1/4]

template<class T >
constexpr impeller::TPoint< T >::TPoint ( )
constexprdefault

◆ TPoint() [2/4]

template<class T >
template<class U >
constexpr impeller::TPoint< T >::TPoint ( const TPoint< U > &  other)
inlineexplicitconstexpr

Definition at line 37 of file point.h.

38  : TPoint(static_cast<Type>(other.x), static_cast<Type>(other.y)) {}
constexpr TPoint()=default

◆ TPoint() [3/4]

template<class T >
template<class U >
constexpr impeller::TPoint< T >::TPoint ( const TSize< U > &  other)
inlineexplicitconstexpr

Definition at line 41 of file point.h.

42  : TPoint(static_cast<Type>(other.width),
43  static_cast<Type>(other.height)) {}

◆ TPoint() [4/4]

template<class T >
constexpr impeller::TPoint< T >::TPoint ( Type  x,
Type  y 
)
inlineconstexpr

Definition at line 45 of file point.h.

45 : x(x), y(y) {}

Member Function Documentation

◆ Abs()

template<class T >
constexpr TPoint impeller::TPoint< T >::Abs ( ) const
inlineconstexpr

Definition at line 294 of file point.h.

294 { return {std::fabs(x), std::fabs(y)}; }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::testing::TEST().

◆ AngleTo()

template<class T >
constexpr Radians impeller::TPoint< T >::AngleTo ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 331 of file point.h.

331  {
332  return Radians{std::atan2(this->Cross(p), this->Dot(p))};
333  }
constexpr Type Cross(const TPoint &p) const
Definition: point.h:296
constexpr Type Dot(const TPoint &p) const
Definition: point.h:309

References impeller::TPoint< T >::Cross(), and impeller::TPoint< T >::Dot().

Referenced by impeller::SeparatedVector2::AngleTo(), and impeller::testing::TEST().

◆ Ceil()

template<class T >
constexpr TPoint impeller::TPoint< T >::Ceil ( ) const
inlineconstexpr

Definition at line 197 of file point.h.

197 { return {std::ceil(x), std::ceil(y)}; }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::testing::TEST().

◆ Cross() [1/2]

template<class T >
constexpr Type impeller::TPoint< T >::Cross ( const TPoint< T > &  p) const
inlineconstexpr

◆ Cross() [2/2]

template<class T >
static constexpr Type impeller::TPoint< T >::Cross ( const TPoint< T > &  p0,
const TPoint< T > &  p1,
const TPoint< T > &  p2 
)
inlinestaticconstexpr

Return the cross product representing the sign (turning direction) and magnitude (sin of the angle) of the angle from p1 to p2 as viewed from p0.

Equivalent to ((p1 - p0).Cross(p2 - p0)).

Definition at line 303 of file point.h.

305  {
306  return (p1 - p0).Cross(p2 - p0);
307  }

References p1, and p2.

◆ Dot()

◆ Floor()

template<class T >
constexpr TPoint impeller::TPoint< T >::Floor ( ) const
inlineconstexpr

Definition at line 195 of file point.h.

195 { return {std::floor(x), std::floor(y)}; }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::testing::TEST().

◆ GetDistance()

template<class T >
constexpr Type impeller::TPoint< T >::GetDistance ( const TPoint< T > &  p) const
inlineconstexpr

◆ GetDistanceSquared()

template<class T >
constexpr Type impeller::TPoint< T >::GetDistanceSquared ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 181 of file point.h.

181  {
182  double dx = p.x - x;
183  double dy = p.y - y;
184  return dx * dx + dy * dy;
185  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::TPoint< T >::GetDistance(), and impeller::TPoint< T >::GetDistanceToSegmentSquared().

◆ GetDistanceToSegment()

template<class T >
constexpr Type impeller::TPoint< T >::GetDistanceToSegment ( TPoint< T >  p0,
TPoint< T >  p1 
) const
inlineconstexpr

Returns the distance from this point to the closest point on the line segment p0 -> p1.

If the projection of this point onto the line defined by the two points is between them, the distance to that point is returned. Otherwise, we return the distance to the endpoint that is closer to the projected point.

Definition at line 282 of file point.h.

282  {
283  return std::sqrt(GetDistanceToSegmentSquared(p0, p1));
284  }
Type GetDistanceToSegmentSquared(TPoint p0, TPoint p1) const
Definition: point.h:219

References impeller::TPoint< T >::GetDistanceToSegmentSquared(), and p1.

◆ GetDistanceToSegmentSquared()

template<class T >
Type impeller::TPoint< T >::GetDistanceToSegmentSquared ( TPoint< T >  p0,
TPoint< T >  p1 
) const
inline

Returns the distance (squared) from this point to the closest point on the line segment p0 -> p1.

If the projection of this point onto the line defined by the two points is between them, the distance (squared) to that point is returned. Otherwise, we return the distance (squared) to the endpoint that is closer to the projected point.

Definition at line 219 of file point.h.

219  {
220  // Compute relative vectors to one endpoint of the segment (p0)
221  TPoint u = p1 - p0;
222  TPoint v = *this - p0;
223 
224  // Compute the projection of (this point) onto p0->p1.
225  Scalar dot = u.Dot(v);
226  if (dot <= 0) {
227  // The projection lands outside the segment on the p0 side.
228  // The result is the (square of the) distance to p0 (length of v).
229  return v.GetLengthSquared();
230  }
231 
232  // The dot product is the product of the length of the two vectors
233  // ||u|| and ||v|| and the cosine of the angle between them. The length
234  // of the v vector times the cosine is the same as the length of
235  // the projection of the v vector onto the u vector (consider a right
236  // triangle [(0,0), v, v_projected], the length of v multipled by the
237  // cosine is the length of v_projected).
238  //
239  // Thus the dot product is also the product of the u vector and the
240  // projected shadow of the v vector onto the u vector.
241  //
242  // So, if the dot product is larger than the square of the length of
243  // the u vector, then the v vector was projected onto the line beyond
244  // the end of the u vector and so we can use the distance formula to
245  // that endpoint as our result.
246  Scalar uLengthSquared = u.GetLengthSquared();
247  if (dot >= uLengthSquared) {
248  // The projection lands outside the segment on the p1 side.
249  // The result is the (square of the) distance to p1.
250  return GetDistanceSquared(p1);
251  }
252 
253  // We must now compute the distance from this point to its projection
254  // on to the segment.
255  //
256  // We compute the cross product of the two vectors u and v which
257  // gives us the area of the parallelogram [(0,0), u, u+v, v]. That
258  // parallelogram area is also the product of the length of one of its
259  // sides and the height perpendicular to that side. We have the length
260  // of one side which is the length of the segment itself (squared) as
261  // uLengthSquared, so if we divide the parallelogram area (squared)
262  // by uLengthSquared then we will get its height (squared) relative to u.
263  //
264  // That height is also the distance from this point to the line segment.
265  Scalar cross = u.Cross(v);
266  // The cross product may currently be signed, but we will square it later.
267 
268  // To get our height (squared), we want to compute:
269  // result^2 == h^2 == (cross * cross / uLengthSquared)
270  //
271  // We reorder the equation slightly to avoid infinities:
272  return (cross / uLengthSquared) * cross;
273  }
float Scalar
Definition: scalar.h:19

References impeller::TPoint< T >::Cross(), impeller::TPoint< T >::Dot(), impeller::TPoint< T >::GetDistanceSquared(), impeller::TPoint< T >::GetLengthSquared(), and p1.

Referenced by impeller::TPoint< T >::GetDistanceToSegment().

◆ GetLength()

template<class T >
constexpr Scalar impeller::TPoint< T >::GetLength ( ) const
inlineconstexpr

◆ GetLengthSquared()

template<class T >
constexpr Scalar impeller::TPoint< T >::GetLengthSquared ( ) const
inlineconstexpr

Definition at line 205 of file point.h.

205  {
206  return static_cast<Scalar>(static_cast<double>(x) * x +
207  static_cast<double>(y) * y);
208  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::ComputeCubicSubdivisions(), impeller::CornerContains(), impeller::TPoint< T >::GetDistanceToSegmentSquared(), and impeller::TPoint< T >::GetLength().

◆ IsFinite()

template<class T >
impeller::TPoint< T >::IsFinite ( ) const
inline

Definition at line 342 of file point.h.

342 { return std::isfinite(x) && std::isfinite(y); }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ IsZero()

template<class T >
constexpr bool impeller::TPoint< T >::IsZero ( ) const
inlineconstexpr

Definition at line 339 of file point.h.

339 { return x == 0 && y == 0; }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::DirectionalMorphologyFilterContents::SetDirection().

◆ Lerp()

template<class T >
constexpr TPoint impeller::TPoint< T >::Lerp ( const TPoint< T > &  p,
Scalar  t 
) const
inlineconstexpr

Definition at line 335 of file point.h.

335  {
336  return *this + (p - *this) * t;
337  }

Referenced by impeller::testing::TEST().

◆ MakeXY()

template<class T >
static constexpr TPoint<Type> impeller::TPoint< T >::MakeXY ( Type  x,
Type  y 
)
inlinestaticconstexpr

Definition at line 47 of file point.h.

47 { return {x, y}; }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ Max()

template<class T >
constexpr TPoint impeller::TPoint< T >::Max ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 191 of file point.h.

191  {
192  return {std::max<Type>(x, p.x), std::max<Type>(y, p.y)};
193  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::ComputeConicSubdivisions(), and impeller::testing::TEST().

◆ Min()

template<class T >
constexpr TPoint impeller::TPoint< T >::Min ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 187 of file point.h.

187  {
188  return {std::min<Type>(x, p.x), std::min<Type>(y, p.y)};
189  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::ComputeConicSubdivisions(), and impeller::testing::TEST().

◆ Normalize()

template<class T >
constexpr TPoint impeller::TPoint< T >::Normalize ( ) const
inlineconstexpr

Definition at line 286 of file point.h.

286  {
287  const auto length = GetLength();
288  if (length == 0) {
289  return {1, 0};
290  }
291  return {x / length, y / length};
292  }
constexpr Scalar GetLength() const
Definition: point.h:210

References impeller::TPoint< T >::GetLength(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::DirectionalMorphologyFilterContents::SetDirection(), and impeller::testing::TEST().

◆ operator!=()

template<class T >
constexpr bool impeller::TPoint< T >::operator!= ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 59 of file point.h.

59  {
60  return p.x != x || p.y != y;
61  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator*() [1/3]

template<class T >
constexpr TPoint impeller::TPoint< T >::operator* ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 158 of file point.h.

158  {
159  return {x * p.x, y * p.y};
160  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator*() [2/3]

template<class T >
template<class U >
constexpr TPoint impeller::TPoint< T >::operator* ( const TSize< U > &  s) const
inlineconstexpr

Definition at line 163 of file point.h.

163  {
164  return {x * static_cast<Type>(s.width), y * static_cast<Type>(s.height)};
165  }

References impeller::TSize< T >::height, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator*() [3/3]

template<class T >
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr TPoint impeller::TPoint< T >::operator* ( scale) const
inlineconstexpr

Definition at line 154 of file point.h.

154  {
155  return {static_cast<Type>(x * scale), static_cast<Type>(y * scale)};
156  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator*=() [1/3]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator*= ( const TPoint< U > &  p)
inline

Definition at line 92 of file point.h.

92  {
93  x *= static_cast<Type>(p.x);
94  y *= static_cast<Type>(p.y);
95  return *this;
96  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator*=() [2/3]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator*= ( const TSize< U > &  s)
inline

Definition at line 99 of file point.h.

99  {
100  x *= static_cast<Type>(s.width);
101  y *= static_cast<Type>(s.height);
102  return *this;
103  }

References impeller::TSize< T >::height, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator*=() [3/3]

template<class T >
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
TPoint impeller::TPoint< T >::operator*= ( scale)
inline

Definition at line 106 of file point.h.

106  {
107  x *= static_cast<Type>(scale);
108  y *= static_cast<Type>(scale);
109  return *this;
110  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator+() [1/2]

template<class T >
constexpr TPoint impeller::TPoint< T >::operator+ ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 135 of file point.h.

135  {
136  return {x + p.x, y + p.y};
137  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator+() [2/2]

template<class T >
template<class U >
constexpr TPoint impeller::TPoint< T >::operator+ ( const TSize< U > &  s) const
inlineconstexpr

Definition at line 140 of file point.h.

140  {
141  return {x + static_cast<Type>(s.width), y + static_cast<Type>(s.height)};
142  }

References impeller::TSize< T >::height, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator+=() [1/2]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator+= ( const TPoint< U > &  p)
inline

Definition at line 64 of file point.h.

64  {
65  x += static_cast<Type>(p.x);
66  y += static_cast<Type>(p.y);
67  return *this;
68  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator+=() [2/2]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator+= ( const TSize< U > &  s)
inline

Definition at line 71 of file point.h.

71  {
72  x += static_cast<Type>(s.width);
73  y += static_cast<Type>(s.height);
74  return *this;
75  }

References impeller::TSize< T >::height, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator-() [1/3]

template<class T >
constexpr TPoint impeller::TPoint< T >::operator- ( ) const
inlineconstexpr

Definition at line 133 of file point.h.

133 { return {-x, -y}; }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator-() [2/3]

template<class T >
constexpr TPoint impeller::TPoint< T >::operator- ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 144 of file point.h.

144  {
145  return {x - p.x, y - p.y};
146  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator-() [3/3]

template<class T >
template<class U >
constexpr TPoint impeller::TPoint< T >::operator- ( const TSize< U > &  s) const
inlineconstexpr

Definition at line 149 of file point.h.

149  {
150  return {x - static_cast<Type>(s.width), y - static_cast<Type>(s.height)};
151  }

References impeller::TSize< T >::height, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator-=() [1/2]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator-= ( const TPoint< U > &  p)
inline

Definition at line 78 of file point.h.

78  {
79  x -= static_cast<Type>(p.x);
80  y -= static_cast<Type>(p.y);
81  return *this;
82  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator-=() [2/2]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator-= ( const TSize< U > &  s)
inline

Definition at line 85 of file point.h.

85  {
86  x -= static_cast<Type>(s.width);
87  y -= static_cast<Type>(s.height);
88  return *this;
89  }

References impeller::TSize< T >::height, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator/() [1/3]

template<class T >
constexpr TPoint impeller::TPoint< T >::operator/ ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 172 of file point.h.

172  {
173  return {x / p.x, y / p.y};
174  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator/() [2/3]

template<class T >
template<class U >
constexpr TPoint impeller::TPoint< T >::operator/ ( const TSize< U > &  s) const
inlineconstexpr

Definition at line 177 of file point.h.

177  {
178  return {x / static_cast<Type>(s.width), y / static_cast<Type>(s.height)};
179  }

References impeller::TSize< T >::height, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator/() [3/3]

template<class T >
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr TPoint impeller::TPoint< T >::operator/ ( d) const
inlineconstexpr

Definition at line 168 of file point.h.

168  {
169  return {static_cast<Type>(x / d), static_cast<Type>(y / d)};
170  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator/=() [1/3]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator/= ( const TPoint< U > &  p)
inline

Definition at line 113 of file point.h.

113  {
114  x /= static_cast<Type>(p.x);
115  y /= static_cast<Type>(p.y);
116  return *this;
117  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator/=() [2/3]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator/= ( const TSize< U > &  s)
inline

Definition at line 120 of file point.h.

120  {
121  x /= static_cast<Type>(s.width);
122  y /= static_cast<Type>(s.height);
123  return *this;
124  }

References impeller::TSize< T >::height, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator/=() [3/3]

template<class T >
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
TPoint impeller::TPoint< T >::operator/= ( scale)
inline

Definition at line 127 of file point.h.

127  {
128  x /= static_cast<Type>(scale);
129  y /= static_cast<Type>(scale);
130  return *this;
131  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ operator==()

template<class T >
constexpr bool impeller::TPoint< T >::operator== ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 55 of file point.h.

55  {
56  return p.x == x && p.y == y;
57  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ PerpendicularLeft()

template<class T >
constexpr TPoint impeller::TPoint< T >::PerpendicularLeft ( ) const
inlineconstexpr

Return the perpendicular vector turning to the left (Counterclockwise) in the logical coordinate system where X increases to the right and Y increases downward.

Definition at line 329 of file point.h.

329 { return {y, -x}; }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ PerpendicularRight()

template<class T >
constexpr TPoint impeller::TPoint< T >::PerpendicularRight ( ) const
inlineconstexpr

Return the perpendicular vector turning to the right (Clockwise) in the logical coordinate system where X increases to the right and Y increases downward.

Definition at line 324 of file point.h.

324 { return {-y, x}; }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ Reflect()

template<class T >
constexpr TPoint impeller::TPoint< T >::Reflect ( const TPoint< T > &  axis) const
inlineconstexpr

Definition at line 311 of file point.h.

311  {
312  return *this - axis * this->Dot(axis) * 2;
313  }

References impeller::TPoint< T >::Dot().

Referenced by impeller::testing::TEST().

◆ Rotate()

template<class T >
constexpr TPoint impeller::TPoint< T >::Rotate ( const Radians angle) const
inlineconstexpr

Definition at line 315 of file point.h.

315  {
316  const auto cos_a = std::cosf(angle.radians);
317  const auto sin_a = std::sinf(angle.radians);
318  return {x * cos_a - y * sin_a, x * sin_a + y * cos_a};
319  }

References impeller::Radians::radians, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::testing::TEST(), impeller::testing::TEST_P(), and flutter::testing::TEST_P().

◆ Round() [1/2]

template<class T >
constexpr TPoint impeller::TPoint< T >::Round ( ) const
inlineconstexpr

Definition at line 199 of file point.h.

199 { return {std::round(x), std::round(y)}; }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ Round() [2/2]

template<class T >
template<class U >
static constexpr TPoint impeller::TPoint< T >::Round ( const TPoint< U > &  other)
inlinestaticconstexpr

Definition at line 50 of file point.h.

50  {
51  return TPoint{static_cast<Type>(std::round(other.x)),
52  static_cast<Type>(std::round(other.y))};
53  }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::TextContents::ComputeVertexData(), and impeller::testing::TEST().

Member Data Documentation

◆ x

template<class T >
Type impeller::TPoint< T >::x = {}

Definition at line 31 of file point.h.

Referenced by impeller::TPoint< T >::Abs(), impeller::LineContents::CalculatePerVertex(), impeller::testing::CanRenderConicalGradientWithDithering(), impeller::testing::CanRenderSweepGradientWithDithering(), impeller::TPoint< T >::Ceil(), impeller::TextFrame::ComputeSubpixelPosition(), impeller::TextContents::ComputeVertexData(), impeller::SolidRRectLikeBlurContents::Concat(), impeller::TRect< T >::Contains(), impeller::TRect< T >::ContainsInclusive(), impeller::CornerContains(), impeller::Paint::MaskBlurDescriptor::CreateMaskBlur(), impeller::TPoint< T >::Cross(), impeller::EllipsePathSource::Dispatch(), impeller::testing::DoGradientOvalStrokeMaskBlur(), impeller::TPoint< T >::Dot(), impeller::Canvas::DrawCircle(), impeller::DrawGlyph(), impeller::interop::DisplayListBuilder::DrawParagraph(), impeller::DrawPlaygroundPoint(), impeller::eccentricity(), impeller::BlitCopyTextureToTextureCommandGLES::Encode(), impeller::TRect< T >::Expand(), impeller::TPoint< T >::Floor(), impeller::DashedLinePathSource::GetBounds(), impeller::PlaygroundImpl::GetContentScale(), impeller::PointFieldGeometry::GetCoverage(), impeller::TPoint< T >::GetDistanceSquared(), impeller::GaussianBlurFilterContents::GetFilterSourceCoverage(), impeller::TPoint< T >::GetLengthSquared(), impeller::GaussianBlurFilterContents::GetSigmaX(), impeller::TPoint< T >::IsFinite(), impeller::TPoint< T >::IsZero(), impeller::LerpHackKernelSamples(), impeller::RSTransform::Make(), impeller::UberSDFContents::MakeCircle(), impeller::TRect< T >::MakeOriginSize(), impeller::Matrix::MakeRotation(), impeller::Matrix::MakeRotationX(), impeller::Matrix::MakeRotationY(), impeller::Matrix::MakeRotationZ(), impeller::Matrix::MakeScale(), impeller::GoldenPlaygroundTest::MakeScreenshot(), impeller::MakeTextFrameFromTextBlobSkia(), impeller::TPoint< T >::MakeXY(), impeller::testing::MaskBlurVariantTest(), impeller::TPoint< T >::Max(), impeller::TPoint< T >::Min(), impeller::TPoint< T >::Normalize(), impeller::GoldenPlaygroundTest::OpenPlaygroundHere(), impeller::TPoint< T >::operator!=(), impeller::Matrix::operator*(), impeller::operator*(), impeller::Trig::operator*(), impeller::TPoint< T >::operator*(), impeller::TPoint< T >::operator*=(), impeller::TPoint< T >::operator+(), impeller::operator+(), impeller::TPoint< T >::operator+=(), impeller::TPoint< T >::operator-(), impeller::operator-(), impeller::TPoint< T >::operator-=(), impeller::operator/(), impeller::TPoint< T >::operator/(), impeller::TPoint< T >::operator/=(), std::operator<<(), impeller::TPoint< T >::operator==(), impeller::TPoint< T >::PerpendicularLeft(), impeller::TPoint< T >::PerpendicularRight(), PointNear(), impeller::StrokePathSegmentReceiver::RecordArc(), impeller::SolidRRectLikeBlurContents::Render(), impeller::TPoint< T >::Rotate(), impeller::TPoint< T >::Round(), impeller::TRect< T >::Scale(), impeller::TRect< T >::Shift(), impeller::testing::swap_nan(), impeller::testing::TEST(), impeller::testing::TEST_P(), flutter::testing::TEST_P(), impeller::interop::ToSkiaType(), impeller::Matrix::TransformDirection(), impeller::Matrix::TransformHomogenous(), and impeller::interop::DisplayListBuilder::Translate().

◆ y

template<class T >
Type impeller::TPoint< T >::y = {}

Definition at line 32 of file point.h.

Referenced by impeller::TPoint< T >::Abs(), impeller::LineContents::CalculatePerVertex(), impeller::testing::CanRenderConicalGradientWithDithering(), impeller::testing::CanRenderSweepGradientWithDithering(), impeller::TPoint< T >::Ceil(), impeller::TextFrame::ComputeSubpixelPosition(), impeller::TextContents::ComputeVertexData(), impeller::SolidRRectLikeBlurContents::Concat(), impeller::TRect< T >::Contains(), impeller::TRect< T >::ContainsInclusive(), impeller::CornerContains(), impeller::Paint::MaskBlurDescriptor::CreateMaskBlur(), impeller::TPoint< T >::Cross(), impeller::EllipsePathSource::Dispatch(), impeller::testing::DoGradientOvalStrokeMaskBlur(), impeller::TPoint< T >::Dot(), impeller::Canvas::DrawCircle(), impeller::DrawGlyph(), impeller::interop::DisplayListBuilder::DrawParagraph(), impeller::DrawPlaygroundPoint(), impeller::eccentricity(), impeller::BlitCopyTextureToTextureCommandGLES::Encode(), impeller::TRect< T >::Expand(), impeller::TPoint< T >::Floor(), impeller::DashedLinePathSource::GetBounds(), impeller::PlaygroundImpl::GetContentScale(), impeller::PointFieldGeometry::GetCoverage(), impeller::TPoint< T >::GetDistanceSquared(), impeller::GaussianBlurFilterContents::GetFilterSourceCoverage(), impeller::TPoint< T >::GetLengthSquared(), impeller::GaussianBlurFilterContents::GetSigmaY(), impeller::TPoint< T >::IsFinite(), impeller::TPoint< T >::IsZero(), impeller::LerpHackKernelSamples(), impeller::RSTransform::Make(), impeller::UberSDFContents::MakeCircle(), impeller::TRect< T >::MakeOriginSize(), impeller::Matrix::MakeRotation(), impeller::Matrix::MakeRotationX(), impeller::Matrix::MakeRotationY(), impeller::Matrix::MakeRotationZ(), impeller::Matrix::MakeScale(), impeller::GoldenPlaygroundTest::MakeScreenshot(), impeller::TPoint< T >::MakeXY(), impeller::testing::MaskBlurVariantTest(), impeller::TPoint< T >::Max(), impeller::TPoint< T >::Min(), impeller::TPoint< T >::Normalize(), impeller::GoldenPlaygroundTest::OpenPlaygroundHere(), impeller::TPoint< T >::operator!=(), impeller::Matrix::operator*(), impeller::operator*(), impeller::Trig::operator*(), impeller::TPoint< T >::operator*(), impeller::TPoint< T >::operator*=(), impeller::TPoint< T >::operator+(), impeller::operator+(), impeller::TPoint< T >::operator+=(), impeller::TPoint< T >::operator-(), impeller::operator-(), impeller::TPoint< T >::operator-=(), impeller::operator/(), impeller::TPoint< T >::operator/(), impeller::TPoint< T >::operator/=(), std::operator<<(), impeller::TPoint< T >::operator==(), impeller::TPoint< T >::PerpendicularLeft(), impeller::TPoint< T >::PerpendicularRight(), PointNear(), impeller::StrokePathSegmentReceiver::RecordArc(), impeller::SolidRRectLikeBlurContents::Render(), impeller::TPoint< T >::Rotate(), impeller::TPoint< T >::Round(), impeller::TRect< T >::Scale(), impeller::TRect< T >::Shift(), impeller::testing::swap_nan(), impeller::testing::TEST(), impeller::testing::TEST_P(), flutter::testing::TEST_P(), impeller::interop::ToSkiaType(), impeller::Matrix::TransformDirection(), impeller::Matrix::TransformHomogenous(), and impeller::interop::DisplayListBuilder::Translate().


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