OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
| 8 #ifndef SkMatrix22_DEFINED |
| 9 #define SkMatrix22_DEFINED |
| 10 |
8 #include "SkPoint.h" | 11 #include "SkPoint.h" |
9 | 12 |
10 class SkMatrix; | 13 class SkMatrix; |
11 | 14 |
12 /** Find the Givens matrix G, which is the rotational matrix | 15 /** Find the Givens matrix G, which is the rotational matrix |
13 * that rotates the vector h to the positive hoizontal axis. | 16 * that rotates the vector h to the positive hoizontal axis. |
14 * G * h = [hypot(h), 0] | 17 * G * h = [hypot(h), 0] |
15 * | 18 * |
16 * This is equivalent to | 19 * This is equivalent to |
17 * | 20 * |
18 * SkScalar r = h.length(); | 21 * SkScalar r = h.length(); |
19 * SkScalar r_inv = r ? SkScalarInvert(r) : 0; | 22 * SkScalar r_inv = r ? SkScalarInvert(r) : 0; |
20 * h.scale(r_inv); | 23 * h.scale(r_inv); |
21 * G->setSinCos(-h.fY, h.fX); | 24 * G->setSinCos(-h.fY, h.fX); |
22 * | 25 * |
23 * but has better numerical stability by using (partial) hypot, | 26 * but has better numerical stability by using (partial) hypot, |
24 * and saves a multiply by not computing r. | 27 * and saves a multiply by not computing r. |
25 */ | 28 */ |
26 void SkComputeGivensRotation(const SkVector& h, SkMatrix* G); | 29 void SkComputeGivensRotation(const SkVector& h, SkMatrix* G); |
| 30 |
| 31 #endif |
OLD | NEW |