1
2
3
4
5
6 package nl.tudelft.simulation.language.d3;
7
8 import javax.media.j3d.Bounds;
9 import javax.vecmath.Point3d;
10
11 /***
12 * A bounding box.
13 * <p>
14 * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft University of Technology </a>, the
15 * Netherlands.
16 * <p>
17 * See for project information <a
18 * href="http://www.simulation.tudelft.nl/dsol/language">www.simulation.tudelft.nl/language </a> <br>
19 * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser General Public License (LGPL)
20 * </a>, no warranty
21 *
22 * @author <a href="http://www.peter-jacobs.com/index.htm">Peter Jacobs </a>
23 * @version $Revision: 1.7 $ $Date: 2005/07/04 12:21:22 $
24 * @since 1.5
25 */
26 public class BoundingBox extends javax.media.j3d.BoundingBox
27 {
28 /***
29 * constructs a new BoundingBox.
30 */
31 public BoundingBox()
32 {
33 super();
34 }
35
36 /***
37 * constructs a new BoundingBox around [0;0;0].
38 *
39 * @param deltaX
40 * the deltaX
41 * @param deltaY
42 * the deltaY
43 * @param deltaZ
44 * the deltaZ
45 */
46 public BoundingBox(final double deltaX, final double deltaY, final double deltaZ)
47 {
48 super(new Point3d(-0.5 * deltaX, -0.5 * deltaY, -0.5 * deltaZ), new Point3d(0.5 * deltaX,
49 0.5 * deltaY, 0.5 * deltaZ));
50 this.normalize();
51 }
52
53 /***
54 * constructs a new BoundingBox.
55 *
56 * @param arg0
57 * the boundaries
58 */
59 public BoundingBox(final Bounds arg0)
60 {
61 super(arg0);
62 this.normalize();
63 }
64
65 /***
66 * constructs a new BoundingBox.
67 *
68 * @param arg0
69 * the boundaries
70 */
71 public BoundingBox(final Bounds[] arg0)
72 {
73 super(arg0);
74 this.normalize();
75 }
76
77 /***
78 * constructs a new BoundingBox.
79 *
80 * @param arg0
81 * the boundaries
82 * @param arg1
83 * the point
84 */
85 public BoundingBox(final Point3d arg0, final Point3d arg1)
86 {
87 super(arg0, arg1);
88 this.normalize();
89 }
90
91 /***
92 * normalizes the boundingBox.
93 */
94 public final void normalize()
95 {
96 Point3d p1 = new Point3d();
97 Point3d p2 = new Point3d();
98 this.getLower(p1);
99 this.getUpper(p2);
100 this.setLower(new Point3d(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y), Math.min(p1.z, p2.z)));
101 this.setUpper(new Point3d(Math.max(p1.x, p2.x), Math.max(p1.y, p2.y), Math.max(p1.z, p2.z)));
102 }
103 }