diff options
author | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-08 15:31:11 +0000 |
---|---|---|
committer | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-08 15:31:11 +0000 |
commit | 80248e3395ac8f5d52e8e290435cdce6482a6726 (patch) | |
tree | 397cbe07f35593f6c77c539dbddca331bf7439a5 /ui/gfx/point3.h | |
parent | a9f090b9d48e668ec4e155b247b2d7fe25fe0f01 (diff) | |
download | chromium_src-80248e3395ac8f5d52e8e290435cdce6482a6726.zip chromium_src-80248e3395ac8f5d52e8e290435cdce6482a6726.tar.gz chromium_src-80248e3395ac8f5d52e8e290435cdce6482a6726.tar.bz2 |
Use SkMatrix44 for the underlying implementation of ui::Transform
BUG=
TEST=ui_unittest
Review URL: http://codereview.chromium.org/7044062
Patch from Ian Vollick <vollick@chromium.org>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/point3.h')
-rw-r--r-- | ui/gfx/point3.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ui/gfx/point3.h b/ui/gfx/point3.h new file mode 100644 index 0000000..d84aa07 --- /dev/null +++ b/ui/gfx/point3.h @@ -0,0 +1,63 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_GFX_POINT3_H_ +#define UI_GFX_POINT3_H_ +#pragma once + +#include <cmath> + +#include "ui/gfx/point.h" + +namespace gfx { + +// A point has an x, y and z coordinate. +class Point3f { + public: + Point3f() : x_(0), y_(0), z_(0) {} + + Point3f(float x, float y, float z) : x_(x), y_(y), z_(z) {} + + Point3f(const Point& point) : x_(point.x()), y_(point.y()), z_(0) {} + + ~Point3f() {} + + float x() const { return x_; } + float y() const { return y_; } + float z() const { return z_; } + + void set_x(float x) { x_ = x; } + void set_y(float y) { y_ = y; } + void set_z(float z) { z_ = z; } + + void SetPoint(float x, float y, float z) { + x_ = x; + y_ = y; + z_ = z; + } + + // Returns the squared euclidean distance between two points. + float SquaredDistanceTo(const Point3f& other) const { + float dx = x_ - other.x_; + float dy = y_ - other.y_; + float dz = z_ - other.z_; + return dx * dx + dy * dy + dz * dz; + } + + Point AsPoint() const { + return Point(static_cast<int>(std::floor(x_)), + static_cast<int>(std::floor(y_))); + } + + private: + float x_; + float y_; + float z_; + + // copy/assign are allowed. +}; + +} // namespace gfx + +#endif // UI_GFX_POINT3_H_ |