| Flutter Impeller |

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
impeller::Vector3 Struct Reference

`#include <vector.h>`

## Public Member Functions
constexpr | Vector3 ()
constexpr | Vector3 (const Color &c)
constexpr | Vector3 (const Point &p)
constexpr | Vector3 (const Size &s)
constexpr | Vector3 (Scalar x, Scalar y)
constexpr | Vector3 (Scalar x, Scalar y, Scalar z)
Scalar | GetLength () const
Vector3 | Normalize () const
constexpr Scalar | Dot (const Vector3 &other) const
Vector3 | Abs () const
constexpr Vector3 | Cross (const Vector3 &other) const
Vector3 | Min (const Vector3 &p) const
Vector3 | Max (const Vector3 &p) const
Vector3 | Floor () const
Vector3 | Ceil () const
Vector3 | Round () const
constexpr bool | operator== (const Vector3 &v) const
constexpr bool | operator!= (const Vector3 &v) const
constexpr Vector3 | operator+= (const Vector3 &p)
constexpr Vector3 | operator-= (const Vector3 &p)
constexpr Vector3 | operator*= (const Vector3 &p)
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr Vector3 | operator*= (U scale)
constexpr Vector3 | operator/= (const Vector3 &p)
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr Vector3 | operator/= (U scale)
constexpr Vector3 | operator- () const
constexpr Vector3 | operator+ (const Vector3 &v) const
constexpr Vector3 | operator- (const Vector3 &v) const
constexpr Vector3 | operator+ (Scalar s) const
constexpr Vector3 | operator- (Scalar s) const
constexpr Vector3 | operator* (const Vector3 &v) const
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr Vector3 | operator* (U scale) const
constexpr Vector3 | operator/ (const Vector3 &v) const
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr Vector3 | operator/ (U scale) const
constexpr Vector3 | Lerp (const Vector3 &v, Scalar t) const
std::string | ToString () const

## Static Public Member Functions
static constexpr Vector3 | Combine (const Vector3 &a, Scalar aScale, const Vector3 &b, Scalar bScale)

## Public Attributes
union {
struct {
Scalar x = 0.0f
Scalar y = 0.0f
Scalar z = 0.0f
} |
Scalar e [3]
}; |

## Detailed Description

Definition at line 20 of file vector.h.

## Constructor & Destructor Documentation

## ◆ Vector3() [1/6]

constexpr impeller::Vector3::Vector3 | ( |  | ) |
| inlineconstexpr

Definition at line 30 of file vector.h.

30 {};

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

## ◆ Vector3() [2/6]

constexpr impeller::Vector3::Vector3 | ( | const Color & | c | ) |
| inlineconstexpr

Definition at line 32 of file vector.h.

32 : x(c.red), y(c.green), z(c.blue) {}
impeller::Vector3::x
Scalar x
Definition: vector.h:23
impeller::Vector3::y
Scalar y
Definition: vector.h:24
impeller::Vector3::z
Scalar z
Definition: vector.h:25

## ◆ Vector3() [3/6]

constexpr impeller::Vector3::Vector3 | ( | const Point & | p | ) |
| inlineconstexpr

Definition at line 34 of file vector.h.

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

## ◆ Vector3() [4/6]

constexpr impeller::Vector3::Vector3 | ( | const Size & | s | ) |
| inlineconstexpr

Definition at line 36 of file vector.h.

36 : x(s.width), y(s.height) {}

## ◆ Vector3() [5/6]

constexpr impeller::Vector3::Vector3 | ( | Scalar | x,
|  | Scalar | y
| ) |  |
| inlineconstexpr

Definition at line 38 of file vector.h.

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

## ◆ Vector3() [6/6]

constexpr impeller::Vector3::Vector3 | ( | Scalar | x,
|  | Scalar | y,
|  | Scalar | z
| ) |  |
| inlineconstexpr

Definition at line 40 of file vector.h.

40 : x(x), y(y), z(z) {}

## Member Function Documentation

## ◆ Abs()

Vector3 impeller::Vector3::Abs | ( |  | ) | const
| inline

Definition at line 58 of file vector.h.

58 {
59 return {std::fabs(x), std::fabs(y), std::fabs(z)};
60 }

References x, y, and z.

## ◆ Ceil()

Vector3 impeller::Vector3::Ceil | ( |  | ) | const
| inline

