Class Line3D

java.lang.Object
edu.cnu.mdi.mdi3D.item3D.Item3D
edu.cnu.mdi.mdi3D.item3D.Line3D
Direct Known Subclasses:
Axis3D

public class Line3D extends Item3D
A single straight line segment between two endpoints in world coordinates. Also caches the segment length and unit direction vector, used by subclasses (e.g. Axis3D) to extend or shorten the drawn line relative to its defining endpoints.
  • Field Details

    • _p0

      protected final float[] _p0
    • _p1

      protected final float[] _p1
    • _unitVector

      protected final double[] _unitVector
    • length

      public final double length
  • Constructor Details

    • Line3D

      public Line3D(Panel3D panel3D, float[] p0, float[] p1, Color color, float lineWidth)
      Create a simple 3D Line item for use on a Panel3D.
      Parameters:
      panel3D - the owner 3D panel
      p0 - one end point as [x, y, z]
      p1 - other end point as [x, y, z]
      color - the color
      lineWidth - the line width
    • Line3D

      public Line3D(Panel3D panel3D, float x1, float y1, float z1, float x2, float y2, float z2, Color color, float lineWidth)
      Create a simple 3D Line item for use on a Panel3D.
      Parameters:
      panel3D - the owner 3D panel
      x1 - x coordinate of one end
      y1 - y coordinate of one end
      z1 - z coordinate of one end
      x2 - x coordinate of other end
      y2 - y coordinate of other end
      z2 - z coordinate of other end
      color - the color
      lineWidth - the line width
    • Line3D

      public Line3D(Panel3D panel3D, float[] coords, Color color, float lineWidth)
      Create a simple 3D Line item for use on a Panel3D.
      Parameters:
      panel3D - the owner 3D panel
      coords - the endpoints as [x1, y1, z1, x2, y2, z2]
      color - the color
      lineWidth - the line width
  • Method Details

    • draw

      public void draw(com.jogamp.opengl.GLAutoDrawable drawable)
      Description copied from class: Item3D
      The custom drawing method
      Specified by:
      draw in class Item3D
      Parameters:
      drawable - the OpenGL drawable
    • getX0

      public float getX0()
      Get the x coordinate of the start
      Returns:
      x coordinate of the start
    • getX1

      public float getX1()
      Get the x coordinate of the end
      Returns:
      x coordinate of the end
    • getY0

      public float getY0()
      Get the y coordinate of the start
      Returns:
      y coordinate of the start
    • getY1

      public float getY1()
      Get the y coordinate of the end
      Returns:
      y coordinate of the end
    • getZ0

      public float getZ0()
      Get the z coordinate of the start
      Returns:
      z coordinate of the start
    • getZ1

      public float getZ1()
      Get the z coordinate of the end
      Returns:
      z coordinate of the end
    • lineItemTest

      public static void lineItemTest(Panel3D p3D, int n)
      Add many lines to see how it handles them
      Parameters:
      p3D - the panel
      n - the number to add
    • extendedPoint

      public void extendedPoint(int whichEnd, float amount, float[] coords)
      Compute a point beyond one endpoint, along the line's direction.
      Parameters:
      whichEnd - which endpoint to extend from: 0 extends past p0 away from p1; any other value extends past p1 away from p0
      amount - distance to extend by, in world units
      coords - destination array, filled with the extended point as [x, y, z]; must have length at least 3
    • getSortPoint

      public float[] getSortPoint()
      Description copied from class: Item3D
      A representative point for transparent sorting, in world coordinates. Default is origin. Override in items with a natural center (Sphere, Cube, Cylinder, etc.).
      Overrides:
      getSortPoint in class Item3D
      Returns:
      the sort point as [x, y, z]