bitbybit.dev v1.0.0-rc.1
    Preparing search index...

    Class GeometryHelper

    Index

    Constructors

    Properties

    getArrayDepth: (value: any) => number

    Calculates the nesting depth of an array recursively. Example: [1,2,3] → 1, [[1,2],[3,4]] → 2, [[[1]]] → 3

    Methods

    • Applies one or more 4×4 transformation matrices to a list of points sequentially. Each transformation is applied in order (composition of transformations). Example: points=[[0,0,0], [1,0,0]] with translation [5,0,0] → [[5,0,0], [6,0,0]]

      Parameters

      • transformation: number[][] | number[][][]
      • transformedControlPoints: Point3[]

      Returns Point3[]

    • Flattens nested transformation arrays into a single-level array of transformation matrices. Handles both 2D arrays (single transform list) and 3D arrays (nested transform lists). Example: [[[matrix1, matrix2]], [[matrix3]]] → [matrix1, matrix2, matrix3]

      Parameters

      • transformation: number[][] | number[][][]

      Returns number[][]

    • Applies a single 4×4 transformation matrix (as flat 16-element array) to multiple points. Example: points=[[0,0,0], [1,0,0]] with translation matrix → transformed points

      Parameters

      • points: Point3[]
      • transform: number[]

      Returns Point3[]

    • Transforms multiple points using a transformation matrix (maps each point through the matrix). Example: points=[[1,0,0], [0,1,0]] with 90° rotation → [[0,1,0], [-1,0,0]]

      Parameters

      • points: Point3[]
      • transform: number[]

      Returns Point3[]

    • Removes all duplicate vectors from a list (works with arbitrary-length numeric vectors). Compares vectors using tolerance for floating-point equality. Example: [[1,2], [3,4], [1,2], [5,6]] with tolerance=1e-7 → [[1,2], [3,4], [5,6]]

      Parameters

      • vectors: number[][]
      • Optionaltolerance: number

      Returns number[][]

    • Removes consecutive duplicate vectors from a list (keeps only first occurrence in each sequence). Optionally checks and removes duplicate if first and last vectors match. Example: [[1,2], [1,2], [3,4], [3,4], [5,6]] → [[1,2], [3,4], [5,6]]

      Parameters

      • vectors: number[][]
      • OptionalcheckFirstAndLast: boolean
      • Optionaltolerance: number

      Returns number[][]

    • Compares two vectors for approximate equality using tolerance (element-wise comparison). Returns false if vectors have different lengths. Example: [1.0000001, 2.0], [1.0, 2.0] with tolerance=1e-6 → true

      Parameters

      • vec1: number[]
      • vec2: number[]
      • tolerance: number

      Returns boolean

    • Checks if two numbers are approximately equal within a tolerance. Example: 1.0000001, 1.0 with tolerance=1e-6 → true, 1.001, 1.0 with tolerance=1e-6 → false

      Parameters

      • num1: number
      • num2: number
      • tolerance: number

      Returns boolean

    • Removes consecutive duplicate points from a list (specialized for 3D/2D points). Optionally checks and removes duplicate if first and last points match (for closed loops). Example: [[0,0,0], [0,0,0], [1,0,0], [1,0,0]] → [[0,0,0], [1,0,0]]

      Parameters

      • points: Point3[]
      • OptionalcheckFirstAndLast: boolean
      • Optionaltolerance: number

      Returns Point3[]

    • Checks if two points are approximately equal using tolerance (supports 2D and 3D points). Example: [1.0000001, 2.0, 3.0], [1.0, 2.0, 3.0] with tolerance=1e-6 → true

      Parameters

      Returns boolean