summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/bbox3.h
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-04-02 23:03:22 +0000
committerKarl Berry <karl@freefriends.org>2013-04-02 23:03:22 +0000
commit324efbd652f973cd70f42fe08c665c518995bcbe (patch)
tree818ae382dfa133f3dcceec8e12e4cbd42be8bcf4 /Build/source/utils/asymptote/bbox3.h
parentbbf699abe485e707133ff3ba502119f261f27269 (diff)
asy 2.21 sources (no runtime update)
git-svn-id: svn://tug.org/texlive/trunk@29618 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/bbox3.h')
-rw-r--r--Build/source/utils/asymptote/bbox3.h42
1 files changed, 40 insertions, 2 deletions
diff --git a/Build/source/utils/asymptote/bbox3.h b/Build/source/utils/asymptote/bbox3.h
index 5659f24b6ee..b28921c305a 100644
--- a/Build/source/utils/asymptote/bbox3.h
+++ b/Build/source/utils/asymptote/bbox3.h
@@ -49,11 +49,22 @@ struct bbox3 {
{
}
+ // Start a bbox3 with 2 points
+ bbox3(const triple& m, const triple& M)
+ : empty(false),
+ left(m.getx()), bottom(m.gety()), lower(m.getz()),
+ right(M.getx()), top(M.gety()), upper(M.getz())
+ {
+ }
+
// Add a point to a bbox3
void add(const triple& v)
{
- double x = v.getx(), y = v.gety(), z = v.getz();
-
+ const double x = v.getx(), y = v.gety(), z = v.getz();
+ add(x,y,z);
+ }
+ void add(double x, double y, double z)
+ {
if (empty) {
left = right = x;
top = bottom = y;
@@ -144,6 +155,33 @@ struct bbox3 {
return triple(right,top,upper);
}
+ // transform bbox3 by 4x4 column-major matrix
+ void transform(const double* m)
+ {
+ const double xmin = left;
+ const double ymin = bottom;
+ const double zmin = lower;
+ const double xmax = right;
+ const double ymax = top;
+ const double zmax = upper;
+
+ empty = true;
+ add(m*triple(xmin,ymin,zmin));
+ addnonempty(m*triple(xmin,ymin,zmax));
+ addnonempty(m*triple(xmin,ymax,zmin));
+ addnonempty(m*triple(xmin,ymax,zmax));
+ addnonempty(m*triple(xmax,ymin,zmin));
+ addnonempty(m*triple(xmax,ymin,zmax));
+ addnonempty(m*triple(xmax,ymax,zmin));
+ addnonempty(m*triple(xmax,ymax,zmax));
+ }
+
+ friend ostream& operator << (ostream& out, const bbox3& b)
+ {
+ out << "Min " << b.Min() << " Max " << b.Max();
+ return out;
+ }
+
};
} // namespace camp