Flutter Impeller
impeller::Vector4 Struct Reference

#include <vector.h>

Public Member Functions

constexpr Vector4 ()
 
constexpr Vector4 (const Color &c)
 
constexpr Vector4 (Scalar x, Scalar y, Scalar z, Scalar w)
 
constexpr Vector4 (const Vector3 &v)
 
constexpr Vector4 (const Point &p)
 
constexpr Vector4 (std::array< Scalar, 4 > values)
 
bool IsFinite () const
 
Vector4 Normalize () const
 
constexpr bool operator== (const Vector4 &v) const
 
constexpr bool operator!= (const Vector4 &v) const
 
constexpr Vector4 operator+ (const Vector4 &v) const
 
constexpr Vector4 operator- (const Vector4 &v) const
 
constexpr Vector4 operator* (Scalar f) const
 
constexpr Vector4 operator* (const Vector4 &v) const
 
constexpr Vector4 Min (const Vector4 &p) const
 
constexpr Vector4 Max (const Vector4 &p) const
 
Vector4 Floor () const
 
Vector4 Ceil () const
 
Vector4 Round () const
 
constexpr Vector4 Lerp (const Vector4 &v, Scalar t) const
 
constexpr Vector2 xy () const
 

Public Attributes

union {
   struct {
      Scalar   x = 0.0f
 
      Scalar   y = 0.0f
 
      Scalar   z = 0.0f
 
      Scalar   w = 1.0f
 
   } 
 
   Scalar   e [4]
 
}; 
 

Detailed Description

Definition at line 230 of file vector.h.

Constructor & Destructor Documentation

◆ Vector4() [1/6]

constexpr impeller::Vector4::Vector4 ( )
inlineconstexpr

Definition at line 241 of file vector.h.

241 {}

Referenced by Normalize(), operator*(), operator+(), and operator-().

◆ Vector4() [2/6]

constexpr impeller::Vector4::Vector4 ( const Color &  c)
inlineconstexpr

Definition at line 243 of file vector.h.

244  : x(c.red), y(c.green), z(c.blue), w(c.alpha) {}

◆ Vector4() [3/6]

constexpr impeller::Vector4::Vector4 ( Scalar  x,
Scalar  y,
Scalar  z,
Scalar  w 
)
inlineconstexpr

Definition at line 246 of file vector.h.

247  : x(x), y(y), z(z), w(w) {}

◆ Vector4() [4/6]

constexpr impeller::Vector4::Vector4 ( const Vector3 &  v)
inlineconstexpr

Definition at line 249 of file vector.h.

249 : x(v.x), y(v.y), z(v.z) {}

◆ Vector4() [5/6]

constexpr impeller::Vector4::Vector4 ( const Point &  p)
inlineconstexpr

Definition at line 251 of file vector.h.

251 : x(p.x), y(p.y) {}

◆ Vector4() [6/6]

constexpr impeller::Vector4::Vector4 ( std::array< Scalar, 4 >  values)
inlineconstexpr

Definition at line 253 of file vector.h.

254  : x(values[0]), y(values[1]), z(values[2]), w(values[3]) {}

Member Function Documentation

◆ Ceil()

Vector4 impeller::Vector4::Ceil ( ) const
inline

Definition at line 304 of file vector.h.

304  {
305  return {std::ceil(x), std::ceil(y), std::ceil(z), std::ceil(w)};
306  }

References w, x, y, and z.

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

◆ Floor()

Vector4 impeller::Vector4::Floor ( ) const
inline

Definition at line 300 of file vector.h.

300  {
301  return {std::floor(x), std::floor(y), std::floor(z), std::floor(w)};
302  }

References w, x, y, and z.

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

◆ IsFinite()

bool impeller::Vector4::IsFinite ( ) const
inline

Definition at line 256 of file vector.h.

256  {
257  return std::isfinite(x) && std::isfinite(y) && std::isfinite(z) &&
258  std::isfinite(w);
259  }

References w, x, y, and z.

Referenced by impeller::Matrix::IsFinite(), and impeller::testing::TEST().

◆ Lerp()

