Package toxi.geom

Class Ray2D

All Implemented Interfaces:
Comparable<ReadonlyVec2D>, ReadonlyVec2D

public class Ray2D extends Vec2D
A simple 2D ray datatype
  • Constructor Details

  • Method Details

    • getDirection

      public Vec2D getDirection()
      Returns a copy of the ray's direction vector.
      Returns:
      vector
    • getDistanceToPoint

      public float getDistanceToPoint(Vec2D p)
      Calculates the distance between the given point and the infinite line coinciding with this ray.
      Parameters:
      p -
      Returns:
      distance
    • getPointAtDistance

      public Vec2D getPointAtDistance(float dist)
    • setDirection

      public Ray2D setDirection(ReadonlyVec2D d)
      Uses a normalized copy of the given vector as the ray direction.
      Parameters:
      d - new direction
      Returns:
      itself
    • setNormalizedDirection

      public Ray2D setNormalizedDirection(ReadonlyVec2D d)
    • toLine2DWithPointAtDistance

      public Line2D toLine2DWithPointAtDistance(float dist)
      Converts the ray into a 2D Line segment with its start point coinciding with the ray origin and its other end point at the given distance along the ray.
      Parameters:
      dist - end point distance
      Returns:
      line segment
    • toString

      public String toString()
      Overrides:
      toString in class Vec2D