Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
SkPoint3 Struct Reference

#include <SkPoint3.h>

Public Member Functions

SkScalar x () const
 
SkScalar y () const
 
SkScalar z () const
 
void set (SkScalar x, SkScalar y, SkScalar z)
 
SkScalar length () const
 
bool normalize ()
 
SkPoint3 makeScale (SkScalar scale) const
 
void scale (SkScalar value)
 
SkPoint3 operator- () const
 
void operator+= (const SkPoint3 &v)
 
void operator-= (const SkPoint3 &v)
 
bool isFinite () const
 
SkScalar dot (const SkPoint3 &vec) const
 
SkPoint3 cross (const SkPoint3 &vec) const
 

Static Public Member Functions

static SkPoint3 Make (SkScalar x, SkScalar y, SkScalar z)
 
static SkScalar Length (SkScalar x, SkScalar y, SkScalar z)
 
static SkScalar DotProduct (const SkPoint3 &a, const SkPoint3 &b)
 
static SkPoint3 CrossProduct (const SkPoint3 &a, const SkPoint3 &b)
 

Public Attributes

SkScalar fX
 
SkScalar fY
 
SkScalar fZ
 

Friends

bool operator== (const SkPoint3 &a, const SkPoint3 &b)
 
bool operator!= (const SkPoint3 &a, const SkPoint3 &b)
 
SkPoint3 operator- (const SkPoint3 &a, const SkPoint3 &b)
 
SkPoint3 operator+ (const SkPoint3 &a, const SkPoint3 &b)
 
SkPoint3 operator* (SkScalar t, SkPoint3 p)
 

Detailed Description

Definition at line 15 of file SkPoint3.h.

Member Function Documentation

◆ cross()

SkPoint3 SkPoint3::cross ( const SkPoint3 vec) const
inline

Definition at line 141 of file SkPoint3.h.

141 {
142 return CrossProduct(*this, vec);
143 }
static SkPoint3 CrossProduct(const SkPoint3 &a, const SkPoint3 &b)
Definition SkPoint3.h:132

◆ CrossProduct()

static SkPoint3 SkPoint3::CrossProduct ( const SkPoint3 a,
const SkPoint3 b 
)
inlinestatic

Returns the cross product of a and b, treating them as 3D vectors

Definition at line 132 of file SkPoint3.h.

132 {
134 result.fX = a.fY*b.fZ - a.fZ*b.fY;
135 result.fY = a.fZ*b.fX - a.fX*b.fZ;
136 result.fZ = a.fX*b.fY - a.fY*b.fX;
137
138 return result;
139 }
static bool b
struct MyStruct a[10]
GAsyncResult * result
SkScalar fX
Definition SkPoint3.h:16

◆ dot()

SkScalar SkPoint3::dot ( const SkPoint3 vec) const
inline

Definition at line 126 of file SkPoint3.h.

126 {
127 return DotProduct(*this, vec);
128 }
static SkScalar DotProduct(const SkPoint3 &a, const SkPoint3 &b)
Definition SkPoint3.h:122

◆ DotProduct()

static SkScalar SkPoint3::DotProduct ( const SkPoint3 a,
const SkPoint3 b 
)
inlinestatic

Returns the dot product of a and b, treating them as 3D vectors

Definition at line 122 of file SkPoint3.h.

122 {
123 return a.fX * b.fX + a.fY * b.fY + a.fZ * b.fZ;
124 }

◆ isFinite()

bool SkPoint3::isFinite ( ) const
inline

Returns true if fX, fY, and fZ are measurable values.

Returns
true for values other than infinities and NaN

Definition at line 116 of file SkPoint3.h.

116 {
117 return SkIsFinite(fX, fY, fZ);
118 }
static bool SkIsFinite(T x, Pack... values)
SkScalar fZ
Definition SkPoint3.h:16
SkScalar fY
Definition SkPoint3.h:16

◆ length()

SkScalar SkPoint3::length ( ) const
inline

Return the Euclidian distance from (0,0,0) to the point

Definition at line 44 of file SkPoint3.h.

44{ return SkPoint3::Length(fX, fY, fZ); }
static SkScalar Length(SkScalar x, SkScalar y, SkScalar z)
Definition SkPoint3.cpp:29

◆ Length()

SkScalar SkPoint3::Length ( SkScalar  x,
SkScalar  y,
SkScalar  z 
)
static

Returns the Euclidian distance from (0,0,0) to (x,y,z)

Definition at line 29 of file SkPoint3.cpp.

29 {
30 float magSq = get_length_squared(x, y, z);
31 if (SkIsFinite(magSq)) {
32 return std::sqrt(magSq);
33 } else {
34 double xx = x;
35 double yy = y;
36 double zz = z;
37 return (float)sqrt(xx * xx + yy * yy + zz * zz);
38 }
39}
static float get_length_squared(float x, float y, float z)
Definition SkPoint3.cpp:14
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition SkVx.h:706
SkScalar x() const
Definition SkPoint3.h:24
SkScalar y() const
Definition SkPoint3.h:25
SkScalar z() const
Definition SkPoint3.h:26

◆ Make()

static SkPoint3 SkPoint3::Make ( SkScalar  x,
SkScalar  y,
SkScalar  z 
)
inlinestatic

Definition at line 18 of file SkPoint3.h.

18 {
19 SkPoint3 pt;
20 pt.set(x, y, z);
21 return pt;
22 }
void set(SkScalar x, SkScalar y, SkScalar z)
Definition SkPoint3.h:28

