Class Segment2D

java.lang.Object
org.episteme.core.mathematics.geometry.Segment2D
All Implemented Interfaces:
GeometricObject<Point2D>

public class Segment2D extends Object implements GeometricObject<Point2D>
Represents a line segment in 2D space.

A 2D segment is defined by two endpoints in 2D Euclidean space.

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • Segment2D

      public Segment2D(Point2D start, Point2D end)
      Creates a 2D segment from two endpoints.
      Parameters:
      start - the start point
      end - the end point
  • Method Details

    • dimension

      public int dimension()
      Description copied from interface: GeometricObject
      Returns the intrinsic dimension of this geometric object.

      Examples:

      • Point: 0
      • Line/Segment: 1
      • Plane/Surface: 2
      • Volume: 3

      Specified by:
      dimension in interface GeometricObject<Point2D>
      Returns:
      the dimension
    • ambientDimension

      public int ambientDimension()
      Description copied from interface: GeometricObject
      Returns the dimension of the ambient space containing this object.

      For example, a 2D plane in 3D space has dimension=2 but ambientDimension=3.

      Specified by:
      ambientDimension in interface GeometricObject<Point2D>
      Returns:
      the ambient space dimension
    • getStart

      public Point2D getStart()
    • getEnd

      public Point2D getEnd()
    • midpoint

      public Point2D midpoint()
      Returns the midpoint of this segment.
      Returns:
      the midpoint
    • length

      public Real length()
      Returns the length of this segment.
      Returns:
      the length
    • at

      public Point2D at(Real t)
      Interpolates along the segment.
      Parameters:
      t - the parameter (0 = start, 1 = end)
      Returns:
      the interpolated point
    • containsPoint

      public boolean containsPoint(Point2D p)
    • toSegmentND

      public SegmentND toSegmentND()
      Converts to SegmentND.
      Returns:
      the N-dimensional representation
    • description

      public String description()
      Description copied from interface: GeometricObject
      Returns a human-readable description of this geometric object.
      Specified by:
      description in interface GeometricObject<Point2D>
      Returns:
      description string
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object