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_ |
11 #define UI_GFX_VECTOR3D_F_H_ | 11 #define UI_GFX_VECTOR3D_F_H_ |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "ui/base/ui_export.h" | 15 #include "ui/base/ui_export.h" |
16 #include "ui/gfx/vector2d_f.h" | 16 #include "ui/gfx/vector2d_f.h" |
17 | 17 |
18 namespace gfx { | 18 namespace gfx { |
19 | 19 |
20 class UI_EXPORT Vector3dF { | 20 class UI_EXPORT Vector3dF { |
21 public: | 21 public: |
22 Vector3dF(); | 22 Vector3dF(); |
23 Vector3dF(float x, float y, float z); | 23 Vector3dF(float x, float y, float z); |
24 | 24 |
25 explicit Vector3dF(const Vector2dF& other); | 25 explicit Vector3dF(const Vector2dF& other); |
26 | 26 |
| 27 static Vector3dF XAxis() { return Vector3dF(1, 0, 0); } |
| 28 static Vector3dF YAxis() { return Vector3dF(0, 1, 0); } |
| 29 static Vector3dF ZAxis() { return Vector3dF(0, 0, 1); } |
| 30 |
27 float x() const { return x_; } | 31 float x() const { return x_; } |
28 void set_x(float x) { x_ = x; } | 32 void set_x(float x) { x_ = x; } |
29 | 33 |
30 float y() const { return y_; } | 34 float y() const { return y_; } |
31 void set_y(float y) { y_ = y; } | 35 void set_y(float y) { y_ = y; } |
32 | 36 |
33 float z() const { return z_; } | 37 float z() const { return z_; } |
34 void set_z(float z) { z_ = z; } | 38 void set_z(float z) { z_ = z; } |
35 | 39 |
36 // True if all components of the vector are 0. | 40 // True if all components of the vector are 0. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 float z_scale); | 119 float z_scale); |
116 | 120 |
117 // Return a vector that is |v| scaled by the given scale factor. | 121 // Return a vector that is |v| scaled by the given scale factor. |
118 inline Vector3dF ScaleVector3d(const Vector3dF& v, float scale) { | 122 inline Vector3dF ScaleVector3d(const Vector3dF& v, float scale) { |
119 return ScaleVector3d(v, scale, scale, scale); | 123 return ScaleVector3d(v, scale, scale, scale); |
120 } | 124 } |
121 | 125 |
122 } // namespace gfx | 126 } // namespace gfx |
123 | 127 |
124 #endif // UI_GFX_VECTOR3D_F_H_ | 128 #endif // UI_GFX_VECTOR3D_F_H_ |
OLD | NEW |