| Flutter Impeller |

Public Member Functions | Public Attributes | List of all members
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)
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
constexpr Vector4 | Floor () const
constexpr Vector4 | Ceil () const
constexpr Vector4 | Round () const
constexpr Vector4 | Lerp (const Vector4 &v, Scalar t) const
std::string | ToString () 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 229 of file vector.h.

## Constructor & Destructor Documentation

## ◆ Vector4() [1/5]

constexpr impeller::Vector4::Vector4 | ( |  | ) |
| inline constexpr

Definition at line 240 of file vector.h.

240 {}

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

## ◆ Vector4() [2/5]

constexpr impeller::Vector4::Vector4 | ( | const Color & | c | ) |
| inline constexpr

Definition at line 242 of file vector.h.

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

## ◆ Vector4() [3/5]

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

Definition at line 245 of file vector.h.

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

## ◆ Vector4() [4/5]

constexpr impeller::Vector4::Vector4 | ( | const Vector3 & | v | ) |
| inline constexpr

Definition at line 248 of file vector.h.

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

## ◆ Vector4() [5/5]

constexpr impeller::Vector4::Vector4 | ( | const Point & | p | ) |
| inline constexpr

Definition at line 250 of file vector.h.

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

## Member Function Documentation

## ◆ Ceil()

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

Definition at line 295 of file vector.h.

295 {
296 return {std::ceil(x), std::ceil(y), std::ceil(z), std::ceil(w)};
297 }

References w, x, y, and z.

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

## ◆ Floor()

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

Definition at line 291 of file vector.h.

291 {
292 return {std::floor(x), std::floor(y), std::floor(z), std::floor(w)};
293 }

References w, x, y, and z.

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

## ◆ Lerp()

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

Definition at line 303 of file vector.h.

303 {
304 return *this + (v - *this) * t;
305 }

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

## ◆ Max()

constexpr Vector4 impeller::Vector4::Max | ( | const Vector4 & | p | ) | const
| inline constexpr

Definition at line 286 of file vector.h.

286 {
287 return {std::max(x, p.x), std::max(y, p.y), std::max(z, p.z),
288 std::max(w, p.w)};
289 }

References w, x, y, and z.

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

## ◆ Min()

constexpr Vector4 impeller::Vector4::Min | ( | const Vector4 & | p | ) | const
| inline constexpr

Definition at line 281 of file vector.h.

281 {
282 return {std::min(x, p.x), std::min(y, p.y), std::min(z, p.z),
283 std::min(w, p.w)};
284 }

References w, x, y, and z.

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

## ◆ Normalize()

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

Definition at line 252 of file vector.h.

252 {
253 const Scalar inverse = 1.0f / sqrt(x * x + y * y + z * z + w * w);
254 return Vector4(x * inverse, y * inverse, z * inverse, w * inverse);
255 }

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

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

## ◆ operator!=()

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

Definition at line 261 of file vector.h.

261 {
262 return (x != v.x) || (y != v.y) || (z != v.z) || (w != v.w);
263 }

References w, x, y, and z.

## ◆ operator*() [1/2]

constexpr Vector4 impeller::Vector4::operator* | ( | const Vector4 & | v | ) | const
| inline constexpr

Definition at line 277 of file vector.h.

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

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

## ◆ operator*() [2/2]

constexpr Vector4 impeller::Vector4::operator* | ( | Scalar | f | ) | const
| inline constexpr

Definition at line 273 of file vector.h.

273 {
274 return Vector4(x * f, y * f, z * f, w * f);
275 }

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

## ◆ operator+()

constexpr Vector4 impeller::Vector4::operator+ | ( | const Vector4 & | v | ) | const
| inline constexpr

Definition at line 265 of file vector.h.

265 {
266 return Vector4(x + v.x, y + v.y, z + v.z, w + v.w);
267 }

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

## ◆ operator-()

constexpr Vector4 impeller::Vector4::operator- | ( | const Vector4 & | v | ) | const
| inline constexpr

Definition at line 269 of file vector.h.

269 {
270 return Vector4(x - v.x, y - v.y, z - v.z, w - v.w);
271 }

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

## ◆ operator==()

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

Definition at line 257 of file vector.h.

257 {
258 return (x == v.x) && (y == v.y) && (z == v.z) && (w == v.w);
259 }

References w, x, y, and z.

## ◆ Round()

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

Definition at line 299 of file vector.h.

299 {
300 return {std::round(x), std::round(y), std::round(z), std::round(w)};
301 }

References w, x, y, and z.

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

## ◆ ToString()

std::string impeller::Vector4::ToString | ( |  | ) | const

Definition at line 16 of file vector.cc.

16 {
17 std::stringstream stream;
18 stream << "{" << x << ", " << y << ", " << z << ", " << w << "}";
19 return stream.str();
20 }

References w, x, y, and z.

## Member Data Documentation

## ◆ @27

union { ... }

## ◆ e

Scalar impeller::Vector4::e[4]

Definition at line 237 of file vector.h.

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

## ◆ w

Scalar impeller::Vector4::w = 1.0f

Definition at line 235 of file vector.h.

Referenced by Ceil(), Floor(), Max(), Min(), Normalize(), operator!=(), operator*(), impeller::Matrix::operator*(), operator+(), operator-(), std::operator<<(), operator==(), Round(), impeller::scene::importer::ToFBVec4(), ToString(), impeller::Matrix::TransformDirection(), and Vector4Near().

## ◆ x

Scalar impeller::Vector4::x = 0.0f

Definition at line 232 of file vector.h.

Referenced by Ceil(), Floor(), impeller::Matrix::MakeRotation(), Max(), Min(), Normalize(), operator!=(), operator*(), impeller::Matrix::operator*(), operator+(), operator-(), std::operator<<(), operator==(), Round(), impeller::scene::importer::ToFBVec4(), ToString(), impeller::Matrix::TransformDirection(), and Vector4Near().

## ◆ y

Scalar impeller::Vector4::y = 0.0f

Definition at line 233 of file vector.h.

Referenced by Ceil(), Floor(), impeller::Matrix::MakeRotation(), Max(), Min(), Normalize(), operator!=(), operator*(), impeller::Matrix::operator*(), operator+(), operator-(), std::operator<<(), operator==(), Round(), impeller::scene::importer::ToFBVec4(), ToString(), impeller::Matrix::TransformDirection(), and Vector4Near().

## ◆ z

Scalar impeller::Vector4::z = 0.0f

Definition at line 234 of file vector.h.

Referenced by Ceil(), Floor(), impeller::Matrix::MakeRotation(), Max(), Min(), Normalize(), operator!=(), operator*(), impeller::Matrix::operator*(), operator+(), operator-(), std::operator<<(), operator==(), Round(), impeller::scene::importer::ToFBVec4(), ToString(), impeller::Matrix::TransformDirection(), and Vector4Near().

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

- impeller/geometry/vector.h
- impeller/geometry/vector.cc

impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::Vector4::x
Scalar x
Definition: vector.h:232
impeller::Vector4::Vector4
constexpr Vector4()
Definition: vector.h:240
impeller::Vector4::w
Scalar w
Definition: vector.h:235
impeller::Vector4::y
Scalar y
Definition: vector.h:233
impeller::Vector4::z
Scalar z
Definition: vector.h:234