Definition at line 82 of file vector.h.

82 {
83 return {std::ceil(x), std::ceil(y), std::ceil(z)};
84 }

References x, y, and z.

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

## ◆ Combine()

static constexpr Vector3 impeller::Vector3::Combine | ( | const Vector3 & | a,
|  | Scalar | aScale,
|  | const Vector3 & | b,
|  | Scalar | bScale
| ) |  |
| inlinestaticconstexpr

Make a linear combination of two vectors and return the result.

Parameters

  a | the first vector.
  aScale | the scale to use for the first vector.
  b | the second vector.
  bScale | the scale to use for the second vector.

Returns
  the combined vector.

Definition at line 192 of file vector.h.

195 {
196 return {
197 aScale * a.x + bScale * b.x, //
198 aScale * a.y + bScale * b.y, //
199 aScale * a.z + bScale * b.z, //
200 };
201 }
impeller::saturated::b
SI b
Definition: saturated_math.h:87

References impeller::saturated::b, x, y, and z.

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

## ◆ Cross()

constexpr Vector3 impeller::Vector3::Cross | ( | const Vector3 & | other | ) | const
| inlineconstexpr

Definition at line 62 of file vector.h.

62 {
63 return {
64 (y * other.z) - (z * other.y), //
65 (z * other.x) - (x * other.z), //
66 (x * other.y) - (y * other.x) //
67 };
68 }

References x, y, and z.

Referenced by impeller::Matrix::MakeLookAt(), and impeller::Quaternion::operator*().

## ◆ Dot()

constexpr Scalar impeller::Vector3::Dot | ( | const Vector3 & | other | ) | const
| inlineconstexpr

Definition at line 54 of file vector.h.

54 {
55 return ((x * other.x) + (y * other.y) + (z * other.z));
56 }

References x, y, and z.

Referenced by impeller::Matrix::Decompose(), impeller::Matrix::MakeLookAt(), and impeller::Quaternion::operator*().

## ◆ Floor()

Vector3 impeller::Vector3::Floor | ( |  | ) | const
| inline

Definition at line 78 of file vector.h.

78 {
79 return {std::floor(x), std::floor(y), std::floor(z)};
80 }

References x, y, and z.

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

## ◆ GetLength()

Scalar impeller::Vector3::GetLength | ( |  | ) | const
| inline

The length (or magnitude of the vector).

Returns
  the calculated length.

Definition at line 47 of file vector.h.

47 { return sqrt(x * x + y * y + z * z); }

References x, y, and z.

Referenced by impeller::Paint::MaskBlurDescriptor::CreateMaskBlur(), impeller::Matrix::Decompose(), impeller::Matrix::GetDirectionScale(), and Normalize().

## ◆ Lerp()

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

Definition at line 178 of file vector.h.

178 {
179 return *this + (v - *this) * t;
180 }

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

## ◆ Max()

Vector3 impeller::Vector3::Max | ( | const Vector3 & | p | ) | const
| inline

Definition at line 74 of file vector.h.

74 {
75 return {std::max(x, p.x), std::max(y, p.y), std::max(z, p.z)};
76 }

References x, y, and z.

Referenced by impeller::Color::Blend(), and impeller::testing::TEST().

## ◆ Min()

Vector3 impeller::Vector3::Min | ( | const Vector3 & | p | ) | const
| inline

Definition at line 70 of file vector.h.

70 {
71 return {std::min(x, p.x), std::min(y, p.y), std::min(z, p.z)};
72 }

References x, y, and z.

Referenced by impeller::Color::Blend(), and impeller::testing::TEST().

## ◆ Normalize()

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

Definition at line 49 of file vector.h.

49 {
50 const auto len = GetLength();
51 return {x / len, y / len, z / len};
52 }
impeller::Vector3::GetLength
Scalar GetLength() const
Definition: vector.h:47

References GetLength(), x, y, and z.

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

## ◆ operator!=()

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

Definition at line 94 of file vector.h.

94 {
95 return v.x != x || v.y != y || v.z != z;
96 }

References x, y, and z.

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

constexpr Vector3 impeller::Vector3::operator* | ( | const Vector3 & | v | ) | const
| inlineconstexpr

Definition at line 160 of file vector.h.

160 {
161 return Vector3(x * v.x, y * v.y, z * v.z);
162 }
impeller::Vector3::Vector3
constexpr Vector3()
Definition: vector.h:30

