10#include "matrix/SRect.h"
18 STSwap<float>(fLeft, fRight);
22 STSwap<float>(fTop, fBottom);
26void SRect::toQuad(SPoint quad[4])
const
30 quad[0].set(fLeft, fTop);
31 quad[1].set(fRight, fTop);
32 quad[2].set(fRight, fBottom);
33 quad[3].set(fLeft, fBottom);
36bool SRect::setBoundsCheck(
const SPoint pts[],
int count)
38 SASSERT((pts && count > 0) || count == 0);
44 memset(
this, 0,
sizeof(SRect));
59 for (
int i = 1; i < count; i++)
80 SASSERT(!accum || !SFloatIsFinite(accum));
86 this->set(l, t, r, b);
94bool STriangle::contains(
const SPoint &pt)
const
97 SPoint v0 = fPts[2] - fPts[0];
98 SPoint v1 = fPts[1] - fPts[0];
99 SPoint v2 = pt - fPts[0];
102 double dot00 = v0.dot(v0);
103 double dot01 = v0.dot(v1);
104 double dot02 = v0.dot(v2);
105 double dot11 = v1.dot(v1);
106 double dot12 = v1.dot(v2);
108 double w = dot00 * dot11 - dot01 * dot01;
113 double wSign = w < 0 ? -1 : 1;
114 double u = (dot11 * dot02 - dot01 * dot12) * wSign;
119 double v = (dot00 * dot12 - dot01 * dot02) * wSign;
124 return u + v < w * wSign;
127bool SQuad::contains(
const SPoint &pt)
const
133 tri.fPts[0] = fPts[0];
134 tri.fPts[1] = fPts[1];
135 tri.fPts[2] = fPts[2];
136 bRet = tri.contains(pt);
141 tri.fPts[0] = fPts[0];
142 tri.fPts[1] = fPts[2];
143 tri.fPts[2] = fPts[3];
144 bRet = tri.contains(pt);