Class Segment2D

All Implemented Interfaces:
Cloneable

public class Segment2D extends UnsafeSegment2D

2D segment

This class is immutable and thread-safe: there are no ways to modify settings of the created instance.

Author:
Daniel Alievsky
  • Method Details

    • getInstance

      public static Segment2D getInstance()
      Creates some "default" segment. The parameters of this segment (center, orientation, length) are not specified. So, you must set all segment parameters after creating such instance.
    • getInstance

      public static Segment2D getInstance(UnsafeSegment2D instance)
      Creates new segment, identical to instance.
    • getInstance

      public static Segment2D getInstance(double centerX, double centerY, double length, double fi)
      Creates new segment; slowly, because requires sine and cosine calculation.
    • getInstance

      public static Segment2D getInstance(double centerX, double centerY, double length, Direction2D normal)
      Creates new segment.
    • setFi

      public void setFi(double fi, double nx, double ny)
      Equivalent to setFi(fi) (nx and ny are ignored, unlike an implementation in UnsafeSegment2D). This method works slowly, because requires sine and cosine calculation.
      Overrides:
      setFi in class UnsafeSegment2D
    • setAll

      public void setAll(double centerX, double centerY, double length, double fi, double nx, double ny)
      Equivalent to setAll(centerX, centerY, length, fi) (nx and ny are ignored, unlike an implementation in UnsafeSegment2D). This method works slowly, because requires sine and cosine calculation.
      Overrides:
      setAll in class UnsafeSegment2D
    • getNormalClone

      public Direction2D getNormalClone()
      Description copied from class: UnsafeSegment2D
      Returns the normal unit vector, with creating a clone.
      Overrides:
      getNormalClone in class UnsafeSegment2D
    • copyNormalTo

      public void copyNormalTo(Direction2D normal)
      Description copied from class: UnsafeSegment2D
      Copies the normal vector to this segment to the given argument (normal.getAngle() will be equal to this.getFi() + π / 2).
      Overrides:
      copyNormalTo in class UnsafeSegment2D
    • copyFrom

      public void copyFrom(UnsafeSegment2D other)
      Description copied from class: UnsafeSegment2D
      Sets the current segment identical to other.
      Overrides:
      copyFrom in class UnsafeSegment2D
    • checkInvariants

      public void checkInvariants()
      Should does nothing (unlike an implementation in UnsafeSegment2D). However, it will generate InternalError if there are some bugs in this package.
      Overrides:
      checkInvariants in class UnsafeSegment2D