Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: ui/gfx/point3_f.h

Issue 11367025: ui: Add the gfx::Vector3dF class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Just for git-try Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/point3_f.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/point3_f.h
diff --git a/ui/gfx/point3_f.h b/ui/gfx/point3_f.h
index c0aefb5b53391383f9e6d6896e12ba1886c1f2b7..6c45a7d34a336297c5c83c1b807ac4be016481b0 100644
--- a/ui/gfx/point3_f.h
+++ b/ui/gfx/point3_f.h
@@ -5,12 +5,16 @@
#ifndef UI_GFX_POINT3_F_H_
#define UI_GFX_POINT3_F_H_
+#include <string>
+
+#include "ui/base/ui_export.h"
#include "ui/gfx/point_f.h"
+#include "ui/gfx/vector3d_f.h"
namespace gfx {
// A point has an x, y and z coordinate.
-class Point3F {
+class UI_EXPORT Point3F {
public:
Point3F() : x_(0), y_(0), z_(0) {}
@@ -44,6 +48,9 @@ class Point3F {
PointF AsPointF() const { return PointF(x_, y_); }
+ // Returns a string representation of 3d point.
+ std::string ToString() const;
+
private:
float x_;
float y_;
@@ -52,6 +59,29 @@ class Point3F {
// copy/assign are allowed.
};
+inline bool operator==(const Point3F& lhs, const Point3F& rhs) {
+ return lhs.x() == rhs.x() && lhs.y() == rhs.y() && lhs.z() == rhs.z();
+}
+
+inline bool operator!=(const Point3F& lhs, const Point3F& rhs) {
+ return !(lhs == rhs);
+}
+
+// Add a vector to a point, producing a new point offset by the vector.
+UI_EXPORT Point3F operator+(const Point3F& lhs, const Vector3dF& rhs);
+
+// Subtract a vector from a point, producing a new point offset by the vector's
+// inverse.
+UI_EXPORT Point3F operator-(const Point3F& lhs, const Vector3dF& rhs);
+
+// Subtract one point from another, producing a vector that represents the
+// distances between the two points along each axis.
+UI_EXPORT Vector3dF operator-(const Point3F& lhs, const Point3F& rhs);
+
+inline Point3F PointAtOffsetFromOrigin(const Vector3dF& offset) {
+ return Point3F(offset.x(), offset.y(), offset.z());
+}
+
} // namespace gfx
#endif // UI_GFX_POINT3_F_H_
« no previous file with comments | « no previous file | ui/gfx/point3_f.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698