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

Unified Diff: ui/gfx/vector3d_f.h

Issue 11361186: ui: Add methods to clamp Sizes, Points, and Vectors from above or below. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: varnames Created 8 years, 1 month 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 | « ui/gfx/vector2d_unittest.cc ('k') | ui/gfx/vector3d_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/vector3d_f.h
diff --git a/ui/gfx/vector3d_f.h b/ui/gfx/vector3d_f.h
index a2845f89267880e28b4634df450471e30c520402..7b879bb6959264e840084d79d341c8ee41a764c8 100644
--- a/ui/gfx/vector3d_f.h
+++ b/ui/gfx/vector3d_f.h
@@ -44,6 +44,18 @@ class UI_EXPORT Vector3dF {
void operator+=(const Vector3dF& other) { Add(other); }
void operator-=(const Vector3dF& other) { Subtract(other); }
+ void ClampToMax(const Vector3dF& max) {
+ x_ = x_ <= max.x_ ? x_ : max.x_;
slavi 2012/11/09 19:15:26 Why not just x_ = x_ < max.x_ ? x_ : max.x_; I ge
danakj 2012/11/09 19:54:57 Yeh, it seemed equally good here though, and more
+ y_ = y_ <= max.y_ ? y_ : max.y_;
+ z_ = z_ <= max.z_ ? z_ : max.z_;
+ }
+
+ void ClampToMin(const Vector3dF& min) {
+ x_ = x_ >= min.x_ ? x_ : min.x_;
+ y_ = y_ >= min.y_ ? y_ : min.y_;
+ z_ = z_ >= min.z_ ? z_ : min.z_;
+ }
+
// Gives the square of the diagonal length of the vector.
double LengthSquared() const;
// Gives the diagonal length of the vector.
« no previous file with comments | « ui/gfx/vector2d_unittest.cc ('k') | ui/gfx/vector3d_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698