soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SPoint.cpp
1
2/*
3 * Copyright 2008 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8#include <souistd.h>
9#include "matrix/SPoint.h"
10
11SNSBEGIN
12
13float SPoint::Length(float dx, float dy)
14{
15 float mag2 = dx * dx + dy * dy;
16 if (SFloatIsFinite(mag2))
17 {
18 return sk_float_sqrt(mag2);
19 }
20 else
21 {
22 double xx = dx;
23 double yy = dy;
24 return (float)sqrt(xx * xx + yy * yy);
25 }
26}
27
28void SPoint::iset(int32_t x, int32_t y)
29{
30 fX = SkIntToScalar(x);
31 fY = SkIntToScalar(y);
32}
33
34void SPoint::iset(const POINT &p)
35{
36 fX = SkIntToScalar(p.x);
37 fY = SkIntToScalar(p.y);
38}
39
40POINT SPoint::toPoint() const
41{
42 POINT pt = { SFloatRoundToInt(fX), SFloatRoundToInt(fY) };
43 return pt;
44}
45
46float SPoint::dot(const SPoint &vec) const
47{
48 return DotProduct(*this, vec);
49}
50
51float SPoint::DotProduct(const SPoint &a, const SPoint &b)
52{
53 return a.fX * b.fX + a.fY * b.fY;
54}
55
56SNSEND