Class Boundary2DScanner.Step

java.lang.Object
net.algart.matrices.scanning.Boundary2DScanner.Step
Enclosing class:
Boundary2DScanner

public static class Boundary2DScanner.Step extends Object

The step of scanning the boundary: moving from one boundary segment to the next boundary segment. See definition of the "boundary" and "boundary segment" terms in comments to Boundary2DScanner class.

In fact, this class is an enumeration: there are only 12 immutable instances of this class (all they are created while initialization). Namely:

So, you can compare instances of this class by == operator, as well as enumeration instances.

You can also identify instances of this class with help of a unique code, returned by code() method.

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

  • Field Details

  • Method Details

    • code

      public int code()
      Returns integer unique code from 0 to 11, identifying this step. Works very quickly (this method just returns an internal field).

      This method returns one of the following constants:

      You can use this value for maximally efficient switching, depending on the step kind, using Java switch operator.

      Returns:
      integer unique code of this step (0..11).
    • pixelCenterDX

      public int pixelCenterDX()
      Returns change of x-coordinate of the pixel center, performed by this step. Can be −1, 0, 1. In other word, returns the increment of the current position along x-axis. Works very quickly (this method just returns an internal field).
      Returns:
      change of x-coordinate of the center of the current pixel.
      See Also:
    • pixelCenterDY

      public int pixelCenterDY()
      Returns change of y-coordinate of the pixel center, performed by this step. Can be −1, 0, 1. In other word, returns the increment of the current position along y-axis. Works very quickly (this method just returns an internal field).
      Returns:
      change of y-coordinate of the center of the current pixel.
      See Also:
    • segmentCenterDX

      public double segmentCenterDX()
      Returns change of x-coordinate of the center of the current boundary segment, performed by this step. Can be 0.0, ±0.5, ±1.0. Works very quickly (this method just returns an internal field).
      Returns:
      change of x-coordinate of the center of the current boundary segment.
      See Also:
    • segmentCenterDY

      public double segmentCenterDY()
      Returns change of y-coordinate of the center of the current boundary segment, performed by this step. Can be 0.0, ±0.5, ±1.0. Works very quickly (this method just returns an internal field).
      Returns:
      change of y-coordinate of the center of the current boundary segment.
      See Also:
    • pixelVertexX

      public double pixelVertexX()
      Returns x-coordinate of the vertex of the new (current) pixel, which is common for the current and previous segments (pixel sides), on the assumption that the center of the new (current) pixel is at the origin of coordinates. Works very quickly (this method just returns an internal field).
      Returns:
      x-coordinate of the vertex of the new (current) pixel, lying between previous and current segments of the boundary.
    • pixelVertexY

      public double pixelVertexY()
      Returns y-coordinate of the vertex of the new (current) pixel, which is common for the current and previous segments (pixel sides), on the assumption that the center of the new (current) pixel is at the origin of coordinates. Works very quickly (this method just returns an internal field).
      Returns:
      y-coordinate of the vertex of the new (current) pixel, lying between previous and current segments of the boundary.
    • increasedPixelVertexX

      public int increasedPixelVertexX()
      Returns pixelVertexX()+0.5. It is always an integer value 0 or 1. Works very quickly (this method just returns an internal field).

      In other words, returns x-coordinate of the vertex of the new (current) pixel, which is common for the current and previous segments (pixel sides), on the assumption that the left up corner of the new (current) pixel is at the origin of coordinates.

      Returns:
      0.5 + x-coordinate of the vertex of the new (current) pixel, lying between previous and current segments of the boundary.
    • increasedPixelVertexY

      public int increasedPixelVertexY()
      Returns pixelVertexY()+0.5. It is always an integer value 0 or 1. Works very quickly (this method just returns an internal field).

      In other words, returns y-coordinate of the vertex of the new (current) pixel, which is common for the current and previous segments (pixel sides), on the assumption that the left up corner of the new (current) pixel is at the origin of coordinates.

      Returns:
      0.5 + y-coordinate of the vertex of the new (current) pixel, lying between previous and current segments of the boundary.
    • isRotation

      public boolean isRotation()
      Returns true if pixelCenterDX()==0 && pixelCenterDY()==0 (rotation kind of movement). Works very quickly (this method just returns an internal field).
      Returns:
      true if pixelCenterDX()==0 && pixelCenterDY()==0.
    • isHorizontal

      public boolean isHorizontal()
      Returns true if pixelCenterDX() is ±1 and pixelCenterDY() is 0. Works very quickly (this method just returns an internal field).
      Returns:
      true if pixelCenterDX()!=0 && pixelCenterDY()==0.
    • isVertical

      public boolean isVertical()
      Returns true if pixelCenterDY() is ±1 and pixelCenterDX() is 0. Works very quickly (this method just returns an internal field).
      Returns:
      true if pixelCenterDX()==0 && pixelCenterDY()!=0.
    • isStraight

      public boolean isStraight()
      Returns true if one of pixelCenterDX() and pixelCenterDY() values is ±1, but another is 0 (straight kind of movement). Works very quickly (this method just returns an internal field).
      Returns:
      true if isHorizontal() || isVertical().
    • isDiagonal

      public boolean isDiagonal()
      Returns true if pixelCenterDX()!=0 && pixelCenterDY()!=0 (diagonal kind of movement). Works very quickly (this method just returns an internal field).
      Returns:
      true if pixelCenterDX()!=0 && pixelCenterDY()!=0.
    • distanceBetweenPixelCenters

      public double distanceBetweenPixelCenters()
      Returns the distance between the centers of the previous and current pixel; equal to StrictMath.hypot(pixelCenterDX(), pixelCenterDY()). In other words, returns 0 if isRotation(), 1 for straight steps and DIAGONAL_LENGTH=√2 for diagonal steps. Works very quickly (this method just returns an internal field).
      Returns:
      the distance between the centers of the previous and current pixe.
    • distanceBetweenSegmentCenters

      public double distanceBetweenSegmentCenters()
      Returns the distance between the centers of the previous and current boundary segments. In other words, returns 1 for straight steps and HALF_DIAGONAL_LENGTH=0.5*√2 for diagonal steps and for movements around the same pixel. Works very quickly (this method just returns an internal field).
      Returns:
      the distance between the centers of the previous and current boundary segments.
    • oldSide

      public Boundary2DScanner.Side oldSide()
      Returns the previous pixel side.
      Returns:
      the previous pixel side.
    • newSide

      public Boundary2DScanner.Side newSide()
      Returns the new (current) pixel side.
      Returns:
      the new (current) pixel side.
    • toString

      public String toString()
      Returns a brief string description of this object.

      The result of this method may depend on implementation.

      Overrides:
      toString in class Object
      Returns:
      a brief string description of this object.