UNPKG

@bitbybit-dev/base

Version:

Bit By Bit Developers Base CAD Library to Program Geometry

223 lines (222 loc) 8.2 kB
import { GeometryHelper } from "./geometry-helper"; import * as Inputs from "../inputs"; import { Transforms } from "./transforms"; /** * Contains various methods for points. Point in bitbybit is simply an array containing 3 numbers for [x, y, z]. * Because of this form Point can be interchanged with Vector, which also is an array in [x, y, z] form. * When creating 2D points, z coordinate is simply set to 0 - [x, y, 0]. */ export declare class Point { private readonly geometryHelper; private readonly transforms; constructor(geometryHelper: GeometryHelper, transforms: Transforms); /** * Transforms the single point * @param inputs Contains a point and the transformations to apply * @returns Transformed point * @group transforms * @shortname transform point * @drawable true */ transformPoint(inputs: Inputs.Point.TransformPointDto): Inputs.Base.Point3; /** * Transforms multiple points * @param inputs Contains points and the transformations to apply * @returns Transformed points * @group transforms * @shortname transform points * @drawable true */ transformPoints(inputs: Inputs.Point.TransformPointsDto): Inputs.Base.Point3[]; /** * Transforms multiple points by multiple transformations * @param inputs Contains points and the transformations to apply * @returns Transformed points * @group transforms * @shortname transforms for points * @drawable true */ transformsForPoints(inputs: Inputs.Point.TransformsForPointsDto): Inputs.Base.Point3[]; /** * Translate multiple points * @param inputs Contains points and the translation vector * @returns Translated points * @group transforms * @shortname translate points * @drawable true */ translatePoints(inputs: Inputs.Point.TranslatePointsDto): Inputs.Base.Point3[]; /** * Translate multiple points * @param inputs Contains points and the translation vector * @returns Translated points * @group transforms * @shortname translate points with vectors * @drawable true */ translatePointsWithVectors(inputs: Inputs.Point.TranslatePointsWithVectorsDto): Inputs.Base.Point3[]; /** * Translate multiple points by x, y, z values provided * @param inputs Contains points and the translation in x y and z * @returns Translated points * @group transforms * @shortname translate xyz points * @drawable true */ translateXYZPoints(inputs: Inputs.Point.TranslateXYZPointsDto): Inputs.Base.Point3[]; /** * Scale multiple points by providing center point and x, y, z scale factors * @param inputs Contains points, center point and scale factors * @returns Scaled points * @group transforms * @shortname scale points on center * @drawable true */ scalePointsCenterXYZ(inputs: Inputs.Point.ScalePointsCenterXYZDto): Inputs.Base.Point3[]; /** * Rotate multiple points by providing center point, axis and degrees of rotation * @param inputs Contains points, axis, center point and angle of rotation * @returns Rotated points * @group transforms * @shortname rotate points center axis * @drawable true */ rotatePointsCenterAxis(inputs: Inputs.Point.RotatePointsCenterAxisDto): Inputs.Base.Point3[]; /** * Measures the closest distance between a point and a collection of points * @param inputs Point from which to measure and points to measure the distance against * @returns Distance to closest point * @group extract * @shortname distance to closest pt * @drawable false */ closestPointFromPointsDistance(inputs: Inputs.Point.ClosestPointFromPointsDto): number; /** * Finds the closest point index between a point and a collection of points. Caution, index is not 0 based, it starts with 1. * @param inputs Point from which to find the index in a collection of points * @returns Closest point index * @group extract * @shortname index of closest pt * @drawable false */ closestPointFromPointsIndex(inputs: Inputs.Point.ClosestPointFromPointsDto): number; /** * Finds the closest point in a collection * @param inputs Point and points collection to find the closest point in * @returns Closest point * @group extract * @shortname closest pt * @drawable true */ closestPointFromPoints(inputs: Inputs.Point.ClosestPointFromPointsDto): Inputs.Base.Point3; /** * Finds the distance between two points * @param inputs Coordinates of start and end points * @returns Distance * @group measure * @shortname distance * @drawable false */ distance(inputs: Inputs.Point.StartEndPointsDto): number; /** * Finds the distances between the start point and multiple end points * @param inputs Coordinates of start and end points * @returns Distances * @group measure * @shortname distances to points * @drawable false */ distancesToPoints(inputs: Inputs.Point.StartEndPointsListDto): number[]; /** * Multiply point by a specified amount * @param inputs The point to be multiplied and the amount of points to create * @returns Distance * @group transforms * @shortname multiply point * @drawable true */ multiplyPoint(inputs: Inputs.Point.MultiplyPointDto): Inputs.Base.Point3[]; /** * Get x coordinate of the point * @param inputs The point * @returns X coordinate * @group get * @shortname x coord * @drawable false */ getX(inputs: Inputs.Point.PointDto): number; /** * Get y coordinate of the point * @param inputs The point * @returns Y coordinate * @group get * @shortname y coord * @drawable false */ getY(inputs: Inputs.Point.PointDto): number; /** * Get z coordinate of the point * @param inputs The point * @returns Z coordinate * @group get * @shortname z coord * @drawable false */ getZ(inputs: Inputs.Point.PointDto): number; /** * Get average point of points * @param inputs The points * @returns point * @group extract * @shortname average point * @drawable true */ averagePoint(inputs: Inputs.Point.PointsDto): Inputs.Base.Point3; /** * Creates the xyz point * @param inputs xyz information * @returns point 3d * @group create * @shortname point xyz * @drawable true */ pointXYZ(inputs: Inputs.Point.PointXYZDto): Inputs.Base.Point3; /** * Creates the xy point * @param inputs xy information * @returns point 3d * @group create * @shortname point xy * @drawable false */ pointXY(inputs: Inputs.Point.PointXYDto): Inputs.Base.Point2; /** * Creates the spiral out of multiple points * @param inputs Spiral information * @returns Specified number of points in the array along the spiral * @group create * @shortname spiral * @drawable true */ spiral(inputs: Inputs.Point.SpiralDto): Inputs.Base.Point3[]; /** * Creates a flat point grid on XY plane. This grid contains center points for hexagons of the given radius. * Be aware that we control only the nr of hexagons to be made and not the length and width of the grid. * @param inputs Information about hexagon and the grid * @returns Points in the array on the grid * @group create * @shortname hex grid * @drawable true */ hexGrid(inputs: Inputs.Point.HexGridCentersDto): Inputs.Base.Point3[]; /** * Removes consecutive duplicates from the point array with tolerance * @param inputs points, tolerance and check first and last * @returns Points in the array without consecutive duplicates * @group clean * @shortname remove duplicates * @drawable true */ removeConsecutiveDuplicates(inputs: Inputs.Point.RemoveConsecutiveDuplicatesDto): Inputs.Base.Point3[]; private closestPointFromPointData; }