OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkPoint3_DEFINED | 8 #ifndef SkPoint3_DEFINED |
9 #define SkPoint3_DEFINED | 9 #define SkPoint3_DEFINED |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 /** Returns a new point whose coordinates are the sum of a and b (a + b) | 86 /** Returns a new point whose coordinates are the sum of a and b (a + b) |
87 */ | 87 */ |
88 friend SkPoint3 operator+(const SkPoint3& a, const SkPoint3& b) { | 88 friend SkPoint3 operator+(const SkPoint3& a, const SkPoint3& b) { |
89 SkPoint3 v; | 89 SkPoint3 v; |
90 v.set(a.fX + b.fX, a.fY + b.fY, a.fZ + b.fZ); | 90 v.set(a.fX + b.fX, a.fY + b.fY, a.fZ + b.fZ); |
91 return v; | 91 return v; |
92 } | 92 } |
93 | 93 |
| 94 /** Add v's coordinates to the point's |
| 95 */ |
| 96 void operator+=(const SkPoint3& v) { |
| 97 fX += v.fX; |
| 98 fY += v.fY; |
| 99 fZ += v.fZ; |
| 100 } |
| 101 |
| 102 /** Subtract v's coordinates from the point's |
| 103 */ |
| 104 void operator-=(const SkPoint3& v) { |
| 105 fX -= v.fX; |
| 106 fY -= v.fY; |
| 107 fZ -= v.fZ; |
| 108 } |
| 109 |
94 /** Returns the dot product of a and b, treating them as 3D vectors | 110 /** Returns the dot product of a and b, treating them as 3D vectors |
95 */ | 111 */ |
96 static SkScalar DotProduct(const SkPoint3& a, const SkPoint3& b) { | 112 static SkScalar DotProduct(const SkPoint3& a, const SkPoint3& b) { |
97 return a.fX * b.fX + a.fY * b.fY + a.fZ * b.fZ; | 113 return a.fX * b.fX + a.fY * b.fY + a.fZ * b.fZ; |
98 } | 114 } |
99 | 115 |
100 SkScalar dot(const SkPoint3& vec) const { | 116 SkScalar dot(const SkPoint3& vec) const { |
101 return DotProduct(*this, vec); | 117 return DotProduct(*this, vec); |
102 } | 118 } |
103 }; | 119 }; |
104 | 120 |
105 typedef SkPoint3 SkVector3; | 121 typedef SkPoint3 SkVector3; |
106 typedef SkPoint3 SkColor3f; | 122 typedef SkPoint3 SkColor3f; |
107 | 123 |
108 #endif | 124 #endif |
OLD | NEW |