Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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)
 
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 232 of file vector.h.

Constructor & Destructor Documentation

◆ Vector4() [1/6]

constexpr impeller::Vector4::Vector4 ( )
inlineconstexpr

Definition at line 243 of file vector.h.

243{}

◆ Vector4() [2/6]

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

Definition at line 245 of file vector.h.

246 : 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 248 of file vector.h.

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

◆ Vector4() [4/6]

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

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)
inlineconstexpr

Definition at line 253 of file vector.h.

◆ Vector4() [6/6]

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

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
inlineconstexpr

Definition at line 301 of file vector.h.

301 {
302 return {std::ceil(x), std::ceil(y), std::ceil(z), std::ceil(w)};
303 }

◆ Floor()

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

Definition at line 297 of file vector.h.

297 {
298 return {std::floor(x), std::floor(y), std::floor(z), std::floor(w)};
299 }

◆ Lerp()

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

Definition at line 309 of file vector.h.

309 {
310 return *this + (v - *this) * t;
311 }

◆ Max()

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

Definition at line 292 of file vector.h.

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

◆ Min()

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

Definition at line 287 of file vector.h.

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

◆ Normalize()

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

Definition at line 258 of file vector.h.

258 {
259 const Scalar inverse = 1.0f / sqrt(x * x + y * y + z * z + w * w);
260 return Vector4(x * inverse, y * inverse, z * inverse, w * inverse);
261 }
float Scalar
Definition scalar.h:18
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition SkVx.h:706
constexpr Vector4()
Definition vector.h:243

◆ operator!=()

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

Definition at line 267 of file vector.h.

267 {
268 return (x != v.x) || (y != v.y) || (z != v.z) || (w != v.w);
269 }

◆ operator*() [1/2]

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

Definition at line 283 of file vector.h.

283 {
284 return Vector4(x * v.x, y * v.y, z * v.z, w * v.w);
285 }

◆ operator*() [2/2]

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

Definition at line 279 of file vector.h.

279 {
280 return Vector4(x * f, y * f, z * f, w * f);
281 }

◆ operator+()

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

Definition at line 271 of file vector.h.

271 {
272 return Vector4(x + v.x, y + v.y, z + v.z, w + v.w);
273 }

◆ operator-()

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

Definition at line 275 of file vector.h.

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

◆ operator==()

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

Definition at line 263 of file vector.h.

263 {
264 return (x == v.x) && (y == v.y) && (z == v.z) && (w == v.w);
265 }

◆ Round()

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

Definition at line 305 of file vector.h.

305 {
306 return {std::round(x), std::round(y), std::round(z), std::round(w)};
307 }

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

Member Data Documentation

◆ [union]

union { ... } impeller::Vector4

◆ e

Scalar impeller::Vector4::e[4]

Definition at line 240 of file vector.h.

◆ w

Scalar impeller::Vector4::w = 1.0f

Definition at line 238 of file vector.h.

◆ x

Scalar impeller::Vector4::x = 0.0f

Definition at line 235 of file vector.h.

◆ y

Scalar impeller::Vector4::y = 0.0f

Definition at line 236 of file vector.h.

◆ z

Scalar impeller::Vector4::z = 0.0f

Definition at line 237 of file vector.h.


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