Class RMLine

java.lang.Object
com.inductiveautomation.rm.graphics.RMLine
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
RMQuadratic

public class RMLine extends Object implements Cloneable
This class models a simple line, providing methods for extracting points, distance calculation, bisection, hit detection and such.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new line.
    RMLine(double x1, double y1, double x2, double y2)
    Creates a new line for the given x & y start/end points.
    RMLine(RMPoint startPoint, RMPoint endPoint)
    Creates a new line for the given start point and end point.
  • Method Summary

    Modifier and Type
    Method
    Description
    Standard clone implementation.
    double
    getAngle(double t)
    Returns the angle at given parametric point (in degrees).
    float
    Returns the total arc length of the segment
    float
    getArcLength(float t)
    Returns the arc length of the segment up to parametric value t
    float
    getArcLength(float start, float end)
    Returns the arc length of the segment in range [start..end]
    final RMRect
    Returns the bounds of the line.
    void
    Get bounds of line in given rect.
    double
    Returns the minimum distance from the given point to this segment.
    double
    Returns the minimum distance from the given point to this line.
    double
    getDistanceLineSquared(double anX, double aY)
    Returns the minimum distance from the given point to this line, squared.
    static double
    getDistanceLineSquared(double p0x, double p0y, double p1x, double p1y, double p2x, double p2y)
    Returns the distance from the given point components (p0) to the given line components (p1->p2).
    getHead(double t)
    Returns a new line from this line's start point to given parametric location t (defined from 0-1) on this line.
    Returns a hit info object for this line and the given bezier.
    Returns a hit info object for this line and the given line.
    Returns a hit info object for this line and the given bezier curve.
    double
    Returns the last x.
    double
    Returns the last y.
    double
    Returns the max x point of this line.
    double
    Returns the max y point of this line.
    double
    Returns the min x point of this line.
    double
    Returns the min y point of this line.
    float
    Returns parametric point t that corresponds to a given length along the curve.
    final RMPoint
    getPoint(double t)
    Returns the point on this line at the parametric location t (defined from 0-1).
    getPoint(double t, RMPoint aPoint)
    Returns the point on this line at the parametric location t (defined from 0-1).
    int
    Returns the point count of segment.
    double
    getPointX(int anIndex)
    Returns the x of point at given index.
    double
    getPointY(int anIndex)
    Returns the y of point at given index.
    getTail(double t)
    Returns a new line from given parametric location t (defined from 0-1) on this line to this line's end point.
    double
    getTangent(double t, RMSize tan)
    Return the tangent at given point.
    void
    setEnd(double t)
    Reset this curve's end point to the given parametric location (0-1).
    void
    setStart(double t)
    Reset this curve's start point to the given parametric location (0-1).
    Returns a string representation of this line.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • RMLine

      public RMLine()
      Creates a new line.
    • RMLine

      public RMLine(double x1, double y1, double x2, double y2)
      Creates a new line for the given x & y start/end points.
    • RMLine

      public RMLine(RMPoint startPoint, RMPoint endPoint)
      Creates a new line for the given start point and end point.
  • Method Details

    • getPoint

      public final RMPoint getPoint(double t)
      Returns the point on this line at the parametric location t (defined from 0-1).
    • getPoint

      public RMPoint getPoint(double t, RMPoint aPoint)
      Returns the point on this line at the parametric location t (defined from 0-1).
    • getPointCount

      public int getPointCount()
      Returns the point count of segment.
    • getPointX

      public double getPointX(int anIndex)
      Returns the x of point at given index.
    • getPointY

      public double getPointY(int anIndex)
      Returns the y of point at given index.
    • getLastX

      public double getLastX()
      Returns the last x.
    • getLastY

      public double getLastY()
      Returns the last y.
    • getDistance

      public double getDistance(RMPoint aPoint)
      Returns the minimum distance from the given point to this segment.
    • getDistanceLine

      public double getDistanceLine(RMPoint aPoint)
      Returns the minimum distance from the given point to this line.
    • getDistanceLineSquared

      public double getDistanceLineSquared(double anX, double aY)
      Returns the minimum distance from the given point to this line, squared.
    • getDistanceLineSquared

      public static double getDistanceLineSquared(double p0x, double p0y, double p1x, double p1y, double p2x, double p2y)
      Returns the distance from the given point components (p0) to the given line components (p1->p2).
    • getMinX

      public double getMinX()
      Returns the min x point of this line.
    • getMinY

      public double getMinY()
      Returns the min y point of this line.
    • getMaxX

      public double getMaxX()
      Returns the max x point of this line.
    • getMaxY

      public double getMaxY()
      Returns the max y point of this line.
    • getBounds

      public final RMRect getBounds()
      Returns the bounds of the line.
    • getBounds

      public void getBounds(Rectangle2D aRect)
      Get bounds of line in given rect.
    • getHead

      public RMLine getHead(double t)
      Returns a new line from this line's start point to given parametric location t (defined from 0-1) on this line.
    • getTail

      public RMLine getTail(double t)
      Returns a new line from given parametric location t (defined from 0-1) on this line to this line's end point.
    • setEnd

      public void setEnd(double t)
      Reset this curve's end point to the given parametric location (0-1).
    • setStart

      public void setStart(double t)
      Reset this curve's start point to the given parametric location (0-1).
    • getHitInfo

      public RMHitInfo getHitInfo(RMLine aLine)
      Returns a hit info object for this line and the given line.
    • getHitInfo

      public RMHitInfo getHitInfo(RMQuadratic aCurve)
      Returns a hit info object for this line and the given bezier curve. HitInfo._index is overloaded to contain number of hits.
    • getHitInfo

      public RMHitInfo getHitInfo(RMBezier aBezier)
      Returns a hit info object for this line and the given bezier.
    • toString

      public String toString()
      Returns a string representation of this line.
      Overrides:
      toString in class Object
    • getArcLength

      public float getArcLength()
      Returns the total arc length of the segment
    • getArcLength

      public float getArcLength(float t)
      Returns the arc length of the segment up to parametric value t
    • getArcLength

      public float getArcLength(float start, float end)
      Returns the arc length of the segment in range [start..end]
    • getAngle

      public double getAngle(double t)
      Returns the angle at given parametric point (in degrees).
    • getTangent

      public double getTangent(double t, RMSize tan)
      Return the tangent at given point.
    • getParameterForLength

      public float getParameterForLength(float l)
      Returns parametric point t that corresponds to a given length along the curve. l is in the range [0-1] (ie. percentage of total arclength). For a line, l == t.
    • clone

      public RMLine clone()
      Standard clone implementation.
      Overrides:
      clone in class Object