◆ makeScale()

SkPoint3 SkPoint3::makeScale ( SkScalar  scale) const
inline

Return a new point whose X, Y and Z coordinates are scaled.

Definition at line 54 of file SkPoint3.h.

54 {
55 SkPoint3 p;
56 p.set(scale * fX, scale * fY, scale * fZ);
57 return p;
58 }
const Scalar scale

◆ normalize()

bool SkPoint3::normalize ( )

Set the point (vector) to be unit-length in the same direction as it already points. If the point has a degenerate length (i.e., nearly 0) then set it to (0,0,0) and return false; otherwise return true.

Definition at line 49 of file SkPoint3.cpp.

49 {
50 float magSq;
51 if (is_length_nearly_zero(fX, fY, fZ, &magSq)) {
52 this->set(0, 0, 0);
53 return false;
54 }
55 // sqrtf does not provide enough precision; since sqrt takes a double,
56 // there's no additional penalty to storing invScale in a double
57 double invScale;
58 if (SkIsFinite(magSq)) {
59 invScale = magSq;
60 } else {
61 // our magSq step overflowed to infinity, so use doubles instead.
62 // much slower, but needed when x, y or z is very large, otherwise we
63 // divide by inf. and return (0,0,0) vector.
64 double xx = fX;
65 double yy = fY;
66 double zz = fZ;
67 invScale = xx * xx + yy * yy + zz * zz;
68 }
69 // using a float instead of a double for scale loses too much precision
70 double scale = 1 / sqrt(invScale);
71 fX *= scale;
72 fY *= scale;
73 fZ *= scale;
74 if (!SkIsFinite(fX, fY, fZ)) {
75 this->set(0, 0, 0);
76 return false;
77 }
78 return true;
79}
static bool is_length_nearly_zero(float x, float y, float z, float *lengthSquared)
Definition SkPoint3.cpp:24

◆ operator+=()

void SkPoint3::operator+= ( const SkPoint3 v)
inline

Add v's coordinates to the point's

Definition at line 94 of file SkPoint3.h.

94 {
95 fX += v.fX;
96 fY += v.fY;
97 fZ += v.fZ;
98 }

◆ operator-()

SkPoint3 SkPoint3::operator- ( ) const
inline

Return a new point whose X, Y and Z coordinates are the negative of the original point's

Definition at line 71 of file SkPoint3.h.

71 {
72 SkPoint3 neg;
73 neg.fX = -fX;
74 neg.fY = -fY;
75 neg.fZ = -fZ;
76 return neg;
77 }

◆ operator-=()

void SkPoint3::operator-= ( const SkPoint3 v)
inline

Subtract v's coordinates from the point's

Definition at line 102 of file SkPoint3.h.

102 {
103 fX -= v.fX;
104 fY -= v.fY;
105 fZ -= v.fZ;
106 }

◆ scale()

void SkPoint3::scale ( SkScalar  value)
inline

Scale the point's coordinates by scale.

Definition at line 62 of file SkPoint3.h.

62 {
63 fX *= value;
64 fY *= value;
65 fZ *= value;
66 }
uint8_t value

◆ set()

void SkPoint3::set ( SkScalar  x,
SkScalar  y,
SkScalar  z 
)
inline

Definition at line 28 of file SkPoint3.h.

28{ fX = x; fY = y; fZ = z; }

◆ x()

SkScalar SkPoint3::x ( ) const
inline

Definition at line 24 of file SkPoint3.h.

24{ return fX; }

◆ y()

SkScalar SkPoint3::y ( ) const
inline

Definition at line 25 of file SkPoint3.h.

25{ return fY; }

◆ z()

SkScalar SkPoint3::z ( ) const
inline

Definition at line 26 of file SkPoint3.h.

26{ return fZ; }

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const SkPoint3 a,
const SkPoint3 b 
)
friend

Definition at line 34 of file SkPoint3.h.

34 {
35 return !(a == b);
36 }

◆ operator*

SkPoint3 operator* ( SkScalar  t,
SkPoint3  p 
)
friend

Definition at line 108 of file SkPoint3.h.

108 {
109 return { t * p.fX, t * p.fY, t * p.fZ };
110 }

◆ operator+

SkPoint3 operator+ ( const SkPoint3 a,
const SkPoint3 b 
)
friend

Returns a new point whose coordinates are the sum of a and b (a + b)

Definition at line 88 of file SkPoint3.h.

88 {
89 return { a.fX + b.fX, a.fY + b.fY, a.fZ + b.fZ };
90 }

◆ operator-

SkPoint3 operator- ( const SkPoint3 a,
const SkPoint3 b 
)
friend

Returns a new point whose coordinates are the difference between a and b (i.e., a - b)

Definition at line 82 of file SkPoint3.h.

82 {
83 return { a.fX - b.fX, a.fY - b.fY, a.fZ - b.fZ };
84 }

◆ operator==

bool operator== ( const SkPoint3 a,
const SkPoint3 b 
)
friend

Definition at line 30 of file SkPoint3.h.

30 {
31 return a.fX == b.fX && a.fY == b.fY && a.fZ == b.fZ;
32 }

Member Data Documentation

◆ fX

SkScalar SkPoint3::fX

Definition at line 16 of file SkPoint3.h.

◆ fY

SkScalar SkPoint3::fY

Definition at line 16 of file SkPoint3.h.

◆ fZ

SkScalar SkPoint3::fZ

Definition at line 16 of file SkPoint3.h.


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