Chromium Code Reviews| Index: mojo/services/geometry/cpp/geometry_util.cc |
| diff --git a/mojo/services/geometry/cpp/geometry_util.cc b/mojo/services/geometry/cpp/geometry_util.cc |
| index 570f707a2462db19f7e2cbfeb79c8308e8b5c573..bb9353d1c1826dc13cc169331ba1df1c1b997ae1 100644 |
| --- a/mojo/services/geometry/cpp/geometry_util.cc |
| +++ b/mojo/services/geometry/cpp/geometry_util.cc |
| @@ -26,4 +26,19 @@ void SetTranslationTransform(Transform* transform, float x, float y, float z) { |
| transform->matrix[11] = z; |
| } |
| +Point TransformPoint(const Transform& transform, const Point& point) { |
| + Point result; |
| + result.x = transform.matrix[0] * point.x + transform.matrix[1] * point.y + |
| + transform.matrix[3]; |
| + result.y = transform.matrix[4] * point.x + transform.matrix[5] * point.y + |
| + transform.matrix[7]; |
| + float z = transform.matrix[12] * point.x + transform.matrix[13] * point.y + |
|
abarth
2016/03/09 04:17:37
We usually call this quantity `w`
|
| + transform.matrix[15]; |
| + if (z) |
| + z = 1.f / z; |
|
abarth
2016/03/09 04:17:37
If `w` is zero, the Point should be at infinity.
jeffbrown
2016/03/09 19:38:50
Well, but which infinity? This behavior is consis
|
| + result.x *= z; |
| + result.y *= z; |
| + return result; |
| +} |
| + |
| } // namespace mojo |