net.algart.model3d.common.movement.model
Class BunkerWall

java.lang.Object
  extended by net.algart.model3d.common.movement.model.BunkerWall
All Implemented Interfaces:
Item

public final class BunkerWall
extends java.lang.Object
implements Item

Solid plane wall, used for forming a bunker, where another items are moving and interacting. Formally, the wall is an infinite half-space, described by an inequality ax+by+czd. It is supposed that all this half-space is filled by some solid elastic matter, and the area ax+by+cz>d is free: items can freely move there. Thus, several walls can describe some polyhedron, the interior of which (where aix+biy+ciz>di for all walls (ai, bi, ci, di)) is a "bunker" for placing another items.

The bunker wall is fully described by 4 numbers a,b,c,d. But such wall is infinite and not convenient for drawing in GUI. To solve this problem, you should specify a set of vertices for every wall: a sequence of 3 or more 3D points, which are supposed to lie at the plane ax+by+cz=d and which are sequential vertices of some polygon inside this plane. The drawing algorithm should draw only the part of the wall plane inside this polygon. The vertices should not affect to the physical model, in particular, to any interaction rule: the wall is supposed to exist also outside this polygon, but there it is invisible (transparent).

Note: the norm of (a,b,c) vector is always 1.0: a²+b²+c²=1.0. The coefficients are normalized automatically while instantiating by the constructor.

It is supposed that the wall acts to any item which intersects it, i.e. partially lies inside the area ax+by+cz<d, filled by a matter. Namely, the wall ejects such an item outside to the free space ax+by+cz>d with a force, depending on the volume of intersection and directed along (a,b,c) vector.

This class is immutable and thread-safe: there are no ways to modify settings of the created instance.

AlgART Laboratory 2010

Since:
JDK 1.5
Version:
1.0
Author:
Daniel Alievsky

Constructor Summary
Constructor and Description
BunkerWall(double a, double b, double c, double d, double... verticesXYZ)
          Creates new wall: an infinite half-space ax+by+czd, filled by elastic solid matter.
 
Method Summary
Modifier and Type Method and Description
 double getA()
          The coefficient a in the inequality ax+by+czd, describing the wall.
 double getB()
          The coefficient b in the inequality ax+by+czd, describing the wall.
 double getC()
          The coefficient c in the inequality ax+by+czd, describing the wall.
 double getD()
          The coefficient d in the inequality ax+by+czd, describing the wall.
 int getVerticesCount()
          The number of vertices of the polygon which should be drawn: verticesXYZ.length/3, where verticesXYZ is the last argument of the constructor.
 double[] getVerticesXYZ()
          Returns all vertices of the polygon which should be drawn.
 boolean isCenterOutside(HavingCenter item)
          Returns true if and only if ax+by+cz<d, where (x,y,z) is the coordinate of the center of the specified item.
 boolean isFullyOutside(Spherical item)
          Returns true if and only if ax+by+czdr, where (x,y,z) is the coordinate of the center of the specified item and r is its radius.
 boolean isPartiallyOutside(Spherical item)
          Returns true if and only if ax+by+cz<d+r, where (x,y,z) is the coordinate of the center of the specified item and r is its radius.
 java.lang.String toString()
          Returns a brief string description of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BunkerWall

public BunkerWall(double a,
                  double b,
                  double c,
                  double d,
                  double... verticesXYZ)
Creates new wall: an infinite half-space ax+by+czd, filled by elastic solid matter.

The coefficients a,b,c,d are passed via the arguments. The vector (a,b,c) is automatically normalized: all 4 numbers are divided by Math.sqrt(a²+b²+c²).

The verticesXYZ argument should specify the sequence of 3D vertices of some polygon inside the plane ax+by+cz=d, if you want to draw this wall in GUI. Namely, this argument should contain an array of (x,y,z) triplets: verticesXYZ[3*k] is x, verticesXYZ[3*k+1] is y, verticesXYZ[3*k+2] is z. Usually this array contains 4 vertices (12 numbers). The minimal number of vertices for correct drawing is 3 (9 numbers).

The passed verticesXYZ argument is cloned by this constructor: no references to it are maintained by the created object.

Parameters:
a - the coefficient a.
b - the coefficient b.
c - the coefficient c.
d - the coefficient d.
verticesXYZ - the sequential vertices of some polygon inside the wall boundary, which will be drawn by 3D-drawing algorithms.
Throws:
java.lang.IllegalArgumentException - if (a,b,c) is zero (and, so, cannot be normalized), or if the length of verticesXYZ array is not divisible by 3.
Method Detail

getA

public double getA()
The coefficient a in the inequality ax+by+czd, describing the wall. Note that the norm of the returned vector (a,b,c) is always 1.0: a²+b²+c²=1.0.

Returns:
the coefficient a.

getB

public double getB()
The coefficient b in the inequality ax+by+czd, describing the wall. Note that the norm of the returned vector (a,b,c) is always 1.0: a²+b²+c²=1.0.

Returns:
the coefficient b.

getC

public double getC()
The coefficient c in the inequality ax+by+czd, describing the wall. Note that the norm of the returned vector (a,b,c) is always 1.0: a²+b²+c²=1.0.

Returns:
the coefficient c.

getD

public double getD()
The coefficient d in the inequality ax+by+czd, describing the wall. Note that the norm of the returned vector (a,b,c) is always 1.0: a²+b²+c²=1.0.

Returns:
the coefficient d.

getVerticesCount

public int getVerticesCount()
The number of vertices of the polygon which should be drawn: verticesXYZ.length/3, where verticesXYZ is the last argument of the constructor.

Returns:
the number of vertices.

getVerticesXYZ

public double[] getVerticesXYZ()
Returns all vertices of the polygon which should be drawn. The returned array is identical to the verticesXYZ array passed to the constructor.

The returned array is a clone of the internal array stored in this object.

Returns:
all vertices of the polygon which should be drawn.

isCenterOutside

public boolean isCenterOutside(HavingCenter item)
Returns true if and only if ax+by+cz<d, where (x,y,z) is the coordinate of the center of the specified item.

Parameters:
item - some item which has a geometrical center.
Returns:
whether the center of the specified item is outside the free bunker space (and, so, inside the wall material).

isPartiallyOutside

public boolean isPartiallyOutside(Spherical item)
Returns true if and only if ax+by+cz<d+r, where (x,y,z) is the coordinate of the center of the specified item and r is its radius.

Parameters:
item - some Spherical item.
Returns:
whether some part of the specified sphere is outside the free bunker space (and, so, intersects with the wall).

isFullyOutside

public boolean isFullyOutside(Spherical item)
Returns true if and only if ax+by+czdr, where (x,y,z) is the coordinate of the center of the specified item and r is its radius.

Parameters:
item - some Spherical item.
Returns:
whether the specified sphere is fully outside the free bunker space (and, so, fully inside the wall material).

toString

public java.lang.String toString()
Returns a brief string description of this object.

The result of this method may depend on implementation.

Overrides:
toString in class java.lang.Object
Returns:
a brief string description of this object.


Hot at AlgART: HTML для чайников | Trinity for non-Christians | Диалог с Богом | Religion and Geometry