Bitbybit Docs
    Preparing search index...

    Class Point

    Points as plain number arrays. A point is [x, y, z] with Y pointing up, the same shape as a vector, so the two can be passed to each other's methods; a 2D point is [x, y]. Every method returns new points or numbers and never changes its inputs. Angles are in degrees and lengths in model units.

    Index

    Constructors

    clean

    • Removes a point when it repeats the one right before it; the same point further away is kept.

      With checkFirstAndLast on, a last point that repeats the first is dropped too. Points within tolerance of each other count as the same. Example: [[0,0,0], [0,0,0], [1,0,0], [1,0,0], [2,0,0]] -> [[0,0,0], [1,0,0], [2,0,0]]

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      The points without consecutive repeats

      const cleaned = bitbybit.point.removeConsecutiveDuplicates({
      points: [[0, 0, 0], [0, 0, 0], [1, 0, 0]],
      tolerance: 1e-7,
      checkFirstAndLast: false,
      });

    create

    • Builds a 3D point from its x, y and z values.

      Example: x=10, y=5, z=3 -> [10,5,3]

      Parameters

      Returns Bit.Inputs.Base.Point3

      The point [x, y, z]

      const point = bitbybit.point.pointXYZ({ x: 10, y: 5, z: 3 });
      
    • Builds a 2D point from its x and y values.

      Example: x=10, y=5 -> [10,5]

      Parameters

      Returns Bit.Inputs.Base.Point2

      The point [x, y]

      const point = bitbybit.point.pointXY({ x: 10, y: 5 });
      
    • Lays out points along a logarithmic spiral in the XY plane, from the origin outward to radius.

      numberPoints sets how many points are placed, phi and widening how quickly the spiral opens, and factor where along the curve it starts. Every point has z = 0.

      Parameters

      • inputs: SpiralDto

        The point count, the radius and the shape of the spiral

      Returns Bit.Inputs.Base.Point3[]

      The points along the spiral, from the center outward

      const points = bitbybit.point.spiral({ phi: 0.9, numberPoints: 100, widening: 3, radius: 10, factor: 1 });
      
    • Lays out the centers of a honeycomb of hexagons in the XY plane.

      radiusHexagon is the distance from a hexagon's center to a corner; columns run along X and rows along Y, every second row shifted by half a column. orientOnCenter centers the grid on the origin, pointsOnGround lays it on the XZ plane.

      Parameters

      • inputs: HexGridCentersDto

        The hexagon size, how many columns and rows, and where to place the grid

      Returns Bit.Inputs.Base.Point3[]

      The center points, row by row

      const centers = bitbybit.point.hexGrid({ radiusHexagon: 1, nrHexagonsX: 5, nrHexagonsY: 4, orientOnCenter: true, pointsOnGround: false });
      
    • Lays out a honeycomb of hexagons that fills a given width and height, sizing the hexagons from the counts.

      The result carries the center points and the six corners of every hexagon. A corner points up unless flatTop is set; the extend flags stretch the outer rows past the edges to cover the rectangle without a jagged border.

      Parameters

      • inputs: HexGridScaledToFitDto

        The area to fill, the hexagon counts, the orientation and the placement options

      Returns HexGridData

      The centers and the corner points of every hexagon

      const grid = bitbybit.point.hexGridScaledToFit({
      width: 10,
      height: 10,
      nrHexagonsInWidth: 5,
      nrHexagonsInHeight: 5,
      flatTop: false,
      centerGrid: true,
      });
    • Finds the direction at right angles to the plane through three points, with length 1.

      The direction follows the right-hand rule going from the first point to the second to the third; reverseNormal flips it. Points on one line have no plane, so the result is undefined. Example: [0,0,0], [1,0,0], [0,1,0] -> [0,0,1]

      Parameters

      Returns Vector3

      The unit normal, or undefined when the points are on one line

      const normal = bitbybit.point.normalFromThreePoints({
      point1: [0, 0, 0],
      point2: [1, 0, 0],
      point3: [0, 1, 0],
      reverseNormal: false,
      });
    • Lays out points along the circular arc through three points, from the first through the second to the third.

      The arc is divided into segments equal steps between the given ends. Points on one line fix no arc and come back as they are. Example: [1,0,0], [0,1,0] and [-1,0,0] in 2 segments -> [[1,0,0], [0,1,0], [-1,0,0]]

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      The points along the arc, its ends included

      const points = bitbybit.point.arcThroughThreePoints({ start: [5, 0, 0], middle: [0, 5, 0], end: [-5, 0, 0], segments: 16 });
      

    extract

    • Finds the smallest axis-aligned box that holds all the points.

      The result carries the min and max corners, the center, and the width (X), height (Y) and length (Z). Example: points [[0,0,0], [10,5,3]] -> min [0,0,0], max [10,5,3], center [5,2.5,1.5]

      Parameters

      Returns BoundingBox

      The bounding box with its corners, center and sizes

      const box = bitbybit.point.boundingBoxOfPoints({ points: [[0, 0, 0], [10, 5, 3], [-2, 1, 1]] });
      
    • Measures the distance from a point to the nearest point in a list.

      Example: point [0,0,0] and points [[5,0,0], [10,0,0], [3,0,0]] -> 3

      Parameters

      Returns number

      The distance to the nearest point, in model units

      const nearest = bitbybit.point.closestPointFromPointsDistance({ point: [0, 0, 0], points: [[5, 0, 0], [3, 0, 0]] });
      
    • Finds the position of the nearest point in a list, counted from 1.

      Example: point [0,0,0] and points [[5,0,0], [10,0,0], [3,0,0]] -> 3

      Parameters

      Returns number

      The 1-based index of the nearest point

      const index = bitbybit.point.closestPointFromPointsIndex({ point: [0, 0, 0], points: [[5, 0, 0], [3, 0, 0]] });
      
    • Finds the nearest point in a list to a given point.

      Example: point [0,0,0] and points [[5,0,0], [10,0,0], [3,0,0]] -> [3,0,0]

      Parameters

      Returns Bit.Inputs.Base.Point3

      The nearest point

      const nearest = bitbybit.point.closestPointFromPoints({ point: [0, 0, 0], points: [[5, 0, 0], [3, 0, 0]] });
      
    • Finds the average of the points, which is their center of mass when they weigh the same.

      Example: [[0,0,0], [10,0,0], [10,10,0]] -> [6.67,3.33,0]

      Parameters

      Returns Bit.Inputs.Base.Point3

      The average point

      const center = bitbybit.point.averagePoint({ points: [[0, 0, 0], [10, 0, 0], [10, 10, 0]] });
      

    fillet

    • Finds the largest fillet that fits a corner: the arc touches both segments and stays inside them.

      The corner is end; start and center are the far ends of the two segments that meet there. The radius is limited by the shorter segment. A straight or folded-back corner, or a segment shorter than tolerance, gives 0.

      Parameters

      Returns number

      The largest fillet radius, in model units

      const radius = bitbybit.point.maxFilletRadius({ start: [10, 0, 0], center: [0, 10, 0], end: [0, 0, 0], tolerance: 1e-7 });
      
    • Finds the largest fillet at a corner whose arc touches each segment within its nearer half, so neighboring corners of a polyline can each be filleted without the arcs overlapping.

      The corner is end; start and center are the far ends of the two segments. A straight or folded-back corner, or a segment shorter than tolerance, gives 0.

      Parameters

      Returns number

      The largest fillet radius under the half-segment rule, in model units

      const radius = bitbybit.point.maxFilletRadiusHalfLine({ start: [10, 0, 0], center: [0, 10, 0], end: [0, 0, 0], tolerance: 1e-7 });
      
    • Finds the largest fillet for every corner of a polyline, each limited to the nearer half of its segments so the fillets never overlap.

      With checkLastWithFirst on, the polyline is treated as closed and the two corners at the ends are included. Fewer than three points give an empty list.

      Parameters

      Returns number[]

      One radius per corner, in the order of the corners

      const radii = bitbybit.point.maxFilletsHalfLine({
      points: [[0, 0, 0], [10, 0, 0], [10, 10, 0], [0, 10, 0]],
      checkLastWithFirst: true,
      tolerance: 1e-7,
      });
    • Finds one fillet radius that fits every corner of a polyline: the smallest of the per-corner maximums under the half-segment rule.

      With checkLastWithFirst on, the polyline is treated as closed. Fewer than three points, or any corner that allows no fillet, give 0.

      Parameters

      Returns number

      The radius that fits every corner, in model units

      const radius = bitbybit.point.safestPointsMaxFilletHalfLine({
      points: [[0, 0, 0], [10, 0, 0], [10, 10, 0], [0, 10, 0]],
      checkLastWithFirst: true,
      tolerance: 1e-7,
      });

    get

    • Reads the Y value of a point, the one that points up.

      Example: [5,10,3] -> 10

      Parameters

      Returns number

      The Y value

    measure

    • Measures the straight-line distance between two points.

      Example: [0,0,0] to [3,4,0] -> 5

      Parameters

      Returns number

      The distance in model units

      const d = bitbybit.point.distance({ startPoint: [0, 0, 0], endPoint: [3, 4, 0] });
      
    • Measures the distance from one point to each point in a list.

      Example: start [0,0,0] and end points [[3,0,0], [0,4,0], [5,0,0]] -> [3, 4, 5]

      Parameters

      Returns number[]

      One distance per end point, in the same order

      const distances = bitbybit.point.distancesToPoints({ startPoint: [0, 0, 0], endPoints: [[3, 0, 0], [0, 4, 0]] });
      
    • Tells whether two points are closer together than a tolerance.

      Example: [1.0000001, 2, 3] and [1, 2, 3] with tolerance 1e-6 -> true

      Parameters

      Returns boolean

      True when the distance between them is below the tolerance

      const same = bitbybit.point.twoPointsAlmostEqual({ point1: [1, 2, 3], point2: [1, 2, 3.0000001], tolerance: 1e-6 });
      

    sort

    • Sorts points by X, then by Y for equal X, then by Z.

      Example: [[5,0,0], [1,0,0], [3,0,0]] -> [[1,0,0], [3,0,0], [5,0,0]]

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      A sorted copy of the points

      const sorted = bitbybit.point.sortPoints({ points: [[5, 0, 0], [1, 0, 0], [3, 0, 0]] });
      

    transforms

    • Applies a transformation matrix, or a list of them in order, to one point.

      Example: point [0,0,0] with a translation by [5,5,0] -> [5,5,0]

      Parameters

      Returns Bit.Inputs.Base.Point3

      The transformed point

      const moved = bitbybit.point.transformPoint({
      point: [0, 0, 0],
      transformation: bitbybit.transforms.translationXYZ({ translation: [5, 5, 0] }),
      });
    • Applies the same transformation matrix, or list of them in order, to every point.

      Example: five points with a 90 degree rotation -> all five rotated together

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      The transformed points, in the same order

      const rotated = bitbybit.point.transformPoints({
      points: [[1, 0, 0], [2, 0, 0]],
      transformation: bitbybit.transforms.rotationCenterAxis({ center: [0, 0, 0], axis: [0, 1, 0], angle: 90 }),
      });
    • Applies a different transformation to each point: the first transformation to the first point, and so on.

      The two lists must have the same length, or an error is thrown. Example: three points with three translations -> each point moved by its own translation

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      The transformed points, in the same order

      const placed = bitbybit.point.transformsForPoints({
      points: [[0, 0, 0], [1, 0, 0]],
      transformation: bitbybit.transforms.translationsXYZ({ translations: [[0, 1, 0], [0, 2, 0]] }),
      });
    • Moves every point by the same vector.

      Example: points [[0,0,0], [1,0,0]] by [5,5,0] -> [[5,5,0], [6,5,0]]

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      The moved points, in the same order

      const moved = bitbybit.point.translatePoints({ points: [[0, 0, 0], [1, 0, 0]], translation: [5, 5, 0] });
      
    • Moves each point by its own vector: the first point by the first vector, and so on.

      The two lists must have the same length, or an error is thrown. Example: three points with three vectors -> each point moved by its own vector

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      The moved points, in the same order

      const moved = bitbybit.point.translatePointsWithVectors({
      points: [[0, 0, 0], [1, 0, 0]],
      translations: [[0, 1, 0], [0, 2, 0]],
      });
    • Moves every point by the given x, y and z amounts.

      Example: point [0,0,0] with x=10, y=5, z=0 -> [10,5,0]

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      The moved points, in the same order

      const lifted = bitbybit.point.translateXYZPoints({ points: [[0, 0, 0], [1, 0, 0]], x: 0, y: 5, z: 0 });
      
    • Scales points away from or toward a center, with its own factor per axis.

      Example: point [10,0,0] about center [5,0,0] with factors [2,1,1] -> [15,0,0]

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      The scaled points, in the same order

      const stretched = bitbybit.point.scalePointsCenterXYZ({
      points: [[10, 0, 0], [0, 10, 0]],
      center: [0, 0, 0],
      scaleXyz: [2, 1, 1],
      });
    • Stretches points along one direction, measured from a center; distances across that direction stay as they are.

      Example: point [10,0,0] from center [0,0,0] along [1,0,0] with scale 2 -> [20,0,0]

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      The stretched points, in the same order

      const taller = bitbybit.point.stretchPointsDirFromCenter({
      points: [[0, 1, 0], [0, 2, 0]],
      center: [0, 0, 0],
      direction: [0, 1, 0],
      scale: 2,
      });
    • Rotates points around an axis that passes through a center.

      The angle is in degrees and turns counter-clockwise when the axis points toward you. Example: point [10,0,0] around the Y axis through [0,0,0] by 90 -> [0,0,-10]

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      The rotated points, in the same order

      const turned = bitbybit.point.rotatePointsCenterAxis({
      points: [[10, 0, 0]],
      center: [0, 0, 0],
      axis: [0, 1, 0],
      angle: 90,
      });
    • Repeats one point a given number of times in a list.

      Example: point [5,5,0] three times -> [[5,5,0], [5,5,0], [5,5,0]]

      Parameters

      Returns Bit.Inputs.Base.Point3[]

      The list of copies

      const copies = bitbybit.point.multiplyPoint({ point: [5, 5, 0], amountOfPoints: 3 });