constexpr Vector4 impeller::Vector4::Lerp ( const Vector4 &  v,
Scalar  t 
) const
inlineconstexpr

Definition at line 312 of file vector.h.

312  {
313  return *this + (v - *this) * t;
314  }

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

◆ Max()

constexpr Vector4 impeller::Vector4::Max ( const Vector4 &  p) const
inlineconstexpr

Definition at line 295 of file vector.h.

295  {
296  return {std::max(x, p.x), std::max(y, p.y), std::max(z, p.z),
297  std::max(w, p.w)};
298  }

References w, x, y, and z.

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

◆ Min()

constexpr Vector4 impeller::Vector4::Min ( const Vector4 &  p) const
inlineconstexpr

Definition at line 290 of file vector.h.

290  {
291  return {std::min(x, p.x), std::min(y, p.y), std::min(z, p.z),
292  std::min(w, p.w)};
293  }

References w, x, y, and z.

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

◆ Normalize()

Vector4 impeller::Vector4::Normalize ( ) const
inline

Definition at line 261 of file vector.h.

261  {
262  const Scalar inverse = 1.0f / sqrt(x * x + y * y + z * z + w * w);
263  return Vector4(x * inverse, y * inverse, z * inverse, w * inverse);
264  }
float Scalar
Definition: scalar.h:19
constexpr Vector4()
Definition: vector.h:241

References Vector4(), w, x, y, and z.

Referenced by impeller::Matrix::MakeRotation().

◆ operator!=()

constexpr bool impeller::Vector4::operator!= ( const Vector4 &  v) const
inlineconstexpr

Definition at line 270 of file vector.h.

270  {
271  return (x != v.x) || (y != v.y) || (z != v.z) || (w != v.w);
272  }

References w, x, y, and z.

◆ operator*() [1/2]

constexpr Vector4 impeller::Vector4::operator* ( const Vector4 &  v) const
inlineconstexpr

Definition at line 286 of file vector.h.

286  {
287  return Vector4(x * v.x, y * v.y, z * v.z, w * v.w);
288  }

References Vector4(), w, x, y, and z.

◆ operator*() [2/2]

constexpr Vector4 impeller::Vector4::operator* ( Scalar  f) const
inlineconstexpr

Definition at line 282 of file vector.h.

282  {
283  return Vector4(x * f, y * f, z * f, w * f);
284  }

References Vector4(), w, x, y, and z.

◆ operator+()

constexpr Vector4 impeller::Vector4::operator+ ( const Vector4 &  v) const
inlineconstexpr

Definition at line 274 of file vector.h.

274  {
275  return Vector4(x + v.x, y + v.y, z + v.z, w + v.w);
276  }

References Vector4(), w, x, y, and z.

◆ operator-()

constexpr Vector4 impeller::Vector4::operator- ( const Vector4 &  v) const
inlineconstexpr

Definition at line 278 of file vector.h.

278  {
279  return Vector4(x - v.x, y - v.y, z - v.z, w - v.w);
280  }

References Vector4(), w, x, y, and z.

◆ operator==()

constexpr bool impeller::Vector4::operator== ( const Vector4 &  v) const
inlineconstexpr

Definition at line 266 of file vector.h.

266  {
267  return (x == v.x) && (y == v.y) && (z == v.z) && (w == v.w);
268  }

References w, x, y, and z.

◆ Round()

Vector4 impeller::Vector4::Round ( ) const
inline

Definition at line 308 of file vector.h.

308  {
309  return {std::round(x), std::round(y), std::round(z), std::round(w)};
310  }

References w, x, y, and z.

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

◆ xy()

constexpr Vector2 impeller::Vector4::xy ( ) const
inlineconstexpr

Definition at line 316 of file vector.h.

316 { return Vector2(x, y); }
Point Vector2
Definition: point.h:430

References x, and y.

Member Data Documentation

◆ 

union { ... }

◆ e

Scalar impeller::Vector4::e[4]

Definition at line 238 of file vector.h.

Referenced by impeller::Matrix::Decompose(), and impeller::Matrix::Matrix().

◆ w

◆ x

◆ y

◆ z


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