|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.hedgehog.HObject
com.hedgehog.geo.GeometricObject
com.hedgehog.geo.threed.GeometricObject3D
com.hedgehog.geo.threed.shapes.Shape3D
com.hedgehog.geo.threed.shapes.Sphere3D
public class Sphere3D
Title: Sphere3D - models a 3D sphere as a centre and radius.
Description: Models a 3D sphere.
Copyright: Copyright (c) Hedgehog Software 2007-2009.
Company: Hedgehog Software
| Field Summary | |
|---|---|
protected Point3D |
mCentre
Sphere centre. |
protected double |
mRadius
Sphere radius. |
| Fields inherited from class com.hedgehog.HObject |
|---|
mID, mName |
| Constructor Summary | |
|---|---|
Sphere3D()
Constructor. |
|
Sphere3D(double radius)
Creates a new sphere of the specified radius with centre at (0,0,0). |
|
Sphere3D(ID id)
Constructor. |
|
Sphere3D(Point3D centre,
double radius)
Creates a new sphere of the specified radius and specified centre. |
|
Sphere3D(Point3D centre,
double radius,
java.lang.String name,
ID id)
Creates a new sphere of the specified radius and specified centre. |
|
Sphere3D(Point3D p1,
Point3D p2,
Point3D p3,
Point3D p4,
double tolerance)
Constructor. |
|
Sphere3D(Sphere3D object)
Copy constructor. |
|
Sphere3D(java.lang.String name)
Constructor. |
|
Sphere3D(java.lang.String name,
ID id)
Constructor. |
|
Sphere3D(java.util.Vector<Point3D> points,
int maxIterations,
double tolerance)
Constructor. |
|
| Method Summary | |
|---|---|
double |
arcDistanceBetween(Point3D p,
Point3D q)
Returns the distance along a great circular arc between the two specified points. |
double |
area()
Returns the surface area of this sphere; ie 4PIr^2. |
Point3D |
axisXPoint()
Returns the point where the x-axis intersects the sphere. |
Vector3D |
axisXVector()
Returns the vector from the sphere centre to axisXPoint(). |
Point3D |
axisYPoint()
Returns the point where the y-axis intersects the sphere. |
Vector3D |
axisYVector()
Returns the vector from the sphere centre to axisYPoint(). |
Point3D |
axisZPoint()
Returns the point where the z-axis intersects the sphere. |
Vector3D |
axisZVector()
Returns the vector from the sphere centre to axisZPoint(). |
AxisAlignedBox3D |
boundingBox()
Returns the axis-aligned bounding box of this sphere. |
Point3D |
centroid()
Returns the centroid of this sphere; ie its centre. |
java.util.Vector<ModelObject> |
childModelObjects()
Returns a vector of this object's child ModelObject objects. |
java.sql.PreparedStatement |
databaseInsertStatement(java.sql.Connection connection,
int modelID)
Returns a prepared statement for inserting (INSERT command) a ModelObject object into a database. |
java.sql.PreparedStatement |
databaseUpdateStatement(java.sql.Connection connection,
int modelID)
Returns a prepared statement for updating (UPDATE command) a ModelObject object into a database. |
double |
diameter()
Returns the sphere diameter; ie 2r. |
Point3D |
diametricallyOppositePoint(Point3D p,
double tolerance)
Returns the point diametrically opposite the specified point. |
double |
distanceToSphere(Point3D p)
Returns the distance from the specfied point to the sphere surface. |
static Sphere3D |
enclosingSphere(Sphere3D sphere0,
Sphere3D sphere1)
Returns the sphere that encloses the two specified spheres. |
static Sphere3D |
enclosingSphereAverageCentre(java.util.Vector<Point3D> points)
Returns the smallest sphere whose centre is the average of the input points. |
PlanarCircle3D |
equatorCircle()
Returns the planar great circle passing through the centre, axisXPoint() and axisYPoint(). |
ModelObject |
fromDatabase(java.sql.Connection connection,
Model model,
int modelID,
int objectID)
Returns a model object from the specified database table. |
ModelObject |
fromXMLNode(org.w3c.dom.Document document,
org.w3c.dom.Node documentRootNode,
org.w3c.dom.Node node,
Model model)
Returns a model object from the specified xml node. |
Point3D |
furthestPoint(Point3D q,
double tolerance)
Returns the furthest point on this sphere's circumference from the specified point. |
double |
gaussCurvature()
Returns the Gauss curvature; ie k=1/r^2. |
Point3D |
getCentre()
Returns the sphere centre. |
double |
getRadius()
Returns the sphere radius. |
PlanarCircle3D |
greatCircle(double pPhi,
double pTheta,
double qPhi,
double qTheta,
boolean degrees)
Returns a great circle passing through this sphere's centre and the two specified points p(pPhi,pTheta) and q(qPhi,qTheta). |
PlanarCircle3D |
greatCircle(Point3D p,
Point3D q)
Returns a great circle passing through the points p and q. |
Intersection3D |
intersection(Plane3D plane,
double tolerance)
Tests for intersection between the specified plane and this sphere. |
Intersection3D |
intersection(Ray3D ray,
double tolerance)
Returns the intersection object between a sphere and a ray. |
Intersection3D |
intersection(Sphere3D sphere,
double tolerance)
Tests for intersection between this sphere and the specified sphere. |
Intersection3D |
intersection(StraightLine3D line,
double tolerance)
Returns the intersection object between a sphere and a straight line segment. |
double |
intersectionVolume(Sphere3D sphere)
Returns the volume of intersection between this sphere and the specified sphere; ie the volume of the resulting lens shape. |
int |
kissingNumber()
The "kissing number" is the maximum number of times a sphere can touch a central sphere, with all spheres having same size and without intersecting other spheres. |
double |
latitude(Point3D p,
boolean degrees)
Returns the latitude of point p in the range [-90:+90] degrees where -90 degrees is the south pole and +90 degrees is the north pole. |
double |
longitude(Point3D p,
boolean degrees)
Returns the longitude of point p in the range [0:+360] degrees where 0 degrees is zero longitude (x-axis) and +360 is a full revolution and also corresponds to zero longitude. |
double |
meanCurvature()
Returns the mean curvature; ie h=1/r. |
Point3D |
nearestPoint(Point3D q,
double tolerance)
Returns the nearest point on this sphere's surface to the specified point. |
Point3D |
northPole()
Returns the north pole point; ie (cx,cy,cz+r). |
Vector3D |
outwardNormal(Point3D p,
boolean normalise)
Returns the outward normal at the specified point. |
PairDouble |
phiAndThetaFromPoint(Point3D p,
boolean degrees)
Returns the phi and theta values corresponding to point p. |
boolean |
pointInside(Point3D p,
double tolerance)
Tests whether or not the specified point is inside this sphere. |
boolean |
pointInsideOrOnSurface(Point3D p,
double tolerance)
Tests whether or not the specified point is either inside or on the surface of this sphere. |
Point3D |
pointOnSphere(double phiRadians,
double thetaRadians)
Returns the point on a sphere corresponding to the angles phi (-pi/2<=phi<=pi/2) and theta (-pi<=theta<=pi), (both in radians). |
boolean |
pointOnSurface(Point3D p,
double tolerance)
Tests whether or not the specified point is on the surface of this sphere. |
boolean |
pointOutside(Point3D p,
double tolerance)
Tests whether or not the specified point is outside this sphere. |
java.util.Vector<Point3D> |
randomPointsInsideSphere(int no_of_random_points)
Returns a vector of random points inside a sphere. |
java.util.Vector<Point3D> |
randomPointsOnSphere(int no_of_random_points)
Returns a vector of random points on the surface of a sphere. |
Shape3D |
rotate(double theta,
double beta,
double gamma,
Point3D fixedPoint,
boolean degrees)
Rotates this sphere angle theta about z, beta about y and gamma about x. |
Shape3D |
scale(double s,
Point3D fixedPoint)
Scales this sphere by multiplying the radius by the specified scaling factor. |
void |
setCentre(Point3D centre)
Sets the centre. |
void |
setRadius(double radius)
Sets the radius. |
Point3D |
southPole()
Returns the north pole point; ie (cx,cy,cz-r). |
PlanarCircle3D |
sphereCircle(double phi_theta_radians,
boolean const_phi)
Returns a circle on this sphere. |
QuadraticSurface3D |
toQuadraticSurface3D()
Returns the quadratic surface equation equivalent of this sphere; ie Q=(Gz^2+Hxz+Iyz+Jz)+(Ax^2+Bxy+Cy^2+Dx+Ey+F)=0. |
java.lang.String |
toString()
Returns a String representation of a Sphere3D object. |
X3DNode |
toX3DNode(X3DObject x3dObject)
X3D support. |
org.w3c.dom.Element |
toXMLNode(org.w3c.dom.Document document,
org.w3c.dom.Element documentRootNode)
Returns the xml node of this object. |
void |
transform(Matrix4x4 matrix)
Applies the specified transformation matrix to this polygon. |
Shape3D |
translate(double tx,
double ty,
double tz)
Translates this sphere by the specified translate vector (tx,ty,tz). |
double |
volume()
Returns the volume of this sphere; ie (4/3)PI.r^3. |
HDouble |
xValue(HDouble phiRadians,
HDouble thetaRadians)
Returns the x-coordinate of a point on a sphere's surface specified by the (phi,theta) values. |
HDouble |
yValue(HDouble phiRadians,
HDouble thetaRadians)
Returns the y-coordinate of a point on a sphere's surface specified by the (phi,theta) values. |
HDouble |
zValue(HDouble phiRadians,
HDouble thetaRadians)
Returns the z-coordinate of a point on a sphere's surface specified by the (phi,theta) values. |
| Methods inherited from class com.hedgehog.geo.threed.shapes.Shape3D |
|---|
is2D, is3D, isCurve, isGrid, isMesh, isPoint, isPointSet, isShape, isSurface |
| Methods inherited from class com.hedgehog.geo.GeometricObject |
|---|
objectDimension |
| Methods inherited from class com.hedgehog.HObject |
|---|
clone, compare, compareTo, copy, equals, getID, getName, hashCode, hasID, hasName, setID, setName |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Point3D mCentre
protected double mRadius
| Constructor Detail |
|---|
public Sphere3D()
public Sphere3D(double radius)
radius - Sphere radius.
public Sphere3D(Point3D centre,
double radius)
centre - Sphere centre.radius - Sphere radius.
public Sphere3D(Point3D centre,
double radius,
java.lang.String name,
ID id)
centre - Sphere centre.radius - Sphere radius.name - Object name.id - Object ID.
public Sphere3D(Point3D p1,
Point3D p2,
Point3D p3,
Point3D p4,
double tolerance)
throws java.lang.IllegalArgumentException
p1 - Point 1.p2 - Point 2.p3 - Point 3.p4 - Point 4.tolerance - Required tolerance.
java.lang.IllegalArgumentException - Thrown if either p1, p2, p3 or p4 are null. Also thrown if the 4 points are co-planar.
public Sphere3D(java.util.Vector<Point3D> points,
int maxIterations,
double tolerance)
throws java.lang.IllegalArgumentException
points - Vector of points. must be at least 4 points in order to fit a sphere.maxIterations - Maximum number of iterations used to generate a sphere from the specified vector of points. A value of 100
with a tolerance of 1e-03 is suitable for most cases.tolerance - Required tolerance.
java.lang.IllegalArgumentException - Thrown if points is null, points has less than 4 elements or the method did not converge
in generating a sphere that passes through the points vector.public Sphere3D(java.lang.String name)
name - Sphere name.public Sphere3D(ID id)
id - Sphere ID.
public Sphere3D(java.lang.String name,
ID id)
name - Sphere name.id - Sphere ID.public Sphere3D(Sphere3D object)
object - Object to copy.| Method Detail |
|---|
public Point3D getCentre()
public double getRadius()
public void setCentre(Point3D centre)
centre - New centre.public void setRadius(double radius)
radius - New radius.public double diameter()
public double distanceToSphere(Point3D p)
p - Point from which to find distance.
public Point3D nearestPoint(Point3D q,
double tolerance)
q - Point to find nearest point.tolerance - Required tolerance.
public Point3D furthestPoint(Point3D q,
double tolerance)
q - Point to find furthest point.tolerance - Required tolerance.
public Point3D diametricallyOppositePoint(Point3D p,
double tolerance)
throws java.lang.IllegalArgumentException
p - Point on surface.tolerance - Required tolerance.
java.lang.IllegalArgumentException - Thrown if p is not on the surface of this sphere.
public Vector3D outwardNormal(Point3D p,
boolean normalise)
throws java.lang.IllegalArgumentException
p - Point at which to find the outward normal.normalise - Specifies whether or not the returned normal is normalised.
java.lang.IllegalArgumentException - Thrown if p is not on this sphere.public Point3D northPole()
public Point3D southPole()
public Point3D pointOnSphere(double phiRadians,
double thetaRadians)
throws java.lang.IllegalArgumentException
phiRadians - The latitude angle phi in radians [-PI/2:+PI/2].thetaRadians - The longitude angle theta in radians [-PI:+PI].
java.lang.IllegalArgumentException - Thrown if phi_radians or theta_radians are out of range.
public PairDouble phiAndThetaFromPoint(Point3D p,
boolean degrees)
p - Point to map to latitude, longitude coordinates.degrees - If logical-true then the returned pair of angles will be in degrees, else in radians.
public java.util.Vector<Point3D> randomPointsInsideSphere(int no_of_random_points)
throws java.lang.IllegalArgumentException
no_of_random_points - Number of random points.
java.lang.IllegalArgumentException - Thrown if no_of_random_points is <=0.
public java.util.Vector<Point3D> randomPointsOnSphere(int no_of_random_points)
throws java.lang.IllegalArgumentException
no_of_random_points - Number of random points.
java.lang.IllegalArgumentException - Thrown if no_of_random_points<=0.public Point3D axisXPoint()
public Point3D axisYPoint()
public Point3D axisZPoint()
public Vector3D axisXVector()
public Vector3D axisYVector()
public Vector3D axisZVector()
public double arcDistanceBetween(Point3D p,
Point3D q)
p - Point p on sphere surface.q - Point q on sphere surface.
public double longitude(Point3D p,
boolean degrees)
p - Point in which latitude is required.degrees - Specifies whether degrees or radians is required.
public double latitude(Point3D p,
boolean degrees)
p - Point in which latitude is required.degrees - Specifies whether degrees or radians is required.
public HDouble xValue(HDouble phiRadians,
HDouble thetaRadians)
throws java.lang.IllegalArgumentException
phiRadians - phi value of point on surface. Must be in range [-PI/2:PI/2].thetaRadians - theta value of point on surface. Must be in range [-PI:PI].
java.lang.IllegalArgumentException - Thrown if phiRadians or thetaRadians are out of range.
public HDouble yValue(HDouble phiRadians,
HDouble thetaRadians)
throws java.lang.IllegalArgumentException
phiRadians - phi value of point on surface. Must be in range [-PI/2:PI/2].thetaRadians - theta value of point on surface. Must be in range [-PI:PI].
java.lang.IllegalArgumentException - Thrown if phiRadians or thetaRadians are out of range.
public HDouble zValue(HDouble phiRadians,
HDouble thetaRadians)
throws java.lang.IllegalArgumentException
phiRadians - phi value of point on surface. Must be in range [-PI/2:PI/2].thetaRadians - theta value of point on surface. Must be in range [-PI:PI].
java.lang.IllegalArgumentException - Thrown if phiRadians or thetaRadians are out of range.public int kissingNumber()
public java.lang.String toString()
toString in class java.lang.Objectpublic QuadraticSurface3D toQuadraticSurface3D()
public X3DNode toX3DNode(X3DObject x3dObject)
throws InvalidObjectException
toX3DNode in interface ModelObjectx3dObject - X3D object.
InvalidObjectException - Thrown if this object is invalid.
public PlanarCircle3D greatCircle(Point3D p,
Point3D q)
throws java.lang.IllegalArgumentException
p - Point p through which the great circle passes.q - Point q through which the great circle passes.
java.lang.IllegalArgumentException - Thrown if p or q are null.
public PlanarCircle3D greatCircle(double pPhi,
double pTheta,
double qPhi,
double qTheta,
boolean degrees)
throws java.lang.IllegalArgumentException
pPhi - The latitude angle phi in radians [-PI/2:+PI/2] of point p.pTheta - The longitude angle theta in radians [-PI:+PI] of point p.qPhi - The latitude angle phi in radians [-PI/2:+PI/2] of point q.qTheta - The longitude angle theta in radians [-PI:+PI] of point q.degrees - Specifies whether or not the specified angles are in degrees (true) or radians (false).
java.lang.IllegalArgumentException - Thrown if (pPhi,pTheta) or (qPhi,qTheta) are out of range.
public Intersection3D intersection(Sphere3D sphere,
double tolerance)
sphere - Other sphere.tolerance - Required tolerance.
public Intersection3D intersection(Ray3D ray,
double tolerance)
ray - The ray to test for intersection with this sphere.tolerance - Required tolerance.
public Intersection3D intersection(StraightLine3D line,
double tolerance)
line - The straight line to test for intersection with this sphere.tolerance - Required tolerance.
public Intersection3D intersection(Plane3D plane,
double tolerance)
plane - Plane to test for intersection.tolerance - Required tolerance.
Point3D tangential intersection and CIRCLE if a
PlanarCircle3D intersection.public double intersectionVolume(Sphere3D sphere)
sphere - Other sphere.
public PlanarCircle3D sphereCircle(double phi_theta_radians,
boolean const_phi)
throws java.lang.IllegalArgumentException
phi_theta_radians - Theta or phi angle in radians.const_phi - If logical-true then an angle phi is specified, else an angle theta is specified.
java.lang.IllegalArgumentException - Thrown if phi_theta_radians is out of range.public PlanarCircle3D equatorCircle()
public double gaussCurvature()
public double meanCurvature()
public double area()
area in class Shape3Dpublic AxisAlignedBox3D boundingBox()
boundingBox in class Shape3Dpublic Point3D centroid()
centroid in class Shape3D
public boolean pointInside(Point3D p,
double tolerance)
pointInside in class Shape3Dp - Point to test.tolerance - Required tolerance.
public boolean pointOutside(Point3D p,
double tolerance)
pointOutside in class Shape3Dp - Point to test.tolerance - Required tolerance.
public boolean pointOnSurface(Point3D p,
double tolerance)
pointOnSurface in class Shape3Dp - Point to test.tolerance - Required tolerance.
public boolean pointInsideOrOnSurface(Point3D p,
double tolerance)
pointInsideOrOnSurface in class Shape3Dp - Point to test.tolerance - Required tolerance.
public Shape3D rotate(double theta,
double beta,
double gamma,
Point3D fixedPoint,
boolean degrees)
throws java.lang.IllegalArgumentException
rotate in class Shape3Dtheta - Angle of rotation in xy-plane about z-axis.beta - Angle of rotation in zx-plane about y-axis.gamma - Angle of rotation with respect to yz-plane about x-axis.fixedPoint - Fixed point. If null then rotation is with respect to centre.degrees - Specifies whether or not the angles are in degrees or radians.
java.lang.IllegalArgumentException - Thrown if (theta,beta,gamma) are out of range.
public Shape3D scale(double s,
Point3D fixedPoint)
scale in class Shape3Ds - Scaling factor.fixedPoint - Fixed point. Not used in scaling this sphere.
public Shape3D translate(double tx,
double ty,
double tz)
translate in class Shape3Dtx - Translation in x-direction.ty - Translation in y-direction.tz - Translation in z-direction.
public double volume()
volume in class Shape3Dpublic static Sphere3D enclosingSphereAverageCentre(java.util.Vector<Point3D> points)
points - Vector of points.
public static Sphere3D enclosingSphere(Sphere3D sphere0,
Sphere3D sphere1)
sphere0 - Sphere 0.sphere1 - Sphere 1.
public java.util.Vector<ModelObject> childModelObjects()
childModelObjects in interface ModelObject
public java.sql.PreparedStatement databaseInsertStatement(java.sql.Connection connection,
int modelID)
throws java.sql.SQLException
databaseInsertStatement in interface ModelObjectconnection - Database connection.modelID - Model ID.
java.sql.SQLException - Thrown if an SQL exception occurs.
public java.sql.PreparedStatement databaseUpdateStatement(java.sql.Connection connection,
int modelID)
throws java.sql.SQLException
databaseUpdateStatement in interface ModelObjectconnection - Database connection.modelID - Model ID.
java.sql.SQLException - Thrown if an SQL exception occurs.
public org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document,
org.w3c.dom.Element documentRootNode)
throws InvalidObjectException
toXMLNode in interface ModelObjectdocument - XML document.documentRootNode - Document root node.
InvalidObjectException - Thrown if this object's ID is equal to the default ID of -1.
public ModelObject fromXMLNode(org.w3c.dom.Document document,
org.w3c.dom.Node documentRootNode,
org.w3c.dom.Node node,
Model model)
throws InvalidObjectException
fromXMLNode in interface ModelObjectdocument - XML document.documentRootNode - Document root node; ie Model node.node - XML node.model - The modelt to which the returned object is associated.
InvalidObjectException - Thrown if an error occurred building the object.
public ModelObject fromDatabase(java.sql.Connection connection,
Model model,
int modelID,
int objectID)
throws java.sql.SQLException
fromDatabase in interface ModelObjectconnection - Database connection.modelID - Model ID.objectID - Object ID in associated ModelObjects table.model - Model built from database.
java.sql.SQLException - Thrown if an SQL exception occurs.public void transform(Matrix4x4 matrix)
matrix - Transformation matrix.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||