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

Side by Side Diff: ui/gfx/geometry/vector3d_f.cc

Issue 2051343002: Make various gfx classes more amenable to use as compile-time constants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete destructor Created 4 years, 6 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
« no previous file with comments | « ui/gfx/geometry/vector3d_f.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/gfx/geometry/vector3d_f.h" 5 #include "ui/gfx/geometry/vector3d_f.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 10
11 namespace { 11 namespace {
12 const float kRadiansToDegrees = 180.0f / 3.14159265f; 12 const float kRadiansToDegrees = 180.0f / 3.14159265f;
13 } 13 }
14 14
15 namespace gfx { 15 namespace gfx {
16 16
17 Vector3dF::Vector3dF()
18 : x_(0),
19 y_(0),
20 z_(0) {
21 }
22
23 Vector3dF::Vector3dF(float x, float y, float z)
24 : x_(x),
25 y_(y),
26 z_(z) {
27 }
28
29 Vector3dF::Vector3dF(const Vector2dF& other)
30 : x_(other.x()),
31 y_(other.y()),
32 z_(0) {
33 }
34
35 std::string Vector3dF::ToString() const { 17 std::string Vector3dF::ToString() const {
36 return base::StringPrintf("[%f %f %f]", x_, y_, z_); 18 return base::StringPrintf("[%f %f %f]", x_, y_, z_);
37 } 19 }
38 20
39 bool Vector3dF::IsZero() const { 21 bool Vector3dF::IsZero() const {
40 return x_ == 0 && y_ == 0 && z_ == 0; 22 return x_ == 0 && y_ == 0 && z_ == 0;
41 } 23 }
42 24
43 void Vector3dF::Add(const Vector3dF& other) { 25 void Vector3dF::Add(const Vector3dF& other) {
44 x_ += other.x_; 26 x_ += other.x_;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 86
105 // If the dot product of this cross product is normal, it means that the 87 // If the dot product of this cross product is normal, it means that the
106 // shortest angle between |base| and |other| was counterclockwise with respect 88 // shortest angle between |base| and |other| was counterclockwise with respect
107 // to the surface represented by |normal| and this angle must be reversed. 89 // to the surface represented by |normal| and this angle must be reversed.
108 if (gfx::DotProduct(cross, normal) > 0.0f) 90 if (gfx::DotProduct(cross, normal) > 0.0f)
109 angle = 360.0f - angle; 91 angle = 360.0f - angle;
110 return angle; 92 return angle;
111 } 93 }
112 94
113 } // namespace gfx 95 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/vector3d_f.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698