Flutter Engine
The Flutter Engine
Functions
SkMatrix22.h File Reference
#include "include/core/SkPoint.h"

Go to the source code of this file.

Functions

void SkComputeGivensRotation (const SkVector &h, SkMatrix *G)
 

Function Documentation

◆ SkComputeGivensRotation()

void SkComputeGivensRotation ( const SkVector h,
SkMatrix G 
)

Find the Givens matrix G, which is the rotational matrix that rotates the vector h to the positive hoizontal axis. G * h = [hypot(h), 0]

This is equivalent to

SkScalar r = h.length(); SkScalar r_inv = r ? SkScalarInvert(r) : 0; h.scale(r_inv); G->setSinCos(-h.fY, h.fX);

but has better numerical stability by using (partial) hypot, and saves a multiply by not computing r.

Definition at line 14 of file SkMatrix22.cpp.

14 {
15 const SkScalar& a = h.fX;
16 const SkScalar& b = h.fY;
17 SkScalar c, s;
18 if (0 == b) {
20 s = 0;
21 //r = SkScalarAbs(a);
22 } else if (0 == a) {
23 c = 0;
25 //r = SkScalarAbs(b);
26 } else if (SkScalarAbs(b) > SkScalarAbs(a)) {
27 SkScalar t = a / b;
29 s = -SK_Scalar1 / u;
30 c = -s * t;
31 //r = b * u;
32 } else {
33 SkScalar t = b / a;
35 c = SK_Scalar1 / u;
36 s = -c * t;
37 //r = a * u;
38 }
39
40 G->setSinCos(s, c);
41}
#define SkScalarCopySign(x, y)
Definition: SkScalar.h:40
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkScalarSqrt(x)
Definition: SkScalar.h:42
#define SkScalarAbs(x)
Definition: SkScalar.h:39
float SkScalar
Definition: extension.cpp:12
static bool b
struct MyStruct s
struct MyStruct a[10]
SkScalar h
Definition: SkMD5.cpp:125