net.algart.drawing3d Class PlanePolygon3D

java.lang.Object net.algart.drawing3d.PlanePolygon3D
All Implemented Interfaces:
Shape3D

public class PlanePolygon3D
extends java.lang.Object
implements Shape3D

Plane polygon, placed in 3D space.

This figure is a polygon inside some plane ax+by+cz=d, where a,b,c,d are parameters of this class. Inside this plane, this polygon is specified by a sequence of 3 or more 3D points, which are supposed to lie at this plane and which are sequential vertices of this polygon. The vertices are also parameters of this class.

The polygon is usually supposed to be convex: it is not checked, but the drawing algorithm of this figure, offered by ConvexPlanePolygon3DDrawingRule class, works incorrectly if it is not convex.

The vertices are supposed to lie at the plane ax+by+cz=d, but it is also not checked; if it is not so, the drawing algorithms can work incorrectly.

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.

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
PlanePolygon3D(double a, double b, double c, double d, double... verticesXYZ)
Creates new plane polygon: a polygonal area inside the plane ax+by+cz=d, restricted by a closed polyline with the vertices with coordinates verticeXYZ.

Method Summary
Modifier and Type Method and Description
double getA()
The coefficient a in the plane equation ax+by+cz=d.
double getB()
The coefficient b in the plane equation ax+by+cz=d.
double getC()
The coefficient c in the plane equation ax+by+cz=d.
double getD()
The coefficient d in the plane equation ax+by+cz=d.
int getVerticesCount()
The number of vertices of the polygon: verticesXYZ.length/3, where verticesXYZ is the last argument of the constructor.
double[] getVerticesXYZ()
Returns all vertices of the polygon.
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

PlanePolygon3D

public PlanePolygon3D(double a,
double b,
double c,
double d,
double... verticesXYZ)
Creates new plane polygon: a polygonal area inside the plane ax+by+cz=d, restricted by a closed polyline with the vertices with coordinates verticeXYZ.

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. 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 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, or if the length of verticesXYZ array is less than 9 (3 vertices).
Method Detail

getA

public double getA()
The coefficient a in the plane equation ax+by+cz=d. 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 plane equation ax+by+cz=d. 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 plane equation ax+by+cz=d. 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 plane equation ax+by+cz=d. 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: 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. 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.

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.