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

Side by Side Diff: ui/gfx/point3.h

Issue 7044062: Use SkMatrix44 for the underlying implementation of ui::Transform (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Gardening patch Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/interpolated_transform_unittest.cc ('k') | ui/gfx/transform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_GFX_POINT3_H_
6 #define UI_GFX_POINT3_H_
7 #pragma once
8
9 #include <cmath>
10
11 #include "ui/gfx/point.h"
12
13 namespace gfx {
14
15 // A point has an x, y and z coordinate.
16 class Point3f {
17 public:
18 Point3f() : x_(0), y_(0), z_(0) {}
19
20 Point3f(float x, float y, float z) : x_(x), y_(y), z_(z) {}
21
22 Point3f(const Point& point) : x_(point.x()), y_(point.y()), z_(0) {}
23
24 ~Point3f() {}
25
26 float x() const { return x_; }
27 float y() const { return y_; }
28 float z() const { return z_; }
29
30 void set_x(float x) { x_ = x; }
31 void set_y(float y) { y_ = y; }
32 void set_z(float z) { z_ = z; }
33
34 void SetPoint(float x, float y, float z) {
35 x_ = x;
36 y_ = y;
37 z_ = z;
38 }
39
40 // Returns the squared euclidean distance between two points.
41 float SquaredDistanceTo(const Point3f& other) const {
42 float dx = x_ - other.x_;
43 float dy = y_ - other.y_;
44 float dz = z_ - other.z_;
45 return dx * dx + dy * dy + dz * dz;
46 }
47
48 Point AsPoint() const {
49 return Point(static_cast<int>(std::floor(x_)),
50 static_cast<int>(std::floor(y_)));
51 }
52
53 private:
54 float x_;
55 float y_;
56 float z_;
57
58 // copy/assign are allowed.
59 };
60
61 } // namespace gfx
62
63 #endif // UI_GFX_POINT3_H_
OLDNEW
« no previous file with comments | « ui/gfx/interpolated_transform_unittest.cc ('k') | ui/gfx/transform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698