References Vector3(), x, y, and z.

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

template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>

constexpr Vector3 impeller::Vector3::operator* | ( | U | scale | ) | const
| inlineconstexpr

Definition at line 165 of file vector.h.

165 {
166 return Vector3(x * scale, y * scale, z * scale);
167 }

References Vector3(), x, y, and z.

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

constexpr Vector3 impeller::Vector3::operator*= | ( | const Vector3 & | p | ) |
| inlineconstexpr

Definition at line 112 of file vector.h.

112 {
113 x *= p.x;
114 y *= p.y;
115 z *= p.z;
116 return *this;
117 }

References x, y, and z.

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

template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>

constexpr Vector3 impeller::Vector3::operator*= | ( | U | scale | ) |
| inlineconstexpr

Definition at line 120 of file vector.h.

120 {
121 x *= scale;
122 y *= scale;
123 z *= scale;
124 return *this;
125 }

References x, y, and z.

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

constexpr Vector3 impeller::Vector3::operator+ | ( | const Vector3 & | v | ) | const
| inlineconstexpr

Definition at line 144 of file vector.h.

144 {
145 return Vector3(x + v.x, y + v.y, z + v.z);
146 }

References Vector3(), x, y, and z.

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

constexpr Vector3 impeller::Vector3::operator+ | ( | Scalar | s | ) | const
| inlineconstexpr

Definition at line 152 of file vector.h.

152 {
153 return Vector3(x + s, y + s, z + s);
154 }

References Vector3(), x, y, and z.

## ◆ operator+=()

constexpr Vector3 impeller::Vector3::operator+= | ( | const Vector3 & | p | ) |
| inlineconstexpr

Definition at line 98 of file vector.h.

98 {
99 x += p.x;
100 y += p.y;
101 z += p.z;
102 return *this;
103 }

References x, y, and z.

## ◆ operator-() [1/3]

constexpr Vector3 impeller::Vector3::operator- | ( |  | ) | const
| inlineconstexpr

Definition at line 142 of file vector.h.

142 { return Vector3(-x, -y, -z); }

References Vector3(), x, y, and z.

## ◆ operator-() [2/3]

constexpr Vector3 impeller::Vector3::operator- | ( | const Vector3 & | v | ) | const
| inlineconstexpr

Definition at line 148 of file vector.h.

148 {
149 return Vector3(x - v.x, y - v.y, z - v.z);
150 }

References Vector3(), x, y, and z.

## ◆ operator-() [3/3]

constexpr Vector3 impeller::Vector3::operator- | ( | Scalar | s | ) | const
| inlineconstexpr

Definition at line 156 of file vector.h.

156 {
157 return Vector3(x - s, y - s, z - s);
158 }

References Vector3(), x, y, and z.

## ◆ operator-=()

constexpr Vector3 impeller::Vector3::operator-= | ( | const Vector3 & | p | ) |
| inlineconstexpr

Definition at line 105 of file vector.h.

105 {
106 x -= p.x;
107 y -= p.y;
108 z -= p.z;
109 return *this;
110 }

References x, y, and z.

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

constexpr Vector3 impeller::Vector3::operator/ | ( | const Vector3 & | v | ) | const
| inlineconstexpr

Definition at line 169 of file vector.h.

169 {
170 return Vector3(x / v.x, y / v.y, z / v.z);
171 }

References Vector3(), x, y, and z.

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

template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>

constexpr Vector3 impeller::Vector3::operator/ | ( | U | scale | ) | const
| inlineconstexpr

Definition at line 174 of file vector.h.

174 {
175 return Vector3(x / scale, y / scale, z / scale);
176 }

References Vector3(), x, y, and z.

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

constexpr Vector3 impeller::Vector3::operator/= | ( | const Vector3 & | p | ) |
| inlineconstexpr

Definition at line 127 of file vector.h.

127 {
128 x /= p.x;
129 y /= p.y;
130 z /= p.z;
131 return *this;
132 }

References x, y, and z.

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

template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>

constexpr Vector3 impeller::Vector3::operator/= | ( | U | scale | ) |
| inlineconstexpr

Definition at line 135 of file vector.h.

135 {
136 x /= scale;
137 y /= scale;
138 z /= scale;
139 return *this;
140 }

References x, y, and z.

