Class Surface3D.Float

java.lang.Object
org.bzdev.geom.Surface3D
org.bzdev.geom.Surface3D.Float
All Implemented Interfaces:
Shape3D, SurfaceOps
Enclosing class:
Surface3D

public static class Surface3D.Float extends Surface3D
Surface3D class that stores the coordinates of control points as single-precision numbers.
  • Constructor Details

    • Float

      public Float()
      Constructor for an oriented surface. A surface is oriented if it has two sides. By convention, for each of the patches and triangles that constitute a surface, the normal vector points in the direction implied by the right hand rule when traversing a patch's or triangle's vertices. By convention, for closed surfaces the normal vector points towards the outside of the surface.
    • Float

      public Float(boolean oriented)
      Constructor specifying if the surface has an orientation. A surface is oriented if it has two sides. By convention, for each of the patches and triangles that constitute a surface, the normal vector points in the direction implied by the right hand rule when traversing a patch's or triangle's vertices. By convention, for closed surfaces the normal vector points towards the outside of the surface.
      Parameters:
      oriented - true if the surface has an orientation; false if it does not
    • Float

      public Float(int initialCapacity)
      Constructor for an oriented surface giving an estimate of the number of surface segments. A surface is oriented if it has two sides. By convention, for each of the patches and triangles that constitute a surface, the normal vector points in the direction implied by the right hand rule when traversing a patch's or triangle's vertices. By convention, for closed surfaces the normal vector points towards the outside of the surface.
      Parameters:
      initialCapacity - the initial number of surface segments allocated in an expandable table
    • Float

      public Float(int initialCapacity, boolean oriented)
      Constructor giving an estimate of the number of surface segments and specifying if the surface has an orientation. A surface is oriented if it has two sides. By convention, for each of the patches and triangles that constitute a surface, the normal vector points in the direction implied by the right hand rule when traversing a patch's or triangle's vertices. By convention, for closed surfaces the normal vector points towards the outside of the surface.
      Parameters:
      initialCapacity - the initial number of surface segments allocated in an expandable table
      oriented - true if the surface has an orientation; false if it does not
    • Float

      public Float(Shape3D surface)
      Constructor using another surface to determine the initial surface segments and the surface's orientation. A surface is oriented if it has two sides. By convention, for each of the patches and triangles that constitute a surface, the normal vector points in the direction implied by the right hand rule when traversing a patch's or triangle's vertices. By convention, for closed surfaces the normal vector points towards the outside of the surface.
      Parameters:
      surface - the path whose segments will be copied
    • Float

      public Float(Shape3D surface, Transform3D transform)
      Constructor using another surface to determine the surface's orientation and its initial path segments, modified with a 3D transform. A surface is oriented if it has two sides. By convention, for each of the patches and triangles that constitute a surface, the normal vector points in the direction implied by the right hand rule when traversing a patch's or triangle's vertices. By convention, for closed surfaces the normal vector points towards the outside of the surface.
      Parameters:
      surface - the path whose segments will be copied
      transform - the transform to apply to the surface segments
    • Float

      public Float(Shape3D surface1, Shape3D... surfaces)
      Constructor for a surface that initially contains the surface segments from multiple surfaces or shapes. The surface is oriented if all shapes are oriented.
      Parameters:
      surface1 - the first surface
      surfaces - the remaining surfaces
  • Method Details

    • getSegment

      protected final void getSegment(int length, int offset, double[] scoords)
      Description copied from class: Surface3D
      Get a segment's control points. The values for the offset parameter are determined by the method Surface3D.getSegment(int, double[]). As a result, this method should only be used by subclasses.
      Specified by:
      getSegment in class Surface3D
      Parameters:
      length - the number of entries in the coords argument that will be filled, starting at index 0
      offset - an index indicating where the control point data will be found
      scoords - an array to hold the results
    • append

      public final void append(SurfaceIterator si)
      Description copied from class: Surface3D
      Append the surface segments specified by a surface iterator.
      Specified by:
      append in class Surface3D
      Parameters:
      si - the surface iterator
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • createTransformedSurface

      public Surface3D createTransformedSurface(Transform3D transform)
      Description copied from class: Surface3D
      Create a new surface by applying a transform to this surface.
      Specified by:
      createTransformedSurface in class Surface3D
      Parameters:
      transform - the transform
      Returns:
      the new surface
    • getSurfaceIterator

      public final SurfaceIterator getSurfaceIterator(Transform3D tform)
      Description copied from interface: Shape3D
      Get a surface iterator for this Shape3D. The surface iterator will represent the shape as a sequence of Bézier patches and Bézier triangles, with the order of the sequence arbitrary.

      Unless the transform is an affine transform, the transformation is not exact. In this case, the patches and triangles that constitute the surface should be small enough that the transform can be approximated by an affine transform over the region containing the control points.

      Parameters:
      tform - a transform to apply to each control point; null for the identity transform
      Returns:
      a surface iterator
    • getSurfaceIterator

      public final SurfaceIterator getSurfaceIterator(Transform3D tform, int level)
      Description copied from interface: Shape3D
      Get a surface iterator for this Shape3D, subdividing the surface. The surface iterator will represent the shape as a sequence of Bézier patches and Bézier triangles, with the order of the sequence arbitrary.

      Unless the transform is an affine transform, the transformation is not exact. In this case, the patches and triangles that constitute the surface after each is subdivided should be small enough that the transform can be approximated by an affine transform over the region containing the control points.

      Parameters:
      tform - a transform to apply to each control point; null for the identity transform
      level - the number of levels of partitioning (each additional level splits the previous level into quarters)
      Returns:
      a surface iterator
    • addCubicPatch

      public final void addCubicPatch(double[] controlPoints, Color color, Object tag)
      Description copied from class: Surface3D
      Add a cubic Bézier patch to this surface, specifying a color and a tag. The control points Pi,j, with i and j in the range [0,3], determine a cubic Bézier patch. The equation
      
       P = ∑i,j Pi,jBi,3(u)Bj,3(v)
       
      where Bi,3 are Bernstein polynomials of degree 3. The orientation of the patch is determined by the right-hand rule when traversing the edges of the patch so that the (u,v) coordinates lie along a square whose vertices are (0,0), (1,0), (1,1), (0,1), traversed in that order before returning to (0,0). More precisely, at a point (u,v), the direction of the normal to an oriented surface is that of the cross product of a tangent vector at (u, v) in the direction of increasing u with v constant and the tangent vector at (u, v) with constant u.

      The controlPoints array contains 16 control points. The matrix of control points Pij is stored in column-major order with the X, Y, and Z values of a control point listed sequentially. The first 4 control points are also the control points for a cubic Bézier curve that lies along the edge of the patch where v=0; and the last 4 control points are the control points for a Bézier curve that lies along the edge of the patch where v=1. The control points for the Bézier curves along the edges where u=0 and u=1 do not consist of contiguous entries in the controlPoints array.

      Methods to help configure the control patches include

      All control points associated with an edge of a cubic patch may be identical, in which case the length of the edge is zero and the edge is equivalent to a vertex, but it is illegal for two adjacent edges to have zero length. Furthermore, if the end points of an edge are identical, the intermediate control points must be located at the same point as the vertex.
      Specified by:
      addCubicPatch in class Surface3D
      Parameters:
      controlPoints - the control points defining this cubic Bézier patch.
      color - the color of this patch; null if none is specified
      tag - a tag naming this patch; null if there is none
    • addFlippedCubicPatch

      public final void addFlippedCubicPatch(double[] controlPoints, Color color, Object tag)
      Description copied from class: Surface3D
      Add a cubic Bézier patch to this surface, specifying a color and a tag, and reversing the patch's orientation. The control points Pi,j, with i and j in the range [0,3], determine a cubic Bézier patch. The equation
      
       P = ∑i,j Pi,jBi,3(u)Bj,3(v)
       
      where Bi,3 are Bernstein polynomials of degree 3. The orientation of the patch is determined by the right-hand rule when traversing the edges of the patch so that the (u,v) coordinates lie along a square whose vertices are (0,0), (1,0), (1,1), (0,1), traversed in that order before returning to (0,0). More precisely, at a point (u,v), the direction of the normal to an oriented surface is that opposite to the cross product of a tangent vector at (u, v) in the direction of increasing u with v constant and the tangent vector at (u, v) with constant u.

      The controlPoints array contains 16 control points. The matrix of control points Pij is stored in column-major order with the X, Y, and Z values of a control point listed sequentially. The first 4 control points are also the control points for a cubic Bézier curve that lies along the edge of the patch where v=0; and the last 4 control points are the control points for a Bézier curve that lies along the edge of the patch where v=1. The control points for the Bézier curves along the edges where u=0 and u=1 do not consist of contiguous entries in the controlPoints array.

      Methods to help configure the control patches include

      All control points associated with an edge of a cubic patch may be identical, in which case the length of the edge is zero and the edge is equivalent to a vertex, but it is illegal for two adjacent edges to have zero length. Furthermore, if the end points of an edge are identical, the intermediate control points must be located at the same point as the vertex.

      For a flipped and non-flipped patch created using the same arguments, a point on the surface at coordinates (v,u) for the flipped patch is the same as the point at coordinates (u,v) for the non-flipped patch.

      Specified by:
      addFlippedCubicPatch in class Surface3D
      Parameters:
      controlPoints - the control points defining this cubic Bézier patch.
      color - the color for this patch; null if none is specified
      tag - a tag naming this patch; null if there is none
    • addCubicTriangle

      public final void addCubicTriangle(double[] controlPoints)
      Description copied from class: Surface3D
      Add a cubic Bézier triangle to this surface. Cubic Bézier triangles uses barycentric coordinates u, v, and w, where u + v + w = 1 and all three coordinates are in the range [0,1].

      The control points, labeled by their three indices, are located as follows:

      Diagram

      The orientation of the triangle is determined by applying the right-hand rule, starting with the edge (0,0)-->(1,0) and ending with the edge (0,0)-->(0,1), where the ordered pairs represent the coordinates (u,v). More precisely, for an orientated surface at a point (u, v, 1 - u - v), the cross product of a tangent vector in the direction of increasing u with v constant and the tangent vector in the direction of increasing v with u constant points in the direction of a normal to the surface.

      The controlPoints array contains the control points whose indices are 003, 012, 021, 030, 102, 111, 120, 201, 210, 300, listed in that order with the X, Y, and Z values for each control point specified as adjacent array entries, again in that order.

      If an edge of the segment to be added is a straight line, one should use Path3D.setupCubic(Point3D,Point3D) or Path3D.setupCubic(double,double,double,double,double,double) to obtain the control points that lie along that edge (while contiguous in the array returned by the toCubic method, the locations at which these values should be placed in the controlPoints array may not be contiguous).

      For a valid triangle, all vertices must be located at different points.

      Several methods exit to help set up the control points. These include

      Overrides:
      addCubicTriangle in class Surface3D
      Parameters:
      controlPoints - the control points for a Bézier triangle
    • addCubicTriangle

      public final void addCubicTriangle(double[] controlPoints, Color color, Object tag)
      Description copied from class: Surface3D
      Add a cubic Bézier triangle to this surface, specifying a color and a tag. Cubic Bézier triangles uses barycentric coordinates u, v, and w, where u + v + w = 1 and all three coordinates are in the range [0,1].

      The control points, labeled by their three indices, are located as follows:

      Diagram

      The orientation of the triangle is determined by applying the right-hand rule, when traversing the vertices whose (u,v) values are (0,0), (1,0), and (0,1) in that order. More precisely, for an orientated surface at a point (u, v, 1 - u - v), the cross product of a tangent vector in the direction of increasing u with v constant and the tangent vector in the direction of increasing v with u constant points in the direction of a normal to the surface.

      The controlPoints array contains the control points whose indices are 003, 012, 021, 030, 102, 111, 120, 201, 210, 300, listed in that order with the X, Y, and Z values for each control point specified as adjacent array entries, again in that order.

      If an edge of the segment to be added is a straight line, one should use Path3D.setupCubic(Point3D,Point3D) or Path3D.setupCubic(double,double,double,double,double,double) to obtain the control points that lie along that edge (while contiguous in the array returned by the toCubic method, the locations at which these values should be placed in the controlPoints array may not be contiguous).

      Several methods exit to help set up the control points. These include

      Specified by:
      addCubicTriangle in class Surface3D
      Parameters:
      controlPoints - the control points for a Bézier triangle
      color - the color for the triangle; null if none is specified
      tag - a tag naming this triangle
    • addFlippedCubicTriangle

      public final void addFlippedCubicTriangle(double[] controlPoints, Color color, Object tag)
      Description copied from class: Surface3D
      Add a cubic Bézier triangle to this surface, specifying a color and a tag, and reversing the triangle's orientation by exchanging its U and V coordinates, Cubic Bézier triangles uses barycentric coordinates u, v, and w, where u + v + w = 1 and all three coordinates are in the range [0,1].

      Before the orientation is reversed, the control points, labeled by their three indices, are located as follows:

      Diagram

      The orientation of the triangle, again before the orientation is reversed, is determined by applying the right-hand rule, when traversing the vertices whose (u,v) values are (0,0), (1,0), and (0,1) in that order. More precisely, for an orientated surface at a point (u, v, 1 - u - v), the cross product of a tangent vector in the direction of increasing u with v constant and the tangent vector in the direction of increasing v with u constant points in the direction opposite to that of a normal to the surface.

      The controlPoints array contains the control points whose indices are 003, 012, 021, 030, 102, 111, 120, 201, 210, 300, listed in that order with the X, Y, and Z values for each control point specified as adjacent array entries, again in that order.

      If an edge of the segment to be added is a straight line, one should use Path3D.setupCubic(Point3D,Point3D) or Path3D.setupCubic(double,double,double,double,double,double) to obtain the control points that lie along that edge (while contiguous in the array returned by the toCubic method, the locations at which these values should be placed in the controlPoints array may not be contiguous).

      Several methods exit to help set up the control points. These include

      For a flipped and non-flipped triangle created using the same arguments, a point on the surface at coordinates (v,u,w) for the flipped triangle is the same as the point at coordinates (u,v,w) for the non-flipped triangle.

      Specified by:
      addFlippedCubicTriangle in class Surface3D
      Parameters:
      controlPoints - the control points for a Bézier triangle
      color - the color for the triangle; null if none is specified
      tag - a tag naming this triangle
    • addPlanarTriangle

      public final void addPlanarTriangle(double[] controlPoints)
      Description copied from class: Surface3D
      Add a planner triangle to the surface, specifying a control-point array. The control points represent three vertices each represented by three array elements for the X, Y, and Z coordinates of the points respectively. The the vertices are numbered so that the right hand rule indicates an outward direction in order to be consistent with the representation used in the org.bzdev.p3d package (which is based on the ordering required in STL files):

      Diagram

      Points on the triangle can be expressed in barycentric coordinates u, v, and w. These have a constraint u + v + w = 1. By convention, we will use u and v and set w = 1 - (u + v). All three coordinates are restricted to the range [0,1]. In barycentric coordinates, a point p will be located at p = wv1 +uv3 + vv2.

      The control-points array stores the vertices in the following order, so as to match the convention for barycentric coordinates used for cubic triangles.

      • controlPoints[0], controlPoints[1], controlPoints[2] - the X, Y and Z coordinates respectively for the first vertex.
      • controlPoints[3], controlPoints[4], controlPoints[5] - the X, Y and Z coordinates respectively for the third vertex.
      • controlPoints[6], controlPoints[7], controlPoints[8] - the X, Y and Z coordinates respectively for the second vertex.

      This order matches the ordering used for a cubic Bezier triangle. As a result, applying the right hand rule using the ordering of the control points (v1 to v3 to v3 yields an orientation opposite to that of the triangle. It is not the same as the ordering used for It is not the same as the ordering used for Surface3D.addPlanarTriangle(double,double,double,double,double,double,double,double,double).

      Overrides:
      addPlanarTriangle in class Surface3D
      Parameters:
      controlPoints - the vertices of the triangle
    • addPlanarTriangle

      public final void addPlanarTriangle(double[] controlPoints, Color color, Object tag)
      Description copied from class: Surface3D
      Add a planner triangle to the surface, specifying a control-point array, a color, and a tag. The control points represent three vertices each represented by three array elements for the X, Y, and Z coordinates of the points respectively. The the vertices are numbered so that the right hand rule indicates an outward direction in order to be consistent with the representation used in the org.bzdev.p3d package (which is based on the ordering required in STL files):

      Diagram

      Points on the triangle can be expressed in barycentric coordinates u, v, and w. These have a constraint u + v + w = 1. By convention, we will use u and v and set w = 1 - (u + v). All three coordinates are restricted to the range [0,1]. In barycentric coordinates, a point p will be located at p = wv1 +uv3 + vv2.

      The control-points array stores the vertices in the following order, so as to match the convention for barycentric coordinates used for cubic triangles.

      • controlPoints[0], controlPoints[1], controlPoints[2] - the X, Y and Z coordinates respectively for the first vertex.
      • controlPoints[3], controlPoints[4], controlPoints[5] - the X, Y and Z coordinates respectively for the third vertex.
      • controlPoints[6], controlPoints[7], controlPoints[8] - the X, Y and Z coordinates respectively for the second vertex.

      This order matches the ordering used for a cubic Bezier triangle. As a result, applying the right hand rule using the ordering of the control points (v1 to v3 to v3 yields an orientation opposite to that of the triangle. It is not the same as the ordering used for Surface3D.addPlanarTriangle(double,double,double,double,double,double,double,double,double,Color,Object).

      Specified by:
      addPlanarTriangle in class Surface3D
      Parameters:
      controlPoints - the vertices of the triangle
      color - the color of this triangle; null if none is specified
      tag - a tag naming this triangle; null if there is none
    • addFlippedPlanarTriangle

      public final void addFlippedPlanarTriangle(double[] controlPoints, Color color, Object tag)
      Description copied from class: Surface3D
      Add a planner triangle to the surface, reversing the triangle's orientation by exchanging the triangle's U and V coordinates, and specifying a control-point array, a color, and a tag. The control points represent three vertices each represented by three array elements for the X, Y, and Z coordinates of the points respectively. The the vertices are numbered so that the right hand rule indicates an outward direction in order to be consistent with the representation used in the org.bzdev.p3d package (which is based on the ordering required in STL files):

      Diagram

      Points on the triangle can be expressed in barycentric coordinates u, v, and w. These have a constraint u + v + w = 1. By convention, we will use u and v and set w = 1 - (u + v). All three coordinates are restricted to the range [0,1]. In barycentric coordinates, a point p will be located at p = wv1 +uv3 + vv2.

      Before the triangle's orientation is reversed, the control-points array stores the vertices in the following order so as to match the convention for barycentric coordinates used for cubic triangles:

      • controlPoints[0], controlPoints[1], controlPoints[2] - the X, Y and Z coordinates respectively for the first vertex.
      • controlPoints[3], controlPoints[4], controlPoints[5] - the X, Y and Z coordinates respectively for the third vertex.
      • controlPoints[6], controlPoints[7], controlPoints[8] - the X, Y and Z coordinates respectively for the second vertex.
      For a flipped triangle, the order of the control points determines the orientation using the right hand rule for traversing v1 to v3 to v2.

      For a flipped and non-flipped triangle created using the same arguments, a point on the surface at coordinates (v,u,w) for the flipped triangle is the same as the point at coordinates (v,u,w) for the non-flipped triangle.

      Specified by:
      addFlippedPlanarTriangle in class Surface3D
      Parameters:
      controlPoints - the vertices of the triangle
      color - the color of this triangle; null if none is specified
      tag - a tag naming this triangle; null if there is none
    • addCubicVertex

      public final void addCubicVertex(double[] controlPoints, Color color, Object tag)
      Description copied from class: Surface3D
      Add a cubic vertex to this surface, specifying a color and tag. A cubic vertex has five control points, P0, P1, P2, P3, and P4. The first four control points are the control points for a cubic Bézier curve and the fifth control point P4 is the control point of a vertex connected points along the Bézier curve by straight lines. The orientation of this surface is that obtained by using the right hand rule when following the Bézier curve from P0 to P3, then proceeding to P4, and finally back to P0. When viewed from the oriented side of the surface, this traversal will go counterclockwise.
      Specified by:
      addCubicVertex in class Surface3D
      Parameters:
      controlPoints - the control points, in order, with each represented by three array elements containing a control point's X coordinate, followed by its Y coordinate, followed by its Z coordinate
      color - the tag of this surface segment
      tag - the tag for this surface segment
    • addFlippedCubicVertex

      public final void addFlippedCubicVertex(double[] controlPoints, Color color, Object tag)
      Description copied from class: Surface3D
      Add a flipped cubic vertex to this surface, specifying a color and tag. A cubic vertex has five control points, P0, P1, P2, P3, and P4. The first four control points are the control points for a cubic Bézier curve and the fifth control point P4 is the control point of a vertex connected points along the Bézier curve by straight lines. The orientation of this surface is that obtained by using the right hand rule when following the Bézier curve from P0 to P3, then proceeding to P4, and finally back to P0. When viewed from the oriented side of the surface, this traversal will go clockwise.
      Specified by:
      addFlippedCubicVertex in class Surface3D
      Parameters:
      controlPoints - the control points, in order, with each represented by three array elements containing a control point's X coordinate, followed by its Y coordinate, followed by its Z coordinate
      color - the color of this surface segment
      tag - the tag for this surface segment
    • transform

      public final void transform(Transform3D tform)
      Description copied from class: Surface3D
      Apply a transform to the surface. The transform will be applied to each segment's control points.
      Specified by:
      transform in class Surface3D
      Parameters:
      tform - the transform
    • reverseOrientation

      public final void reverseOrientation()
      Description copied from class: Surface3D
      Reverse the orientation of this surface. This changes the direction associated with each edge and each segment.
      Specified by:
      reverseOrientation in class Surface3D
    • computeBoundary

      public void computeBoundary(Appendable out, boolean multipleEdges)
      Description copied from class: Surface3D
      Compute the boundary of this surface. This method is public because org.bzdev.p3d.Model3D uses it.

      The second argument, when true, relaxes some tests for error conditions. Normally this argument should be false. A choice is provided because the Model3D class uses a partial surface where planar triangles are not included. This can result in cases where multiple boundary segments of this partial surface share the same starting points in the partial surface, but not the full surface.

      Specified by:
      computeBoundary in class Surface3D
      Parameters:
      out - an Appendable for logging error messages
      multipleEdges - true if multiple edges on the boundary can begin at the same vertex; false (the default) otherwise