OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2014 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #include "SkMatrix.h" | |
9 #include "SkPoint.h" | |
10 #include "SkScalar.h" | |
11 | |
12 void Sk2x2Givens(SkVector h, SkMatrix* G) { | |
13 const SkScalar& a = h.fX; | |
14 const SkScalar& b = h.fY; | |
15 SkScalar c, s; | |
16 if (0 == b) { | |
17 c = SkScalarCopySign(SK_Scalar1, a); | |
18 s = 0; | |
19 } else if (0 == a) { | |
20 c = 0; | |
21 s = -SkScalarCopySign(SK_Scalar1, b); | |
22 } else if (SkScalarAbs(b) > SkScalarAbs(a)) { | |
23 SkScalar t = a / b; | |
24 SkScalar u = SkScalarCopySign(SkScalarSqrt(SK_Scalar1 + t*t), b); | |
25 s = -SK_Scalar1 / u; | |
26 c = -s * t; | |
27 } else { | |
28 SkScalar t = b / a; | |
29 SkScalar u = SkScalarCopySign(SkScalarSqrt(SK_Scalar1 + t*t), a); | |
30 c = SK_Scalar1 / u; | |
31 s = -c * t; | |
32 } | |
33 | |
34 G->setAll(c, -s, 0, | |
reed1
2014/03/26 20:19:57
SkMatrix::setSinCos(-s, c)
bungeman-skia
2014/04/08 21:33:39
Done.
| |
35 s, c, 0, | |
36 0, 0, SkScalarToPersp(SK_Scalar1)); | |
37 } | |
OLD | NEW |