- All Superinterfaces:
Shape3D
- All Known Implementing Classes:
Surface3D
,Surface3D.Double
,Surface3D.Float
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addAreaToAdder
(Adder adder, SurfaceIterator si) Add the surface area for those segments associated with a surface iterator to an Adder.static void
addVolumeToAdder
(Adder adder, SurfaceIterator si, Point3D refPoint) Add the surface-integral contributions, used in computing a volume for those segments associated with a surface iterator, to an Adder.static Point3D
centerOfMassOf
(Shape3D shape) Compute the center of mass of a shape assuming uniform density.static Point3D
centerOfMassOf
(Shape3D shape, boolean parallel, int size) Compute the center of mass of a shape assuming uniform density, specifying whether to use a sequential or parallel computation.static Point3D
centerOfMassOf
(Shape3D shape, double v) Compute the center of mass of a shape assuming uniform density and given the shape's volume.static Point3D
centerOfMassOf
(Shape3D shape, double v, boolean parallel, int size) Compute the center of mass of a shape assuming uniform density and given the shape's volume, and specifying if the computation should be done in parallel.static Point3D
centerOfMassOf
(Shape3D shape, double v, double limit) Compute the center of mass of a shape assuming uniform density and given the shape's volume and a flatness limit.static Point3D
centerOfMassOf
(Shape3D shape, double v, double limit, boolean parallel, int size) Compute the center of mass of a shape assuming uniform density and given the shape's volume and a flatness limit, and specifying if the computation should be done in parallel.static void
configArea
(int nCT, int nCP) Configure the number of points used in an area computation for Gaussian-Legendre integration.int[]
Get the edge numbers of the surface segments corresponding to each path segment along the boundary.int[]
Get the indices for the segments bordering on this object's boundary.int
getSegment
(int i, double[] coords) Get the control points for the ith segment for this surface.getSegmentColor
(int i) Get the color for the ith segment of this surface.getSegmentTag
(int i) Get the tag for the ith segment of this surface.static double[][]
Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p.static double[][]
Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p, specifying an estimate of the number of segments in a shape and whether or not the moments should be computed in parallel.static double[][]
Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p, specifying the shape's volume.static double[][]
Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p, specifying the shape's volume and whether or not the computation should be performed in parallel.static double[][]
Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p, specifying the shape's volume and a flatness parameter.static double[][]
Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p, specifying the shape's volume, a flatness parameter, and whether or not the computation should be performed in parallel.static double[][]
principalAxes
(double[][] moments) Compute the axes corresponding to the principal moments of a moments matrix.static AffineTransform3D
principalAxesTransform
(double[][] principalAxes, Point3D rotCenter, boolean toOrigin) Get an affine transform to rotate an object so that its 0th principal axis lies along the X axis, its 1st principal axis lies along the Y axis, and its 2nd principal axis lies along the Z axis.static double[]
principalMoments
(double[][] moments) Find the principal moments of a shape given its moments.static void
segmentValue
(double[] results, int type, double[] coords, double u, double v) Get coordinates for a specific point on a segment of a surface.static void
segmentValue
(double[] results, int type, double[] coords, double u, double v, double w) Get the coordinates corresponding to a point at a specific location on a segment of a surface, using barycentric coordinates.static Point3D
segmentValue
(int type, double[] coords, double u, double v) Get a point at a specific location on a segment of a surface.static Point3D
segmentValue
(int type, double[] coords, double u, double v, double w) Get a point at a specific location on a segment of a surface, using barycentric coordinates.int
size()
Get the number of segments contained in this surface.static double[][]
toMomentsOfInertia
(double[][] moments) Convert moments to moments of inertia.static void
uTangent
(double[] results, int type, double[] coords, double u, double v) Get components of the "u" tangent vector at a specific point on a segment of a surface.static void
vTangent
(double[] results, int type, double[] coords, double u, double v) Get components of the "v" tangent vector at a specific point on a segment of a surface.Methods inherited from interface org.bzdev.geom.Shape3D
getBoundary, getBoundary, getBounds, getComponent, getSurfaceIterator, getSurfaceIterator, isClosedManifold, isOriented, numberOfComponents
-
Method Details
-
size
int size()Get the number of segments contained in this surface.- Returns:
- the number of segments contained in this surface
-
getSegment
Get the control points for the ith segment for this surface. The control points depend on the segment type. The number entries in the coords array is- 48 when the return value is
SurfaceIterator.CUBIC_PATCH
. - 30 when the return value is
SurfaceIterator.CUBIC_TRIANGLE
. - 12 when the return value is
SurfaceIterator.PLANAR_TRIANGLE
. - 15 when the return value is
SurfaceIterator.CUBIC_VERTEX
.
Valid indices are non-negative integers smaller than the value returned by
size()
.- Parameters:
i
- the indexcoords
- an array to hold the results- Returns:
- the segment type (
SurfaceIterator.CUBIC_PATCH
,SurfaceIterator.CUBIC_TRIANGLE
,SurfaceIterator.PLANAR_TRIANGLE
, orSurfaceIterator.CUBIC_VERTEX
) - Throws:
IllegalArgumentException
- the index i is out of range
- 48 when the return value is
-
getSegmentTag
Get the tag for the ith segment of this surface. Valid indices are non-negative integers smaller than the value returned bysize()
.- Parameters:
i
- the index of the segment- Returns:
- the tag for this segment
- Throws:
IllegalArgumentException
- the index is out of range
-
getSegmentColor
Get the color for the ith segment of this surface.- Parameters:
i
- the index of the segment- Returns:
- the color for this segment; null if none is defined
- Throws:
IllegalArgumentException
- the index is out of range
-
getBoundarySegmentIndices
int[] getBoundarySegmentIndices()Get the indices for the segments bordering on this object's boundary. When using a path iterator for the boundary, counting the lineTo and moveTo operations will generate the index, into the array returned, for the corresponding segment's index.- Returns:
- an array containing the segment indices; null if the surface is not well formed
-
getBoundaryEdgeNumbers
int[] getBoundaryEdgeNumbers()Get the edge numbers of the surface segments corresponding to each path segment along the boundary. When using a path iterator for the boundary, counting the lineTo and moveTo operations will generate the index, into the array returned, for the corresponding segment's edge number.The edge numbers are defined as follows:
- For a planar triangle,
- edge 0 is the edge from vertex 1 to vertex 2
- edge 1 is the edge from vertex 2 to vertex 3
- edge 2 is the edge from vertex 3 to vertex 1
- For a cubic triangle, described in (u,v) coordinates
where the barycentric coordinates are (u, v, w) with
w = 1 - u - v,
- edge 0 is the edge from (0, 0) to (1, 0)
- edge 1 is the edge from (1, 0) to (0, 1)
- edge 2 is the edge from (0, 1) to (0,0)
- For a cubic patch, described in (u,v) coordinates
- edge 0 is the edge from (0, 0) to (1, 0)
- edge 1 is the edge from (1, 0) to (1, 1)
- edge 2 is the edge from (1, 1) to (0, 1)
- edge 3 is the edge from (0, 1) to (0, 0)
- Returns:
- the edge numbers for the surface segments adjacent to the path segments along the boundary; null if the 3D shape is not well formed
- For a planar triangle,
-
centerOfMassOf
Compute the center of mass of a shape assuming uniform density.- Parameters:
shape
- the shape- Returns:
- the center of mass
- Throws:
IllegalArgumentException
-
centerOfMassOf
static Point3D centerOfMassOf(Shape3D shape, boolean parallel, int size) throws IllegalArgumentException Compute the center of mass of a shape assuming uniform density, specifying whether to use a sequential or parallel computation.The size estimate is used to determine how many threads to use when computing the moments in parallel.
- Parameters:
shape
- the shapeparallel
- true if the computation is done in parallel; false if it is done sequentially.size
- an estimate of the number of segments is the shape (ignored if the argument 'parallel' is false)- Returns:
- the center of mass
- Throws:
IllegalArgumentException
-
centerOfMassOf
Compute the center of mass of a shape assuming uniform density and given the shape's volume. The volume is provided as a parameter to speed up the computation for cases where the volume is already available.- Parameters:
shape
- the shapev
- the volume of the shape.- Returns:
- the center of mass
- Throws:
IllegalArgumentException
-
centerOfMassOf
static Point3D centerOfMassOf(Shape3D shape, double v, boolean parallel, int size) throws IllegalArgumentException Compute the center of mass of a shape assuming uniform density and given the shape's volume, and specifying if the computation should be done in parallel. The volume is provided as a parameter to speed up the computation for cases where the volume is already available.The size estimate is used to determine how many threads to use when computing the moments in parallel.
- Parameters:
shape
- the shapev
- the volume of the shape.parallel
- true if the computation is done in parallel; false if it is done sequentially.size
- an estimate of the number of segments is the shape (ignored if the argument 'parallel' is false)- Returns:
- the center of mass
- Throws:
IllegalArgumentException
-
centerOfMassOf
static Point3D centerOfMassOf(Shape3D shape, double v, double limit) throws IllegalArgumentException Compute the center of mass of a shape assuming uniform density and given the shape's volume and a flatness limit. The volume is provided as a parameter to speed up the computation for cases where the volume is already available. Flatness parameters are described in the documentation forSurfaceIntegral(int,RealValuedFunctThreeOps,RealValuedFunctThreeOps,RealValuedFunctThreeOps,double)
, and can be used to decrease running time at the expense of a possible reduction in accuracy.- Parameters:
shape
- the shapev
- the volume of the shape.limit
- the flatness parameter- Returns:
- the center of mass
- Throws:
IllegalArgumentException
-
centerOfMassOf
static Point3D centerOfMassOf(Shape3D shape, double v, double limit, boolean parallel, int size) throws IllegalArgumentException Compute the center of mass of a shape assuming uniform density and given the shape's volume and a flatness limit, and specifying if the computation should be done in parallel. The volume is provided as a parameter to speed up the computation for cases where the volume is already available. Flatness parameters are described in the documentation forSurfaceIntegral(int,RealValuedFunctThreeOps,RealValuedFunctThreeOps,RealValuedFunctThreeOps,double)
, and can be used to decrease running time at the expense of a possible reduction in accuracy.The size estimate is used to determine how many threads to use when computing the moments in parallel.
- Parameters:
shape
- the shapev
- the volume of the shape.limit
- the flatness parameterparallel
- true if the computation is done in parallel; false if it is done sequentially.size
- an estimate of the number of segments is the shape (ignored if the argument 'parallel' is false)- Returns:
- the center of mass
- Throws:
IllegalArgumentException
-
momentsOf
Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p. If p = (px, py, pz), r = (rx, ry, rz), and- x = rx - px
- y = ry - py
- z = rz - pz
- Parameters:
shape
- the shape whose moments are computedp
- the point about which to compute the moments- Returns:
- the moments
- Throws:
IllegalArgumentException
-
momentsOf
static double[][] momentsOf(Shape3D shape, Point3D p, boolean parallel, int size) throws IllegalArgumentException Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p, specifying an estimate of the number of segments in a shape and whether or not the moments should be computed in parallel. If p = (px, py, pz), r = (rx, ry, rz), and- x = rx - px
- y = ry - py
- z = rz - pz
The size estimate is used to determine how many threads to use when computing the moments in parallel.
- Parameters:
shape
- the shape whose moments are computedp
- the point about which to compute the momentsparallel
- true if the moments should be computed in parallel; false otherwisesize
- an estimate of the number of element in the shape (ignored if 'parallel' is false)- Returns:
- the moments
- Throws:
IllegalArgumentException
-
momentsOf
Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p, specifying the shape's volume. If p = (px, py, pz), r = (rx, ry, rz), and- x = rx - px
- y = ry - py
- z = rz - pz
- Parameters:
shape
- the shape whose moments are computedp
- the point about which to compute the momentsv
- the shape's volume- Returns:
- the moments
- Throws:
IllegalArgumentException
-
momentsOf
static double[][] momentsOf(Shape3D shape, Point3D p, double v, boolean parallel, int size) throws IllegalArgumentException Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p, specifying the shape's volume and whether or not the computation should be performed in parallel. If p = (px, py, pz), r = (rx, ry, rz), and- x = rx - px
- y = ry - py
- z = rz - pz
The size estimate is used to determine how many threads to use when computing the moments in parallel.
- Parameters:
shape
- the shape whose moments are computedp
- the point about which to compute the momentsv
- the shape's volumeparallel
- true if the computation is done in parallel; false if it is done sequentially.size
- an estimate of the number of segments is the shape (ignored if the argument 'parallel' is false)- Returns:
- the moments
- Throws:
IllegalArgumentException
-
momentsOf
static double[][] momentsOf(Shape3D shape, Point3D p, double v, double limit) throws IllegalArgumentException Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p, specifying the shape's volume and a flatness parameter. If p = (px, py, pz), r = (rx, ry, rz), and- x = rx - px
- y = ry - py
- z = rz - pz
Flatness parameters are described in the documentation for
SurfaceIntegral(int,RealValuedFunctThreeOps,RealValuedFunctThreeOps,RealValuedFunctThreeOps,double)
, and can be used to decrease running time at the expense of a possible reduction in accuracy.- Parameters:
shape
- the shape whose moments are computedp
- the point about which to compute the momentsv
- the shape's volumelimit
- the flatness parameter- Returns:
- the moments
- Throws:
IllegalArgumentException
-
momentsOf
static double[][] momentsOf(Shape3D shape, Point3D p, double v, double limit, boolean parallel, int size) throws IllegalArgumentException Compute the moments about axes parallel to the X, Y, and Z axis and located at a point p, specifying the shape's volume, a flatness parameter, and whether or not the computation should be performed in parallel. If p = (px, py, pz), r = (rx, ry, rz), and- x = rx - px
- y = ry - py
- z = rz - pz
Flatness parameters are described in the documentation for
SurfaceIntegral(int,RealValuedFunctThreeOps,RealValuedFunctThreeOps,RealValuedFunctThreeOps,double)
, and can be used to decrease running time at the expense of a possible reduction in accuracy.The size estimate is used to determine how many threads to use when computing the moments in parallel.
- Parameters:
shape
- the shape whose moments are computedp
- the point about which to compute the momentsv
- the shape's volumelimit
- the flatness parameterparallel
- true if the computation is done in parallel; false if it is done sequentially.size
- an estimate of the number of segments is the shape (ignored if the argument 'parallel' is false)- Returns:
- the moments
- Throws:
IllegalArgumentException
-
toMomentsOfInertia
static double[][] toMomentsOfInertia(double[][] moments) Convert moments to moments of inertia. For a moments matrix M computed about the center of mass, the returned value is the matrix $$ I = \left(\begin{array}{c,c,c} ((M_{11}+M_{22}) & -M_{01} & -M_{02} \\ -M_{10} & (M_{00} + M_{22}) & -M_{12} \\ -M_{20} & -M_{21} & (M_{00} + M_{11}) \end{array}\right) $$- Parameters:
moments
- a 3x3 matrix containing the moments [the integral of (xi-ci)((xj-cj) where c is the location of the center of mass and x is a point on or inside the surface, divided by the volume]- Returns:
- the moment of inertia matrix for the case where the volume enclosed has a uniform density and unit mass
-
principalMoments
static double[] principalMoments(double[][] moments) Find the principal moments of a shape given its moments. The array returned contains the moments sorted so that the largest moment appears first. The argument array can be computed from a shape by callingmomentsOf(Shape3D,Point3D)
,momentsOf(Shape3D,Point3D,boolean,int)
,momentsOf(Shape3D,Point3D,double)
,momentsOf(Shape3D,Point3D,double,boolean,int)
,momentsOf(Shape3D,Point3D,double,double)
,momentsOf(Shape3D,Point3D,double,double,boolean,int)
. or by callingtoMomentsOfInertia(double[][])
on the matrix returned by one of thesemomentsOf
methods.The principal moments are the eigenvalues of the moments matrix.
- Parameters:
moments
- the shape's moments.- Returns:
- the principal moments
-
principalAxes
static double[][] principalAxes(double[][] moments) Compute the axes corresponding to the principal moments of a moments matrix. The moments matrix can be computed from a shape by calling the the methodsmomentsOf(Shape3D,Point3D)
,momentsOf(Shape3D,Point3D,boolean,int)
,momentsOf(Shape3D,Point3D,double)
,momentsOf(Shape3D,Point3D,double,boolean,int)
,momentsOf(Shape3D,Point3D,double,double)
,momentsOf(Shape3D,Point3D,double,double,boolean,int)
, or by callingtoMomentsOfInertia(double[][])
on the matrix returned by one of thesemomentsOf
methods. The return value for principalAxes is a three dimensional array. If the array returned is stored as pmatrix, then pmatrix[i] is an array containing the principal axes corresponding to the ith principal moment. Each principal axis vector contains its X component followed by its Y component and is normalized so its length is 1.0.The principal axes are actually the eigenvectors of the moments matrix provided as this method's first argument.
- Parameters:
moments
- a 3-by-3 matrix containing the moments- Returns:
- an array of vectors, each providing an axis, with the vectors corresponding to the principal moments
-
principalAxesTransform
static AffineTransform3D principalAxesTransform(double[][] principalAxes, Point3D rotCenter, boolean toOrigin) Get an affine transform to rotate an object so that its 0th principal axis lies along the X axis, its 1st principal axis lies along the Y axis, and its 2nd principal axis lies along the Z axis.As a use case, suppose one has an affine transform at that will shear an object s or reflect it for the case where the principal axes are oriented along the X, Y, and Z directions with the center of mass at (0, 0, 0). Given a moments matrix (e.g., for the moments of inertia) for a shape with an arbitrary orientation, the following code will transform the object without moving its previous center of mass point or rotation it:
Point3D cm = SurfaceOps.centerOfMassOf(s); double[][] moments = SurfaceOps.momentsOf(s, cm) double[][] I = SurfaceOps.toMomentsOfInertia(moments); AffineTransform afI = SurfaceOps.principalAxesTransform(I, cm, true); AffineTransform af = afI.invert().concatenate(at) .concatenate(afI); Surface3D ns = new Surface3D.Double(s, af);
- Parameters:
principalAxes
- the principal axesrotCenter
- the point about which to perform a rotation (e.g., the center of mass)toOrigin
- true if the center of rotation (rotCenter) after the rotation should be translated to (0, 0, 0); false if it should not move.- Returns:
- the affine transform
-
segmentValue
static Point3D segmentValue(int type, double[] coords, double u, double v) throws IllegalArgumentException Get a point at a specific location on a segment of a surface.- Parameters:
type
- the segment type (SurfaceIterator.PLANAR_TRIANGLE
,SurfaceIterator.CUBIC_TRIANGLE
,SurfaceIterator.CUBIC_PATCH
, orSurfaceIterator.CUBIC_VERTEX
))coords
- the control-point array for the segmentu
- the first parameter for the surfacev
- the second parameter for the surface- Returns:
- the point corresponding to coordinates (u,v)
- Throws:
IllegalArgumentException
-
segmentValue
static void segmentValue(double[] results, int type, double[] coords, double u, double v) throws IllegalArgumentException Get coordinates for a specific point on a segment of a surface.- Parameters:
results
- an array to hold the X, Y, and Z coordinates of point corresponding to parameters (u,v)type
- the segment type (SurfaceIterator.PLANAR_TRIANGLE
,SurfaceIterator.CUBIC_TRIANGLE
,SurfaceIterator.CUBIC_PATCH
, orSurfaceIterator.CUBIC_VERTEX
)coords
- the control-point array for the segmentu
- the first parameter for the surfacev
- the second parameter for the surface- Throws:
IllegalArgumentException
-
segmentValue
static Point3D segmentValue(int type, double[] coords, double u, double v, double w) throws IllegalArgumentException Get a point at a specific location on a segment of a surface, using barycentric coordinates.The coordinates must satisfy the constraint u + w + v = 1; To compute a value from the other two, use
- u = 1.0 - (v + w);
- v = 1.0 - (u + w);
- w = 1.0 - (u + v);
- Parameters:
type
- the segment type (SurfaceIterator.CUBIC_TRIANGLE
,SurfaceIterator.PLANAR_TRIANGLE
, orSurfaceIterator.CUBIC_VERTEX
)coords
- the control-point array for the segmentu
- the first parameter for the surface; -1 if the value of u should be computed from the other two parametersv
- the second parameter for the surface; -1 if the value of v should be computed from the other two parametersw
- the third parameter for the surface; -1 if the value of w should be computed from the other two parameters- Returns:
- the point corresponding to coordinates (u,v,w)
- Throws:
IllegalArgumentException
- an argument was out of range, more than one argument was set to -1, or the type was not acceptable
-
segmentValue
static void segmentValue(double[] results, int type, double[] coords, double u, double v, double w) throws IllegalArgumentException Get the coordinates corresponding to a point at a specific location on a segment of a surface, using barycentric coordinates.The coordinates must satisfy the constraint u + w + v = 1; To compute a value from the other two, use
- u = 1.0 - (v + w);
- v = 1.0 - (u + w);
- w = 1.0 - (u + v);
- Parameters:
results
- an array holding the X, Y and Z coordinates of the desired point, listed in that ordertype
- the segment type (SurfaceIterator.CUBIC_TRIANGLE
,SurfaceIterator.PLANAR_TRIANGLE
, orSurfaceIterator.CUBIC_VERTEX
)coords
- the control-point array for the segmentu
- the first parameter for the surface; -1 if the value of u should be computed from the other two parametersv
- the second parameter for the surface; -1 if the value of v should be computed from the other two parametersw
- the third parameter for the surface; -1 if the value of w should be computed from the other two parameters- Throws:
IllegalArgumentException
- an argument was out of range, more than one argument was set to -1, or the type was not acceptable
-
uTangent
static void uTangent(double[] results, int type, double[] coords, double u, double v) Get components of the "u" tangent vector at a specific point on a segment of a surface. The value of the vector is ∂p/∂u where p is a point for parameters (u,v). For cases where barycentric coordinates are used p(u,v,1-(u+v)) is differentiated.- Parameters:
results
- an array to hold the X, Y, and Z components of the tangent vector for the u direction when the parameters are (u,v)type
- the segment type (SurfaceIterator.PLANAR_TRIANGLE
,SurfaceIterator.CUBIC_TRIANGLE
,SurfaceIterator.CUBIC_PATCH
, orSurfaceIterator.CUBIC_VERTEX
)coords
- the control-point array for the segmentu
- the first parameter for the surfacev
- the second parameter for the surface
-
vTangent
static void vTangent(double[] results, int type, double[] coords, double u, double v) Get components of the "v" tangent vector at a specific point on a segment of a surface. The value of the vector is ∂p/∂v where p is a point for parameters (u,v). For cases where barycentric coordinates are used p(u,v,1-(u+v)) is differentiated.- Parameters:
results
- an array to hold the X, Y, and Z components of the tangent vector for the u direction when the parameters are (u,v)type
- the segment type (SurfaceIterator.PLANAR_TRIANGLE
,SurfaceIterator.CUBIC_TRIANGLE
,SurfaceIterator.CUBIC_PATCH
, orSurfaceIterator.CUBIC_VERTEX
)coords
- the control-point array for the segmentu
- the first parameter for the surfacev
- the second parameter for the surface
-
configArea
static void configArea(int nCT, int nCP) Configure the number of points used in an area computation for Gaussian-Legendre integration. The default for both is 8. If values are set to be less than 8, they will be increased to 8, so giving values of 0 will produce the default. Normally the default should be adequate. Setting higher values is useful for testing. One should note that increasing the values improves the accuracy for each segment in the absence of floating-point errors, but increases the number of values summed.- Parameters:
nCT
- the number of points for cubic Bézier trianglesnCP
- the number of points for cubic Bézier patches
-
addAreaToAdder
Add the surface area for those segments associated with a surface iterator to an Adder. The surface iterator will be modified.- Parameters:
adder
- the addersi
- the surface iterator
-
addVolumeToAdder
Add the surface-integral contributions, used in computing a volume for those segments associated with a surface iterator, to an Adder. The surface iterator will be modified. The total added to the adder will be 3 times the contribution of the iterator's patches to the volume of the shape it represents or partially represents.The volume assumes the surface is well formed and is embedded in a Euclidean three-dimensional space. The algorithm first (in effect) translates an arbitrary reference point (rx, ry, rz) to the origin and then computes the integral of the vector (x, y, z) over the translated surface. The divergence of this vector is the constant 3, and Gauss's theorem states that the integral of the divergence of a vector field v over a volume bounded by a surface S is equal to the the surface integral of v over S (the integral over the surface of the dot product of v and the normal to the surface). Since the divergence is 3, this surface integral's value is 3 times the volume. It is the caller's responsibility to divide by this factor of 3 at the appropriate point.
A reasonable choice of the reference point is the center of the surface's bounding box, a heuristic that helps reduce floating-point errors.
- Parameters:
adder
- the addersi
- the surface iteratorrefPoint
- a reference point
-