OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Defines a simple float vector class. This class is used to indicate a | 5 // Defines a simple float vector class. This class is used to indicate a |
6 // distance in two dimensions between two points. Subtracting two points should | 6 // distance in two dimensions between two points. Subtracting two points should |
7 // produce a vector, and adding a vector to a point produces the point at the | 7 // produce a vector, and adding a vector to a point produces the point at the |
8 // vector's distance from the original point. | 8 // vector's distance from the original point. |
9 | 9 |
10 #ifndef UI_GFX_VECTOR3D_F_H_ | 10 #ifndef UI_GFX_VECTOR3D_F_H_ |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return result; | 97 return result; |
98 } | 98 } |
99 | 99 |
100 // Return the cross product of two vectors. | 100 // Return the cross product of two vectors. |
101 inline Vector3dF CrossProduct(const Vector3dF& lhs, const Vector3dF& rhs) { | 101 inline Vector3dF CrossProduct(const Vector3dF& lhs, const Vector3dF& rhs) { |
102 Vector3dF result = lhs; | 102 Vector3dF result = lhs; |
103 result.Cross(rhs); | 103 result.Cross(rhs); |
104 return result; | 104 return result; |
105 } | 105 } |
106 | 106 |
| 107 // Return the dot product of two vectors with the second given as xyz. |
| 108 UI_EXPORT float DotProduct(const Vector3dF& lhs, float x, float y, float z); |
| 109 |
107 // Return the dot product of two vectors. | 110 // Return the dot product of two vectors. |
108 UI_EXPORT float DotProduct(const Vector3dF& lhs, const Vector3dF& rhs); | 111 inline float DotProduct(const Vector3dF& lhs, const Vector3dF& rhs) { |
| 112 return DotProduct(lhs, rhs.x(), rhs.y(), rhs.z()); |
| 113 } |
| 114 |
109 | 115 |
110 // Return a vector that is |v| scaled by the given scale factors along each | 116 // Return a vector that is |v| scaled by the given scale factors along each |
111 // axis. | 117 // axis. |
112 UI_EXPORT Vector3dF ScaleVector3d(const Vector3dF& v, | 118 UI_EXPORT Vector3dF ScaleVector3d(const Vector3dF& v, |
113 float x_scale, | 119 float x_scale, |
114 float y_scale, | 120 float y_scale, |
115 float z_scale); | 121 float z_scale); |
116 | 122 |
117 // Return a vector that is |v| scaled by the given scale factor. | 123 // Return a vector that is |v| scaled by the given scale factor. |
118 inline Vector3dF ScaleVector3d(const Vector3dF& v, float scale) { | 124 inline Vector3dF ScaleVector3d(const Vector3dF& v, float scale) { |
119 return ScaleVector3d(v, scale, scale, scale); | 125 return ScaleVector3d(v, scale, scale, scale); |
120 } | 126 } |
121 | 127 |
122 } // namespace gfx | 128 } // namespace gfx |
123 | 129 |
124 #endif // UI_GFX_VECTOR3D_F_H_ | 130 #endif // UI_GFX_VECTOR3D_F_H_ |
OLD | NEW |