Constructors

Properties

dataGrid: any
debugMode: boolean = false
rawLinearPathSegments: Line[] = []
CLOSE_GAP_TYPE_ABOVE: number = 1
CLOSE_GAP_TYPE_BELOW: number = 2
CLOSE_GAP_TYPE_NONE: number = 0

Methods

  • Checks if both value are on the same side of the critical value (above or below). The closeGapType indictes if CLOSE_GAP_TYPE_BELOW or CLOSE_GAP_TYPE_ABOVE should be used as a rule.

    Parameters

    • valueA: number
    • valueB: number
    • criticalValue: number
    • closeGapType: number

    Returns boolean

  • This procedure will look at the face4 at the ((x,y),(nextX,nextY)) position – which are four values – and determines the local contour lines for these cases.

    This is used to detect and calculate edge cases on the borders of the underliying height data:

    • left and right border (x=0, x=data.xSegmentCount)
    • top and bottom border (x=y, x=data.ySegmentCount)

    Resulting path segments will be stored in the global rawLinearPathSegments array for further processing.

    Parameters

    • x: number
    • y: number
    • nextX: number
    • nextY: number
    • criticalHeightValue: number
    • closeGapType: number

      CLOSE_GAP_TYPE_ABOVE or CLOSE_GAP_TYPE_BELOW.

    Returns void

  • Detect contour paths from the underlying data source.

    Parameters

    • criticalHeightValue: number

      The height value. If above data's maximum or below data's minimum then the result will be empty (no intersections).

    • Optional options: {
          closeGapType: number;
          onRawSegmentsDetected?: ((rawSegmentsDoNotModifiy) => void);
          pathDetectEpsilon?: number;
          pointEliminationEpsilon?: number;
          useTriangles?: boolean;
      }
      • closeGapType: number

        CLOSE_GAP_TYPE_NONE or CLOSE_GAP_TYPE_ABOVE or CLOSE_GAP_TYPE_BELOW.

      • Optional onRawSegmentsDetected?: ((rawSegmentsDoNotModifiy) => void)
          • (rawSegmentsDoNotModifiy): void
          • Parameters

            • rawSegmentsDoNotModifiy: Line[]

            Returns void

      • Optional pathDetectEpsilon?: number

        (optional) The epsilon to tell if two points are located 'in the same place'. Used for connected path detection. If not specified the value 0.0000001 is used.

      • Optional pointEliminationEpsilon?: number

        (optional) The epsilon for duplicate point elimination (default is 0.000001).

      • Optional useTriangles?: boolean

        If set to true the detection will split each face3 quad into two triangle faces.

    Returns GenericPath[]

    • A list of connected paths that resemble the contour lines of the data/terrain at the given height value.
  • This function will calculate a single intersecion line of the given face4 data segment. If the given face does not intersect with the plane at the given heightValue then no segments will be stored.

    Parameters

    • xIndex: number

      The x position (index) of the data face.

    • yIndex: number

      The y position (index) of the data face.

    • heightFace: DataGridFace4<number>

      The data sample that composes the face4 as a two-dimensional number array.

    • heightValue: number

      The height value of the intersection plane to check for.

    • pointEliminationEpsilon: number

    Returns Line

  • This function will calculate a single intersecion line of the given face4 data segment. If the given face does not intersect with the plane at the given heightValue then no segments will be stored.

    Parameters

    • xIndex: number

      The x position (index) of the data face.

    • yIndex: number

      The y position (index) of the data face.

    • heightFace: DataGridFace4<number>

      The data sample that composes the face4 as a two-dimensional number array.

    • criticalHeightValue: number
    • pointEliminationEpsilon: number
    • Optional useTriangles: boolean

    Returns void

  • This function will calculate a single intersecion line of the given face3 data segment. If the given face does not intersect with the plane at the given heightValue then no segments will be stored.

    Parameters

    • xIndexA: number

      The x position (index) of the first triangle data point.

    • yIndexA: number

      The y position (index) of the first triangle data point.

    • xIndexB: number
    • yIndexB: number
    • xIndexC: number
    • yIndexC: number
    • heightFace: DataGridFace3<number>

      The data sample that composes the face4 as a two-dimensional number array.

    • heightValue: number

      The height value of the intersection plane to check for.

    • pointEliminationEpsilon: number

    Returns Line

  • Get a 'lerp' value - which is some sort of percentage/ratio for the curValue inside the range of the given interval [valA ... valB].

    Examples:

    • getLerpRatio(0,100,50) === 0.5
    • getLerpRatio(50,100,75) === 0.5
    • getLerpRatio(0,100,0) === 0.0
    • getLerpRatio(0,100,100) === 1.0
    • getLerpRatio(0,100,-50) === -0.5

    Parameters

    • valA: number
    • valB: number
    • curValue: number

    Returns number

  • Test if a given numeric value (curValue) is between the given values valA and valB. Value A and B don't need to be in ascending order, so valA <= curValue <= valB and valB <= curvalue <= valA will do the job.

    Parameters

    • valA: number

      The first of the two bounds.

    • valB: number

      The second of the two bounds.

    • curValue: number

      The value to check if it is between (or equal) to the given bounds.

    Returns boolean

  • Helper function to lerp a numeric value.

    Parameters

    • min: number

      The min (start) value. Doesn't necesarily need to be the smaller one.

    • max: number

      The max (end) value. Doesn't necesarily need to be the larger one.

    • ratio: number

      The lerp ratio; usually a value between 0.0 and 1.0, but other values a valid for linear interpolation, too.

    Returns number