## ◆ operator==()

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

Definition at line 90 of file vector.h.

90 {
91 return v.x == x && v.y == y && v.z == z;
92 }

References x, y, and z.

## ◆ Round()

Vector3 impeller::Vector3::Round | ( |  | ) | const
| inline

Definition at line 86 of file vector.h.

86 {
87 return {std::round(x), std::round(y), std::round(z)};
88 }

References x, y, and z.

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

## ◆ ToString()

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

Definition at line 10 of file vector.cc.

10 {
11 std::stringstream stream;
12 stream << "{" << x << ", " << y << ", " << z << "}";
13 return stream.str();
14 }

References x, y, and z.

## Member Data Documentation

## ◆

union { ... }

## ◆ e

Scalar impeller::Vector3::e[3]

Definition at line 27 of file vector.h.

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

## ◆ x

Scalar impeller::Vector3::x = 0.0f

Definition at line 23 of file vector.h.

Referenced by Abs(), impeller::Color::Blend(), Ceil(), impeller::ClipColor(), Combine(), impeller::ComponentChoose(), Cross(), impeller::Matrix::Decompose(), Dot(), Floor(), impeller::FromRGB(), impeller::GaussianBlurFilterContents::GetFilterSourceCoverage(), GetLength(), impeller::Luminosity(), impeller::Matrix::MakeLookAt(), impeller::Matrix::MakeScale(), impeller::Matrix::MakeTranslateScale(), impeller::Matrix::MakeTranslation(), Max(), Min(), Normalize(), operator!=(), impeller::Matrix::operator*(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), impeller::operator/(), operator/=(), std::operator<<(), operator==(), impeller::Quaternion::Quaternion(), impeller::testing::RGBToYUV(), Round(), impeller::Saturation(), impeller::Matrix::Scale(), impeller::SetSaturation(), impeller::testing::TEST(), impeller::testing::TEST_P(), ToString(), impeller::Matrix::TransformDirection(), impeller::Matrix::Translate(), and Vector3Near().

## ◆ y

Scalar impeller::Vector3::y = 0.0f

Definition at line 24 of file vector.h.

Referenced by Abs(), impeller::Color::Blend(), Ceil(), impeller::ClipColor(), Combine(), impeller::ComponentChoose(), Cross(), impeller::Matrix::Decompose(), Dot(), impeller::DlDispatcherBase::drawShadow(), Floor(), impeller::FromRGB(), impeller::GaussianBlurFilterContents::GetFilterSourceCoverage(), GetLength(), impeller::Luminosity(), impeller::Matrix::MakeLookAt(), impeller::Matrix::MakeScale(), impeller::Matrix::MakeTranslateScale(), impeller::Matrix::MakeTranslation(), Max(), Min(), Normalize(), operator!=(), impeller::Matrix::operator*(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), impeller::operator/(), operator/=(), std::operator<<(), operator==(), impeller::Quaternion::Quaternion(), impeller::testing::RGBToYUV(), Round(), impeller::Saturation(), impeller::Matrix::Scale(), impeller::SetSaturation(), impeller::testing::TEST(), impeller::testing::TEST_P(), ToString(), impeller::Matrix::TransformDirection(), impeller::Matrix::Translate(), and Vector3Near().

## ◆ z

Scalar impeller::Vector3::z = 0.0f

Definition at line 25 of file vector.h.

Referenced by Abs(), impeller::Color::Blend(), Ceil(), impeller::ClipColor(), Combine(), impeller::ComponentChoose(), Cross(), impeller::Matrix::Decompose(), Dot(), Floor(), impeller::FromRGB(), GetLength(), impeller::Luminosity(), impeller::Matrix::MakeLookAt(), impeller::Matrix::MakeScale(), impeller::Matrix::MakeTranslateScale(), impeller::Matrix::MakeTranslation(), Max(), Min(), Normalize(), operator!=(), impeller::Matrix::operator*(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), impeller::operator/(), operator/=(), std::operator<<(), operator==(), impeller::Quaternion::Quaternion(), impeller::testing::RGBToYUV(), Round(), impeller::Saturation(), impeller::Matrix::Scale(), impeller::SetSaturation(), impeller::testing::TEST(), impeller::testing::TEST_P(), ToString(), impeller::Matrix::TransformDirection(), impeller::Matrix::Translate(), and Vector3Near().

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

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