home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
oct93
/
graphics
/
graphtal.lha
/
Graphtal
/
BoundingBox.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-17
|
2KB
|
63 lines
/*
* BoundingBox.C - methods for class BoundingBox.
*
* Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
* University of Berne, Switzerland
* All rights reserved.
*
* This software may be freely copied, modified, and redistributed
* provided that this copyright notice is preserved on all copies.
*
* You may not distribute this software, in whole or in part, as part of
* any commercial product without the express consent of the authors.
*
* There is no warranty or other guarantee of fitness of this software
* for any purpose. It is provided solely "as is".
*
*/
#include <values.h>
#include "BoundingBox.h"
#include "TransMatrix.h"
//___________________________________________________________ BoundingBox
BoundingBox::BoundingBox()
: vmin(MAXDOUBLE, MAXDOUBLE, MAXDOUBLE), vmax(-MAXDOUBLE, -MAXDOUBLE, -MAXDOUBLE)
{}
BoundingBox BoundingBox::transform(const TransMatrix& tmat) const
{
BoundingBox retval;
retval.expand(Vector(vmin[0], vmin[1], vmin[2])*tmat);
retval.expand(Vector(vmax[0], vmin[1], vmin[2])*tmat);
retval.expand(Vector(vmax[0], vmax[1], vmin[2])*tmat);
retval.expand(Vector(vmin[0], vmax[1], vmin[2])*tmat);
retval.expand(Vector(vmin[0], vmin[1], vmax[2])*tmat);
retval.expand(Vector(vmax[0], vmin[1], vmax[2])*tmat);
retval.expand(Vector(vmax[0], vmax[1], vmax[2])*tmat);
retval.expand(Vector(vmin[0], vmax[1], vmax[2])*tmat);
return retval;
}
void BoundingBox::expand(const Vector& v)
{
if (v[0] < vmin[0]) vmin[0] = v[0]; if (v[0] > vmax[0]) vmax[0] = v[0];
if (v[1] < vmin[1]) vmin[1] = v[1]; if (v[1] > vmax[1]) vmax[1] = v[1];
if (v[2] < vmin[2]) vmin[2] = v[2]; if (v[2] > vmax[2]) vmax[2] = v[2];
}
void BoundingBox::expand(const BoundingBox& b)
{
expand(b.vmin);
expand(b.vmax);
}
ostream& operator<<(ostream& os, const BoundingBox& b)
{
return os << "{ min" << b.vmin << ", max" << b.vmax << " }";
}