Package com.jme3.math

Class Line

java.lang.Object
com.jme3.math.Line
All Implemented Interfaces:
Savable, Serializable, Cloneable

public class Line extends Object implements Savable, Cloneable, Serializable
Line defines a line. Where a line is defined as infinite along two points. The two points of the line are defined as the origin and direction.
See Also:
  • Constructor Details

    • Line

      public Line()
      Constructor instantiates a new Line object. The origin and direction both default to (0,0,0).
    • Line

      public Line(Vector3f origin, Vector3f direction)
      Constructor instantiates a new Line object. The origin and direction are set via the parameters.
      Parameters:
      origin - the origin of the line.
      direction - the direction of the line.
  • Method Details

    • getOrigin

      public Vector3f getOrigin()
      getOrigin returns the origin of the line.
      Returns:
      the origin of the line.
    • setOrigin

      public void setOrigin(Vector3f origin)
      setOrigin sets the origin of the line.
      Parameters:
      origin - the origin of the line.
    • getDirection

      public Vector3f getDirection()
      getDirection returns the direction of the line.
      Returns:
      the direction of the line.
    • setDirection

      public void setDirection(Vector3f direction)
      setDirection sets the direction of the line.
      Parameters:
      direction - the direction of the line.
    • distanceSquared

      public float distanceSquared(Vector3f point)
      Calculate the squared distance from this line to the specified point.
      Parameters:
      point - location vector of the input point (not null, unaffected)
      Returns:
      the square of the minimum distance (≥0)
    • distance

      public float distance(Vector3f point)
      Calculate the distance from this line to the specified point.
      Parameters:
      point - location vector of the input point (not null, unaffected)
      Returns:
      the minimum distance (≥0)
    • orthogonalLineFit

      public void orthogonalLineFit(FloatBuffer points)
      Fit this line to the specified points.
      Parameters:
      points - a buffer containing location vectors, or null
    • random

      public Vector3f random()
      random determines a random point along the line.
      Returns:
      a random point on the line.
    • random

      public Vector3f random(Vector3f result)
      random determines a random point along the line.
      Parameters:
      result - Vector to store result in
      Returns:
      a random point on the line.
    • write

      public void write(JmeExporter e) throws IOException
      Serialize this line to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface Savable
      Parameters:
      e - (not null)
      Throws:
      IOException - from the exporter
    • read

      public void read(JmeImporter importer) throws IOException
      De-serialize this line from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface Savable
      Parameters:
      importer - (not null)
      Throws:
      IOException - from the importer
    • clone

      public Line clone()
      Create a copy of this line.
      Overrides:
      clone in class Object
      Returns:
      a new instance, equivalent to this one