Bitbybit Docs
    Preparing search index...

    Class Point

    以普通数值数组表示的点。点是 [x, y, z],Y 指向上方,与向量的形式相同,因此两者可以互相传给对方的方法;2D 点是 [x, y]。每个方法都返回新的点或数值,从不更改其输入。角度以度为单位,长度以模型单位表示。

    Index

    Constructors

    clean

    • 当一个点与紧邻其前的点重复时将其移除;距离更远的相同点则保留。

      打开 checkFirstAndLast 时,与第一个重复的最后一个点也会被丢弃。相互之间在 tolerance 以内的点算作相同。 示例:[[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 Point3[]

      去除连续重复后的点

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

    create

    • 由 x、y 和 z 值构建 3D 点。

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

      Parameters

      Returns Point3

      [x, y, z]

      const point = bitbybit.point.pointXYZ({ x: 10, y: 5, z: 3 });
      
    • 由 x 和 y 值构建 2D 点。

      示例:x=10, y=5 -> [10,5]

      Parameters

      Returns Point2

      [x, y]

      const point = bitbybit.point.pointXY({ x: 10, y: 5 });
      
    • 在 XY 平面内沿对数螺线布置点,从原点向外直到 radius

      numberPoints 设置放置多少个点,phiwidening 设置螺线张开的快慢,factor 设置它从曲线上何处开始。每个点的 z = 0。

      Parameters

      • inputs: SpiralDto

        点数、半径和螺线的形状

      Returns Point3[]

      沿螺线的点,从中心向外

      const points = bitbybit.point.spiral({ phi: 0.9, numberPoints: 100, widening: 3, radius: 10, factor: 1 });
      
    • 在 XY 平面内布置蜂窝状六边形的中心点。

      radiusHexagon 是六边形中心到角的距离;列沿 X,行沿 Y,每隔一行偏移半列。orientOnCenter 使网格以原点为中心,pointsOnGround 将其放在 XZ 平面上。

      Parameters

      • inputs: HexGridCentersDto

        六边形大小、列数和行数,以及网格的放置位置

      Returns Point3[]

      中心点,逐行排列

      const centers = bitbybit.point.hexGrid({ radiusHexagon: 1, nrHexagonsX: 5, nrHexagonsY: 4, orientOnCenter: true, pointsOnGround: false });
      
    • 布置一片填满给定宽度和高度的蜂窝状六边形,根据数量确定六边形的大小。

      结果包含每个六边形的中心点和六个角。除非设置 flatTop,否则角朝上;扩展标志将外侧行拉伸到边缘之外,以覆盖矩形而没有锯齿状边框。

      Parameters

      Returns HexGridData

      每个六边形的中心和角点

      const grid = bitbybit.point.hexGridScaledToFit({
      width: 10,
      height: 10,
      nrHexagonsInWidth: 5,
      nrHexagonsInHeight: 5,
      flatTop: false,
      centerGrid: true,
      });
    • 找出与经过三点的平面垂直的方向,长度为 1。

      方向遵循从第一点到第二点再到第三点的右手定则;reverseNormal 将其翻转。共线的点没有平面,因此结果为 undefined。 示例:[0,0,0], [1,0,0], [0,1,0] -> [0,0,1]

      Parameters

      Returns Vector3

      单位法线,当三点共线时为 undefined

      const normal = bitbybit.point.normalFromThreePoints({
      point1: [0, 0, 0],
      point2: [1, 0, 0],
      point3: [0, 1, 0],
      reverseNormal: false,
      });

    extract

    • 找出容纳所有点的最小轴对齐盒。

      结果包含最小和最大角点、中心,以及宽度(X)、高度(Y)和长度(Z)。 示例:点 [[0,0,0], [10,5,3]] -> min [0,0,0],max [10,5,3],center [5,2.5,1.5]

      Parameters

      Returns BoundingBox

      边界框及其角点、中心和尺寸

      const box = bitbybit.point.boundingBoxOfPoints({ points: [[0, 0, 0], [10, 5, 3], [-2, 1, 1]] });
      
    • 测量一个点到列表中最近点的距离。

      示例:点 [0,0,0] 和点 [[5,0,0], [10,0,0], [3,0,0]] -> 3

      Parameters

      Returns number

      到最近点的距离,以模型单位表示

      const nearest = bitbybit.point.closestPointFromPointsDistance({ point: [0, 0, 0], points: [[5, 0, 0], [3, 0, 0]] });
      
    • 找出列表中最近点的位置,从 1 开始计数。

      示例:点 [0,0,0] 和点 [[5,0,0], [10,0,0], [3,0,0]] -> 3

      Parameters

      Returns number

      最近点的索引,从 1 开始

      const index = bitbybit.point.closestPointFromPointsIndex({ point: [0, 0, 0], points: [[5, 0, 0], [3, 0, 0]] });
      
    • 找出列表中离给定点最近的点。

      示例:点 [0,0,0] 和点 [[5,0,0], [10,0,0], [3,0,0]] -> [3,0,0]

      Parameters

      Returns Point3

      最近的点

      const nearest = bitbybit.point.closestPointFromPoints({ point: [0, 0, 0], points: [[5, 0, 0], [3, 0, 0]] });
      
    • 求这些点的平均值,当它们重量相同时这就是它们的质心。

      示例:[[0,0,0], [10,0,0], [10,10,0]] -> [6.67,3.33,0]

      Parameters

      Returns Point3

      平均点

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

    fillet

    • 找出适合某个角的最大圆角:圆弧与两条线段都相切并保持在它们之内。

      角是 endstartcenter 是在此相交的两条线段的远端。半径受较短线段限制。平直或折回的角,或短于 tolerance 的线段,给出 0。

      Parameters

      Returns number

      最大圆角半径,以模型单位表示

      const radius = bitbybit.point.maxFilletRadius({ start: [10, 0, 0], center: [0, 10, 0], end: [0, 0, 0], tolerance: 1e-7 });
      
    • 找出某个角的最大圆角,其圆弧在每条线段较近的一半内与之相切,使折线的相邻各角都能倒圆角而圆弧不重叠。

      角是 endstartcenter 是两条线段的远端。平直或折回的角,或短于 tolerance 的线段,给出 0。

      Parameters

      Returns number

      半段规则下的最大圆角半径,以模型单位表示

      const radius = bitbybit.point.maxFilletRadiusHalfLine({ start: [10, 0, 0], center: [0, 10, 0], end: [0, 0, 0], tolerance: 1e-7 });
      
    • 找出折线每个角的最大圆角,各自限制在其线段较近的一半内,使圆角永不重叠。

      打开 checkLastWithFirst 时,折线被视为闭合,两端的两个角也包含在内。少于三个点给出空列表。

      Parameters

      Returns number[]

      每个角点一个半径,按角点顺序排列

      const radii = bitbybit.point.maxFilletsHalfLine({
      points: [[0, 0, 0], [10, 0, 0], [10, 10, 0], [0, 10, 0]],
      checkLastWithFirst: true,
      tolerance: 1e-7,
      });
    • 找出适合折线每个角的一个圆角半径:半线段规则下各角最大值中的最小者。

      打开 checkLastWithFirst 时,折线被视为闭合。少于三个点,或任一角不允许圆角,给出 0。

      Parameters

      Returns number

      适用于每个角点的半径,以模型单位表示

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

    get

    measure

    • 测量两点之间的直线距离。

      示例:[0,0,0] 到 [3,4,0] -> 5

      Parameters

      Returns number

      以模型单位表示的距离

      const d = bitbybit.point.distance({ startPoint: [0, 0, 0], endPoint: [3, 4, 0] });
      
    • 测量一个点到列表中每个点的距离。

      示例:起点 [0,0,0] 和终点 [[3,0,0], [0,4,0], [5,0,0]] -> [3, 4, 5]

      Parameters

      Returns number[]

      每个终点一个距离,顺序相同

      const distances = bitbybit.point.distancesToPoints({ startPoint: [0, 0, 0], endPoints: [[3, 0, 0], [0, 4, 0]] });
      
    • 判断两点之间的距离是否小于容差。

      示例:[1.0000001, 2, 3] 和 [1, 2, 3],容差 1e-6 -> true

      Parameters

      Returns boolean

      当两点之间的距离小于容差时为 true

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

    sort

    • 按 X 排序点,X 相等时按 Y,然后按 Z。

      示例:[[5,0,0], [1,0,0], [3,0,0]] -> [[1,0,0], [3,0,0], [5,0,0]]

      Parameters

      Returns Point3[]

      排序后的点的副本

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

    transforms

    • 对一个点应用一个变换矩阵,或按顺序应用一个矩阵列表。

      示例:点 [0,0,0] 平移 [5,5,0] -> [5,5,0]

      Parameters

      Returns Point3

      变换后的点

      const moved = bitbybit.point.transformPoint({
      point: [0, 0, 0],
      transformation: bitbybit.transforms.translationXYZ({ translation: [5, 5, 0] }),
      });
    • 对每个点应用同一个变换矩阵,或按顺序应用同一个矩阵列表。

      示例:五个点旋转 90 度 -> 五个点一起旋转

      Parameters

      Returns Point3[]

      变换后的点,顺序相同

      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 }),
      });
    • 对每个点应用不同的变换:第一个变换用于第一个点,依此类推。

      两个列表的长度必须相同,否则抛出错误。 示例:三个点配三个平移 -> 每个点按自己的平移移动

      Parameters

      Returns Point3[]

      变换后的点,顺序相同

      const placed = bitbybit.point.transformsForPoints({
      points: [[0, 0, 0], [1, 0, 0]],
      transformation: bitbybit.transforms.translationsXYZ({ translations: [[0, 1, 0], [0, 2, 0]] }),
      });
    • 将每个点按同一个向量移动。

      示例:点 [[0,0,0], [1,0,0]] 移动 [5,5,0] -> [[5,5,0], [6,5,0]]

      Parameters

      Returns Point3[]

      移动后的点,顺序相同

      const moved = bitbybit.point.translatePoints({ points: [[0, 0, 0], [1, 0, 0]], translation: [5, 5, 0] });
      
    • 将每个点按自己的向量移动:第一个点按第一个向量,依此类推。

      两个列表的长度必须相同,否则抛出错误。 示例:三个点配三个向量 -> 每个点按自己的向量移动

      Parameters

      Returns Point3[]

      移动后的点,顺序相同

      const moved = bitbybit.point.translatePointsWithVectors({
      points: [[0, 0, 0], [1, 0, 0]],
      translations: [[0, 1, 0], [0, 2, 0]],
      });
    • 将每个点按给定的 x、y 和 z 量移动。

      示例:点 [0,0,0],x=10, y=5, z=0 -> [10,5,0]

      Parameters

      Returns Point3[]

      移动后的点,顺序相同

      const lifted = bitbybit.point.translateXYZPoints({ points: [[0, 0, 0], [1, 0, 0]], x: 0, y: 5, z: 0 });
      
    • 以中心为基准向外或向内缩放点,每个轴有自己的系数。

      示例:点 [10,0,0] 绕中心 [5,0,0],系数 [2,1,1] -> [15,0,0]

      Parameters

      Returns Point3[]

      缩放后的点,顺序相同

      const stretched = bitbybit.point.scalePointsCenterXYZ({
      points: [[10, 0, 0], [0, 10, 0]],
      center: [0, 0, 0],
      scaleXyz: [2, 1, 1],
      });
    • 从中心出发沿一个方向拉伸点;垂直于该方向的距离保持不变。

      示例:点 [10,0,0] 从中心 [0,0,0] 沿 [1,0,0],缩放 2 -> [20,0,0]

      Parameters

      Returns Point3[]

      拉伸后的点,顺序相同

      const taller = bitbybit.point.stretchPointsDirFromCenter({
      points: [[0, 1, 0], [0, 2, 0]],
      center: [0, 0, 0],
      direction: [0, 1, 0],
      scale: 2,
      });
    • 绕经过中心的轴旋转点。

      角度以度为单位,当轴指向你时逆时针转动。 示例:点 [10,0,0] 绕经过 [0,0,0] 的 Y 轴转 90 -> [0,0,-10]

      Parameters

      Returns Point3[]

      旋转后的点,顺序相同

      const turned = bitbybit.point.rotatePointsCenterAxis({
      points: [[10, 0, 0]],
      center: [0, 0, 0],
      axis: [0, 1, 0],
      angle: 90,
      });
    • 在列表中将一个点重复给定次数。

      示例:点 [5,5,0] 三次 -> [[5,5,0], [5,5,0], [5,5,0]]

      Parameters

      Returns Point3[]

      副本列表

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