com.hedgehog.geo.threed.surfaces
Class QuadraticSurface3D

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.geo.GeometricObject
          extended by com.hedgehog.geo.threed.surfaces.Surface3D
              extended by com.hedgehog.geo.threed.surfaces.QuadraticSurface3D
All Implemented Interfaces:
ModelObject, java.lang.Comparable, java.util.Comparator

public class QuadraticSurface3D
extends Surface3D
implements ModelObject

Title: QuadraticSurface3D - models a 3D quadratic/quadric surface.

Description: Models a 3D quadratic/quadric surface as an QuadraticEquation3D object.

This class supports the method intersection(), which tests for an intersection between a surface and a 3D ray. Thus, if the QuadraticSurface3D object can be formed for a 3D object/surface then a ray-intersection test exists.

For example, Sphere3D supports the method toQuadraticSurface3D() which returns a QuadraticSurface3D.

Copyright: Copyright (c) Hedgehog Software 2007-2009.

Company: Hedgehog Software

Since:
1.0
Version:
1.1
See Also:
QuadraticShape2D, QuadraticEquation3D

Field Summary
protected  QuadraticEquation3D mQuadraticEquation
          The surface quadratic equation.
protected  double mxMax
          Maximum x value.
protected  double mxMin
          Minimum x value.
protected  double myMax
          Maximum y value.
protected  double myMin
          Minimum y value.
protected  double mzMax
          Maximum z value.
protected  double mzMin
          Minimum z value.
 
Fields inherited from class com.hedgehog.geo.threed.surfaces.Surface3D
mBoundingBox
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
QuadraticSurface3D()
          Default constructor.
QuadraticSurface3D(QuadraticEquation3D quadraticEquation)
          Constructor.
