| 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)
constexpr | Vector4 (std::array< Scalar, 4 > values)
constexpr 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
constexpr Vector4 | Floor () const
constexpr Vector4 | Ceil () const
constexpr Vector4 | Round () const
constexpr Vector4 | Lerp (const Vector4 &v, Scalar t) const
constexpr Vector2 | xy () 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 232 of file vector.h.

## Constructor & Destructor Documentation

## ◆ Vector4() [1/6]

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

Definition at line 243 of file vector.h.

243 {}

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

## ◆ Vector4() [2/6]

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

Definition at line 245 of file vector.h.

246 : x(c.red), y(c.green), z(c.blue), w(c.alpha) {}
impeller::Vector4::y
Scalar y
Definition: vector.h:236
impeller::Vector4::w
Scalar w
Definition: vector.h:238
impeller::Vector4::x
Scalar x
Definition: vector.h:235
impeller::Vector4::z
Scalar z
Definition: vector.h:237

## ◆ Vector4() [3/6]

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

Definition at line 248 of file vector.h.

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

## ◆ Vector4() [4/6]

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

Definition at line 251 of file vector.h.

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

## ◆ Vector4() [5/6]

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

Definition at line 253 of file vector.h.

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

## ◆ Vector4() [6/6]

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

Definition at line 255 of file vector.h.

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

## Member Function Documentation

## ◆ Ceil()

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

Definition at line 306 of file vector.h.

306 {
307 return {std::ceil(x), std::ceil(y), std::ceil(z), std::ceil(w)};
308 }

References w, x, y, and z.

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

## ◆ Floor()

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

Definition at line 302 of file vector.h.

302 {
303 return {std::floor(x), std::floor(y), std::floor(z), std::floor(w)};
304 }

References w, x, y, and z.

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

## ◆ IsFinite()

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

Definition at line 258 of file vector.h.

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

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
| inline constexpr

Definition at line 314 of file vector.h.

314 {
315 return *this + (v - *this) * t;
316 }

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

## ◆ Max()

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

Definition at line 297 of file vector.h.

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

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 292 of file vector.h.

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

References w, x, y, and z.

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

## ◆ Normalize()

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

Definition at line 263 of file vector.h.

263 {
264 const Scalar inverse = 1.0f / sqrt(x * x + y * y + z * z + w * w);
265 return Vector4(x * inverse, y * inverse, z * inverse, w * inverse);
266 }
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::Vector4::Vector4
constexpr Vector4()
Definition: vector.h:243

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 272 of file vector.h.

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

References w, x, y, and z.

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

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

Definition at line 288 of file vector.h.

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

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

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

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

Definition at line 284 of file vector.h.

284 {
285 return Vector4(x * f, y * f, z * f, w * f);
286 }

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

## ◆ operator+()

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

Definition at line 276 of file vector.h.

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

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

## ◆ operator-()

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

Definition at line 280 of file vector.h.

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

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

## ◆ operator==()

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

Definition at line 268 of file vector.h.

268 {
269 return (x == v.x) && (y == v.y) && (z == v.z) && (w == v.w);
270 }

References w, x, y, and z.

## ◆ Round()

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

Definition at line 310 of file vector.h.

310 {
311 return {std::round(x), std::round(y), std::round(z), std::round(w)};
312 }

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.

## ◆ xy()

constexpr Vector2 impeller::Vector4::xy | ( |  | ) | const
| inline constexpr

Definition at line 318 of file vector.h.

318 { return Vector2(x, y); }
impeller::Vector2
Point Vector2
Definition: point.h:331

References x, and y.

## Member Data Documentation

## ◆

union { ... }

## ◆ e

Scalar impeller::Vector4::e[4]

Definition at line 240 of file vector.h.

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

## ◆ w

Scalar impeller::Vector4::w = 1.0f

Definition at line 238 of file vector.h.

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

## ◆ x

Scalar impeller::Vector4::x = 0.0f

Definition at line 235 of file vector.h.

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

## ◆ y

Scalar impeller::Vector4::y = 0.0f

Definition at line 236 of file vector.h.

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

## ◆ z

Scalar impeller::Vector4::z = 0.0f

Definition at line 237 of file vector.h.

Referenced by Ceil(), Floor(), IsFinite(), impeller::Matrix::MakeRotation(), Max(), Min(), Normalize(), operator!=(), impeller::Matrix::operator*(), operator*(), operator+(), operator-(), std::operator<<(), operator==(), Round(), impeller::testing::TEST(), 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