bungeman@google.com | d3fbd34 | 2014-04-15 15:52:07 +0000 | [diff] [blame^] | 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 "SkPoint.h" |
| 9 | |
| 10 | class 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 | */ |
| 26 | void SkComputeGivensRotation(const SkVector& h, SkMatrix* G); |