QuadraticSurface3D(QuadraticEquation3D quadraticEquation, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
          Constructor.
QuadraticSurface3D(QuadraticSurface3D object)
          Copy constructor.
 
Method Summary
 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.
 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.
 QuadraticEquation3D getQuadraticEquation3D()
          Returns the underlying quadratic equation.
 double getXMax()
          Returns the maximum x value.
 double getXMin()
          Returns the minimum x value.
 double getYMax()
          Returns the maximum y value.
 double getYMin()
          Returns the minimum y value.
 double getZMax()
          Returns the maximum z value.
 double getZMin()
          Returns the minimum z value.
 Intersection3D intersection(Ray3D ray, double tolerance)
          Tests for intersection between this surface and the specified ray.
 Intersection3D intersection(StraightLine3D line, double tolerance)
          Returns the intersection object between this general surface and a straight line segment.
 Vector3D normal(Point3D p, boolean normalised)
          Returns the normal at the specified point.
 Point3D pointOnSurface(double u, double v, double tolerance)
          Returns null since a QuadraticSurface3D object is represented implicitly via a QuadraticEquation3D object, which requires x, y and z coordinates to evaluate.
 boolean pointOnSurface(Point3D p, double tolerance)
          Tests whether or not the specified point is on the surface of this shape.
 void setQuadraticEquation3D(QuadraticEquation3D quadraticEquation)
          Sets the underlying quadratic equation.
 void setXMax(double xmax)
          Sets the maximum x value.
 void setXMin(double xmin)
          Sets the minimum x value.
 void setYMax(double ymax)
          Sets the maximum y value.
 void setYMin(double ymin)
          Sets the minimum y value.
 void setZMax(double zmax)
          Sets the maximum z value.
 void setZMin(double zmin)
          Sets the minimum z value.
 java.lang.String toString()
          Returns a String representation of a QuadraticSurface3D 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.
 
Methods inherited from class com.hedgehog.geo.threed.surfaces.Surface3D
area, areaOfPatch, cornerPoint00, cornerPoint01, cornerPoint10, cornerPoint11, curvatureU, curvatureV, elementalArea, feature, featureFromGaussMeanCurvature, gaussCurvature, gaussMeanCurvatures, getBoundingBox, is2D, is3D, isCornerPoint, isCurve, isGrid, isMesh, isPoint, isPointSet, isShape, isSurface, magnitudesFirstOrder, magnitudesSecondOrder, meanCurvature, minmaxScalarProperty, minmaxVectorProperty, normal, parametricCheck, pointNet, principalCurvatures, radiusCurvatureU, radiusCurvatureV, secondDerivativeU, secondDerivativeUV, secondDerivativeV, setBoundingBox, tangentVectorU, tangentVectorV, twistVector
 
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

mQuadraticEquation

protected QuadraticEquation3D mQuadraticEquation
The surface quadratic equation.


mxMin

protected double mxMin
Minimum x value.


mxMax

protected double mxMax
Maximum x value.


myMin

protected double myMin
Minimum y value.


myMax

protected double myMax
Maximum y value.


mzMin

protected double mzMin
Minimum z value.


mzMax

protected double mzMax
Maximum z value.

Constructor Detail

QuadraticSurface3D

public QuadraticSurface3D()
Default constructor. Sets (xmin,xmax), (ymin,ymax) and (zmin,zmax) to (0,10). Calls Shape3D(). Creates a new non-null default QuadraticEquation3D object.


QuadraticSurface3D

public QuadraticSurface3D(QuadraticEquation3D quadraticEquation)
Constructor.

Parameters:
quadraticEquation - The underlying quadratic equation.

QuadraticSurface3D

public QuadraticSurface3D(QuadraticEquation3D quadraticEquation,
                          double xmin,
                          double xmax,
                          double ymin,
                          double ymax,
                          double zmin,
                          double zmax)
Constructor.

Parameters:
quadraticEquation - The underlying quadratic equation.
xmin - Minimum x value.
xmax - Maximum x value.
ymin - Minimum y value.
ymax - Maximum y value.
zmin - Minimum z value.
zmax - Maximum z value.

QuadraticSurface3D

public QuadraticSurface3D(QuadraticSurface3D object)
Copy constructor.

Parameters:
object - Object to copy.
Method Detail

getQuadraticEquation3D

public QuadraticEquation3D getQuadraticEquation3D()
Returns the underlying quadratic equation.

Returns:
The underlying quadratic equation.

setQuadraticEquation3D

public void setQuadraticEquation3D(QuadraticEquation3D quadraticEquation)
Sets the underlying quadratic equation.

Parameters:
quadraticEquation - New QuadraticEquation3D object.

getXMin

public double getXMin()
Returns the minimum x value.

Returns:
Minimum x value.

getXMax

public double getXMax()
Returns the maximum x value.

Returns:
Maximum x value.

getYMin

public double getYMin()
Returns the minimum y value.

Returns:
Minimum y value.

getYMax

public double getYMax()
Returns the maximum y value.

Returns:
Maximum y value.

getZMin

public double getZMin()
Returns the minimum z value.

Returns:
Minimum z value.

getZMax

public double getZMax()
Returns the maximum z value.

Returns:
Maximum z value.

setXMin

public void setXMin(double xmin)
Sets the minimum x value.

Parameters:
xmin - New minimum x value.

setXMax

public void setXMax(double xmax)
Sets the maximum x value.

Parameters:
xmax - New maximum x value.

setYMin

public void setYMin(double ymin)
Sets the minimum y value.

Parameters:
ymin - New minimum y value.

setYMax

public void setYMax(double ymax)
Sets the maximum y value.

Parameters:
ymax - New maximum y value.

setZMin

public void setZMin(double zmin)
Sets the minimum z value.

Parameters:
zmin - New minimum z value.

setZMax

public void setZMax(double zmax)
Sets the maximum z value.

Parameters:
zmax - New maximum z value.

intersection

public Intersection3D intersection(Ray3D ray,
                                   double tolerance)
Tests for intersection between this surface and the specified ray.

Parameters:
ray - Ray.
tolerance - Required tolerance.
Returns:
Intersection object. Set to NONE if no intersection points, POINT if a single Point3D tangential intersection and POINTS if 2 Point3D intersections.

intersection

public Intersection3D intersection(StraightLine3D line,
                                   double tolerance)
Returns the intersection object between this general surface and a straight line segment. Simply passes the intersection test to intersection(Ray3D) and tests each surface-ray intersection point to see if it lies on the specified line.

Parameters:
line - The straight line to test for intersection with this torus.
tolerance - Required tolerance.
Returns:
Intersection object. The object can consist of no intersection points (NONE), 1 Point3D tangential intersection point (POINT) or up to 4 Point3D intersection points (POINTS).

pointOnSurface

public boolean pointOnSurface(Point3D p,
                              double tolerance)
Tests whether or not the specified point is on the surface of this shape.

Parameters:
p - Point to test.
tolerance - Required tolerance.
Returns:
Logical-true if p is on the surface of this shape, else logical-false.

normal

public Vector3D normal(Point3D p,
                       boolean normalised)
Returns the normal at the specified point.

Parameters:
p - Point at which surface normal is required.
normalised - Specifies whether or not the returned vector is normalised or not.
Returns:
Normal vector at the specified point.

toString

public java.lang.String toString()
Returns a String representation of a QuadraticSurface3D object.

Overrides:
toString in class java.lang.Object
Returns:
A String representation of a QuadraticSurface3D object.

pointOnSurface

public Point3D pointOnSurface(double u,
                              double v,
                              double tolerance)
                       throws java.lang.IllegalArgumentException
Returns null since a QuadraticSurface3D object is represented implicitly via a QuadraticEquation3D object, which requires x, y and z coordinates to evaluate.

Specified by:
pointOnSurface in class Surface3D
Parameters:
u - Parametric u coordinate.
v - Parametric v coordinate.
tolerance - Required tolerance.
Returns:
Point at (u,v) or null if no point exists.
Throws:
java.lang.IllegalArgumentException - Thrown if (u,v) are out of range [0:1].

childModelObjects

public java.util.Vector<ModelObject> childModelObjects()
Returns a vector of this object's child ModelObject objects.

Specified by:
childModelObjects in interface ModelObject
Returns:
An empty vector.

databaseInsertStatement

public java.sql.PreparedStatement databaseInsertStatement(java.sql.Connection connection,
                                                          int modelID)
                                                   throws java.sql.SQLException
Returns a prepared statement for inserting (INSERT command) a ModelObject object into a database.

Specified by:
databaseInsertStatement in interface ModelObject
Parameters:
connection - Database connection.
modelID - Model ID.
Returns:
A prepared statement for inserting a ModelObject object into a database.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

databaseUpdateStatement

public java.sql.PreparedStatement databaseUpdateStatement(java.sql.Connection connection,
                                                          int modelID)
                                                   throws java.sql.SQLException
Returns a prepared statement for updating (UPDATE command) a ModelObject object into a database.

Specified by:
databaseUpdateStatement in interface ModelObject
Parameters:
connection - Database connection.
modelID - Model ID.
Returns:
A prepared statement for inserting a ModelObject object into a database.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

toXMLNode

public org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document,
                                     org.w3c.dom.Element documentRootNode)
                              throws InvalidObjectException
