Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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)
 
constexpr Scalar Length () const
 
constexpr Vector3 Normalize () const
 
constexpr Scalar Dot (const Vector3 &other) const
 
constexpr Vector3 Abs () const
 
constexpr Vector3 Cross (const Vector3 &other) const
 
constexpr Vector3 Min (const Vector3 &p) const
 
constexpr Vector3 Max (const Vector3 &p) const
 
constexpr Vector3 Floor () const
 
constexpr Vector3 Ceil () const
 
constexpr 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{};

◆ 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) {}

◆ Vector3() [3/6]

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

Definition at line 34 of file vector.h.

◆ 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) {}
struct MyStruct s

◆ 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()

constexpr Vector3 impeller::Vector3::Abs ( ) const
inlineconstexpr

Definition at line 58 of file vector.h.

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

◆ Ceil()

constexpr Vector3 impeller::Vector3::Ceil ( ) const
inlineconstexpr

Definition at line 82 of file vector.h.

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

◆ 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
athe first vector.
aScalethe scale to use for the first vector.
bthe second vector.
bScalethe 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 }
static bool b
struct MyStruct a[10]

◆ 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 }

◆ 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 }

◆ Floor()

constexpr Vector3 impeller::Vector3::Floor ( ) const
inlineconstexpr

Definition at line 78 of file vector.h.

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

◆ Length()

constexpr Scalar impeller::Vector3::Length ( ) const
inlineconstexpr

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); }
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition SkVx.h:706

◆ 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 }

◆ Max()

constexpr Vector3 impeller::Vector3::Max ( const Vector3 p) const
inlineconstexpr

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 }

◆ Min()

constexpr Vector3 impeller::Vector3::Min ( const Vector3 p) const
inlineconstexpr

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 }

◆ Normalize()

constexpr Vector3 impeller::Vector3::Normalize ( ) const
inlineconstexpr

Definition at line 49 of file vector.h.

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

◆ 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 }

◆ 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 }
constexpr Vector3()
Definition vector.h:30

◆ operator*() [2/2]

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

Definition at line 165 of file vector.h.

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

◆ 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 }

◆ operator*=() [2/2]

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

Definition at line 120 of file vector.h.

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

◆ 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 }

◆ 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 }

◆ 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 }

◆ operator-() [1/3]

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

Definition at line 142 of file vector.h.

142{ return Vector3(-x, -y, -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 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ operator/() [2/2]

template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr Vector3 impeller::Vector3::operator/ ( scale) const
inlineconstexpr

Definition at line 174 of file vector.h.

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

◆ 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 }

◆ operator/=() [2/2]

template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr Vector3 impeller::Vector3::operator/= ( scale)
inlineconstexpr

Definition at line 135 of file vector.h.

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

◆ 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 }

◆ Round()

constexpr Vector3 impeller::Vector3::Round ( ) const
inlineconstexpr

Definition at line 86 of file vector.h.

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

◆ 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}

Member Data Documentation

◆ [union]

union { ... } impeller::Vector3

◆ e

Scalar impeller::Vector3::e[3]

Definition at line 27 of file vector.h.

◆ x

Scalar impeller::Vector3::x = 0.0f

Definition at line 23 of file vector.h.

◆ y

Scalar impeller::Vector3::y = 0.0f

Definition at line 24 of file vector.h.

◆ z

Scalar impeller::Vector3::z = 0.0f

Definition at line 25 of file vector.h.


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