blob: d0f4ed3155df2638ef72b195f42b02399bdd1ff7 [file] [log] [blame]
bungeman@google.comd3fbd342014-04-15 15:52:07 +00001/*
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 "SkPoint.h"
9
10class SkMatrix;
11
12/** Find the Givens matrix G, which is the rotational matrix
13 * that rotates the vector h to the positive hoizontal axis.
14 * G * h = [hypot(h), 0]
15 *
16 * This is equivalent to
17 *
18 * SkScalar r = h.length();
19 * SkScalar r_inv = r ? SkScalarInvert(r) : 0;
20 * h.scale(r_inv);
21 * G->setSinCos(-h.fY, h.fX);
22 *
23 * but has better numerical stability by using (partial) hypot,
24 * and saves a multiply by not computing r.
25 */
26void SkComputeGivensRotation(const SkVector& h, SkMatrix* G);