Returns the xml node of this object.

Specified by:
toXMLNode in interface ModelObject
Parameters:
document - XML document.
documentRootNode - Document root node.
Returns:
The xml node of this object.
Throws:
InvalidObjectException - Thrown if this object's ID is equal to the default ID of -1.

fromXMLNode

public ModelObject fromXMLNode(org.w3c.dom.Document document,
                               org.w3c.dom.Node documentRootNode,
                               org.w3c.dom.Node node,
                               Model model)
                        throws InvalidObjectException
Returns a model object from the specified xml node.

Specified by:
fromXMLNode in interface ModelObject
Parameters:
document - XML document.
documentRootNode - Document root node; ie Model node.
node - XML node.
model - The model to which the returned object is associated with.
Returns:
ModelObject corresponding to the specified node. A null value is returned if an error occurred building the object.
Throws:
InvalidObjectException - Thrown if an error occurred building the object.

fromDatabase

public ModelObject fromDatabase(java.sql.Connection connection,
                                Model model,
                                int modelID,
                                int objectID)
                         throws java.sql.SQLException
Returns a model object from the specified database table.

Specified by:
fromDatabase in interface ModelObject
Parameters:
connection - Database connection.
modelID - Model ID.
objectID - Object ID in associated ModelObjects table.
model - Model built from database.
Returns:
ModelObject corresponding to the specified db connection, model ID and obect ID. A null value is returned if no match found.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

toX3DNode

public X3DNode toX3DNode(X3DObject x3dObject)
                  throws InvalidObjectException
X3D support. Returns null as not possible to build an X3D node as QuadraticSurface3D objects are internally represented by an implicit equation.

Specified by:
toX3DNode in interface ModelObject
Parameters:
x3dObject - X3D object.
Returns:
X3D object or null if object has no visualisation.
Throws:
InvalidObjectException - Thrown if this object is invalid.