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 | |
110 /** Returns the dot product of a and b, treating them as 3D vectors | 94 /** Returns the dot product of a and b, treating them as 3D vectors |
111 */ | 95 */ |
112 static SkScalar DotProduct(const SkPoint3& a, const SkPoint3& b) { | 96 static SkScalar DotProduct(const SkPoint3& a, const SkPoint3& b) { |
113 return a.fX * b.fX + a.fY * b.fY + a.fZ * b.fZ; | 97 return a.fX * b.fX + a.fY * b.fY + a.fZ * b.fZ; |
114 } | 98 } |
115 | 99 |
116 SkScalar dot(const SkPoint3& vec) const { | 100 SkScalar dot(const SkPoint3& vec) const { |
117 return DotProduct(*this, vec); | 101 return DotProduct(*this, vec); |
118 } | 102 } |
119 }; | 103 }; |
120 | 104 |
121 typedef SkPoint3 SkVector3; | 105 typedef SkPoint3 SkVector3; |
122 typedef SkPoint3 SkColor3f; | 106 typedef SkPoint3 SkColor3f; |
123 | 107 |
124 #endif | 108 #endif |
OLD | NEW |