Class SegmentND

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

public class SegmentND extends Object implements GeometricObject<PointND>
Represents an N-dimensional line segment.

A segment is a finite portion of a line, defined by two endpoints. Unlike a line which extends infinitely, a segment has a definite length.

Parametric form: S(t) = start + t*(end - start), where t ∈ [0,1]

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

    • SegmentND

      public SegmentND(PointND start, PointND end)
      Creates a 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<PointND>
      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<PointND>
      Returns:
      the ambient space dimension
    • getStart

      public PointND getStart()
    • getEnd

      public PointND getEnd()
    • midpoint

      public PointND 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 PointND at(Real t)
      Evaluates the segment at parameter t.

      Returns: start + t*(end - start) - t=0 gives start - t=1 gives end - t=0.5 gives midpoint

      Parameters:
      t - the parameter (typically in [0,1])
      Returns:
      the point at parameter t
    • toLine

      public LineND toLine()
      Converts this segment to a line.
      Returns:
      the line containing this segment
    • containsPoint

      public boolean containsPoint(PointND p)
    • closestPoint

      public PointND closestPoint(PointND p)
      Finds the closest point on this segment to a given point.
      Parameters:
      p - the point
      Returns:
      the closest point on the segment
    • distanceTo

      public Real distanceTo(PointND p)
      Computes the distance from a point to this segment.
      Parameters:
      p - the point
      Returns:
      the distance
    • intersects

      public boolean intersects(SegmentND other)
      Checks if this segment intersects another segment.
      Parameters:
      other - the other segment
      Returns:
      true if segments intersect
    • description

      public String description()
      Description copied from interface: GeometricObject
      Returns a human-readable description of this geometric object.
      Specified by:
      description in interface GeometricObject<PointND>
      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