Class Surface3d

java.lang.Object
org.djutils.draw.surface.Surface3d
All Implemented Interfaces:
Serializable, Drawable<Point3d>, Drawable3d

public class Surface3d extends Object implements Drawable3d
Surface3d.java. Triangulated surface in 3D space.

Copyright (c) 2021-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUTILS License.

Author:
Alexander Verbraeck, Peter Knoppers
See Also:
  • Constructor Details

    • Surface3d

      public Surface3d(Point3d[][] points) throws NullPointerException, DrawRuntimeException
      Construct a new Surface3d.
      Parameters:
      points - Point3d[][]; two dimensional array of points. The first index iterates over the individual triangles; the second index iterates of the points of a single triangle. The range of the second index must be 3.
      Throws:
      NullPointerException - when points is null, or any element in points is null
      DrawRuntimeException - when points is empty, or any element in points does not contain exactly three elements
  • Method Details

    • getPoints

      public Iterator<? extends Point3d> getPoints()
      Retrieve, or generate all points that make up the object.
      Specified by:
      getPoints in interface Drawable<Point3d>
      Returns:
      Iterable<Point2d>; an iterator that generates all points that make up the object
    • size

      public int size()
      Retrieve the number of points that make up the object.
      Specified by:
      size in interface Drawable<Point3d>
      Returns:
      int; the number of points that make up the object
    • getBounds

      public Bounds3d getBounds()
      Retrieve the bounding box of the object.
      Specified by:
      getBounds in interface Drawable3d
      Returns:
      Bounds3d; the bounding box of the object
    • project

      public Drawable2d project() throws DrawRuntimeException
      Project the object onto the z=0 plane.
      Specified by:
      project in interface Drawable3d
      Returns:
      Drawable2d; the projected object
      Throws:
      DrawRuntimeException - when projecting onto the z=0 plane results in an invalid object. E.g. a Line3d that consists of points that all have the exact same x and y coordinates cannot be a line after projecting on the z=0 plane.
    • toString

      public String toString()
      Produce a string describing the Drawable using default conversion for the (double) coordinate values. Regrettably, it is not allowed to provide a default implementation here.
      Specified by:
      toString in interface Drawable<Point3d>
      Overrides:
      toString in class Object
      Returns:
      String; a string describing the Drawable
    • toString

      public String toString(String doubleFormat, boolean doNotIncludeClassName)
      Produce a String describing the Drawable.
      Specified by:
      toString in interface Drawable<Point3d>
      Parameters:
      doubleFormat - String; a format string (something like "%6.3f") which will be used to render every coordinate value)
      doNotIncludeClassName - boolean; if true; the output of toString is not prefixed by the class name. This is useful for concatenating the textual representation of lots of Drawables (e.g. an array, or a List).
      Returns:
      String; textual representation of the Drawable
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object