Class AbstractDrawable3DObject

  • Direct Known Subclasses:
    ConvexObject

    public abstract class AbstractDrawable3DObject
    extends java.lang.Object
    Author:
    Calixte DENIZET
    • Field Detail

      • vertices

        protected final Vector3d[] vertices
      • colors

        protected final java.awt.Color[] colors
      • precedence

        protected int precedence
      • is2d

        protected java.lang.Boolean is2d
      • zindex

        protected java.lang.Double zindex
      • nv0v1

        protected double nv0v1
      • marked

        protected boolean marked
      • marked2

        protected boolean marked2
      • degenerated

        protected java.lang.Boolean degenerated
    • Method Detail

      • isMonochromatic

        public static boolean isMonochromatic​(java.awt.Color[] colors)
        Test if an array of colors contains only one color or not
        Parameters:
        colors - the colors array
        Returns:
        true if the array is monochromatic
      • draw

        public abstract void draw​(java.awt.Graphics2D g2d)
        Draw this object on a Graphics2D object
        Parameters:
        g2d - the Graphics2d object where to draw
      • resetDefaultPrecedence

        public static void resetDefaultPrecedence()
        Reset the default precedence
      • setPrecedence

        public void setPrecedence​(int precedence)
        Set the precedence of this object.
        Parameters:
        precedence - the precedence of this object
      • getPrecedence

        public int getPrecedence()
        Get the precedence of this object, i.e. its position in the list of the draw objects. The first object has a precedence of 0, the second has a precedence of 1, ...
        Parameters:
        the - precedence
      • is2D

        public boolean is2D()
        Determinates if this object is 2D in looking at the z coordinates (when all the drawn objects are 2D, we can avoid the projection)
      • getProvidedNormal

        public Vector3d getProvidedNormal()
        Get the normal vector. If no normal vector has been set then it is calculated in using the cross product of the first two vectors.
        Returns:
        the normal vector.
      • getNormal

        public Vector3d getNormal()
        Get the normal vector. If no normal vector has been set then it is calculated in using the cross product of the first two vectors.
        Returns:
        the normal vector.
      • setNormal

        protected void setNormal()
        Set the normal vector
      • isPlanar

        protected boolean isPlanar()
        Determinates if the object is contained into a plane
        Returns:
        true if the object is planar
      • isBehind

        public int isBehind​(Vector3d v,
                            double a)
      • isBehind

        public static boolean isBehind​(Vector3d M,
                                       Vector3d v,
                                       double a)
      • getProjectedPolyLine

        protected java.awt.geom.Path2D getProjectedPolyLine()
        Get the projected polyline of this object
        Returns:
        a path 2D
      • getProjectedContour

        protected java.awt.geom.Path2D getProjectedContour()
        Get the projected contour (i.e. a closed polyline) of this object
        Returns:
        a path 2D
      • isNull

        protected static final boolean isNull​(double d)
        Parameters:
        d - a number
        Returns:
        true if d is near zero
      • isPositiveOrNull

        protected static final boolean isPositiveOrNull​(double d)
        Parameters:
        d - a number
        Returns:
        true if d is greater than zero
      • isNegativeOrNull

        protected static final boolean isNegativeOrNull​(double d)
        Parameters:
        d - a number
        Returns:
        true if d is greater than zero
      • isGreaterOrEqual

        protected static final boolean isGreaterOrEqual​(double d1,
                                                        double d2)
        Parameters:
        d1 - a number
        d2 - a number
        Returns:
        true if d1 is greater than d2
      • isLowerOrEqual

        protected static final boolean isLowerOrEqual​(double d1,
                                                      double d2)
        Parameters:
        d1 - a number
        d2 - a number
        Returns:
        true if d1 is lower than d2
      • isEqual

        protected static final boolean isEqual​(double d1,
                                               double d2)
        Parameters:
        d1 - a number
        d2 - a number
        Returns:
        true if d1 is equal to d2
      • minmax3D

        protected static final double[] minmax3D​(AbstractDrawable3DObject o,
                                                 Vector3d v)
        Get min-max of the projections of the vertices of o on v
        Parameters:
        o - an object
        v - a vector
        Returns:
        an array of size 2 containing min-max.
      • minmax2D

        protected static final double[] minmax2D​(AbstractDrawable3DObject o,
                                                 double x,
                                                 double y)
        Get min-max of the projections of the vertices of o on v
        Parameters:
        o - an object
        v - a vector
        Returns:
        an array of size 2 containing min-max.
      • getColorsBarycenter

        protected static final java.awt.Color getColorsBarycenter​(java.awt.Color c1,
                                                                  java.awt.Color c2,
                                                                  double w1,
                                                                  double w2)
      • isDegenerate

        protected boolean isDegenerate()
        Returns:
        true if there are two vertices which are indentical
      • isNanOrInf

        protected boolean isNanOrInf()
      • isNanOrInf

        public static final boolean isNanOrInf​(Vector3d v)