OLD | NEW |
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/vector2d_f.h" | 5 #include "ui/gfx/vector2d_f.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 float Vector2dF::Length() const { | 45 float Vector2dF::Length() const { |
46 return static_cast<float>(std::sqrt(LengthSquared())); | 46 return static_cast<float>(std::sqrt(LengthSquared())); |
47 } | 47 } |
48 | 48 |
49 void Vector2dF::Scale(float x_scale, float y_scale) { | 49 void Vector2dF::Scale(float x_scale, float y_scale) { |
50 x_ *= x_scale; | 50 x_ *= x_scale; |
51 y_ *= y_scale; | 51 y_ *= y_scale; |
52 } | 52 } |
53 | 53 |
| 54 double CrossProduct(const Vector2dF& lhs, const Vector2dF& rhs) { |
| 55 return static_cast<double>(lhs.x()) * rhs.y() - |
| 56 static_cast<double>(lhs.y()) * rhs.x(); |
| 57 } |
| 58 |
| 59 double DotProduct(const Vector2dF& lhs, const Vector2dF& rhs) { |
| 60 return static_cast<double>(lhs.x()) * rhs.x() + |
| 61 static_cast<double>(lhs.y()) * rhs.y(); |
| 62 } |
| 63 |
54 } // namespace gfx | 64 } // namespace gfx |
OLD | NEW |