skia2/src/utils/SkMatrix22.cpp
commit-bot@chromium.org 2cfa3200fd fix warnings around size_t/int
fix warnings around undeclared (non-static) functions

TBR=bsalomon@google.com

Author: reed@google.com

Review URL: https://codereview.chromium.org/242643008

git-svn-id: http://skia.googlecode.com/svn/trunk@14267 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-19 22:00:40 +00:00

41 lines
1.0 KiB
C++

/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkMatrix.h"
#include "SkMatrix22.h"
#include "SkPoint.h"
#include "SkScalar.h"
void SkComputeGivensRotation(const SkVector& h, SkMatrix* G) {
const SkScalar& a = h.fX;
const SkScalar& b = h.fY;
SkScalar c, s;
if (0 == b) {
c = SkScalarCopySign(SK_Scalar1, a);
s = 0;
//r = SkScalarAbs(a);
} else if (0 == a) {
c = 0;
s = -SkScalarCopySign(SK_Scalar1, b);
//r = SkScalarAbs(b);
} else if (SkScalarAbs(b) > SkScalarAbs(a)) {
SkScalar t = a / b;
SkScalar u = SkScalarCopySign(SkScalarSqrt(SK_Scalar1 + t*t), b);
s = -SK_Scalar1 / u;
c = -s * t;
//r = b * u;
} else {
SkScalar t = b / a;
SkScalar u = SkScalarCopySign(SkScalarSqrt(SK_Scalar1 + t*t), a);
c = SK_Scalar1 / u;
s = -c * t;
//r = a * u;
}
G->setSinCos(s, c);
}