Maker.js, a Microsoft Garage project, is a JavaScript library for creating and sharing modular line drawings for CNC and laser cutters.

View project on GitHub Star

Api - measure Module

Index

Variables

Private Const graham_scan

graham_scan: ConvexHullGrahamScan

Private Const onPathMap

onPathMap: object

Type declaration

Private pathAreEqualMap

pathAreEqualMap: IPathAreEqualMap

Private pathExtentsMap

pathExtentsMap: object

Type declaration

Private pathLengthMap

pathLengthMap: object

Type declaration

  • [pathType: string]: function
      • (pathToMeasure: IPath): number
      • Parameters

        Returns number

Functions

Private addUniquePoints

  • addUniquePoints(pointArray: IPoint[], pointsToAdd: IPoint[]): number
  • Parameters

    • pointArray: IPoint[]
    • pointsToAdd: IPoint[]

    Returns number

augment

  • Augment a measurement - add more properties such as center point, height and width.

    Parameters

    • measureToAugment: IMeasure

      The measurement to augment.

    Returns IMeasureWithCenter

    Measurement object with augmented properties.

boundingHexagon

  • Measures the minimum bounding hexagon surrounding a model. The hexagon is oriented such that the right and left sides are vertical, and the top and bottom are pointed.

    Parameters

    • modelToMeasure: IModel

      The model to measure.

    Returns IBoundingHex

    IBoundingHex object which is a hexagon model, with an additional radius property.

Private cloneMeasure

Private getAngledBounds

  • getAngledBounds(index: number, modelToMeasure: IModel, rotateModel: number, rotatePaths: number): IAngledBoundary

Private getExtremePoint

Private getFarPoint

Private hexSolution

  • hexSolution(lines: IPathLine[], bounds: IAngledBoundary[]): IHexSolution

increase

  • Increase a measurement by an additional measurement.

    Parameters

    • baseMeasure: IMeasure

      The measurement to increase.

    • addMeasure: IMeasure

      The additional measurement.

    • Optional augmentBaseMeasure: boolean

      Optional flag to call measure.augment on the measurement.

    Returns IMeasure

    The increased original measurement (for cascading).

isAngleEqual

  • isAngleEqual(angleA: number, angleB: number, accuracy?: number): boolean
  • Find out if two angles are equal.

    Parameters

    • angleA: number

      First angle.

    • angleB: number

      Second angle.

    • Default value accuracy: number = 0.0001

    Returns boolean

    true if angles are the same, false if they are not

isArcConcaveTowardsPoint

  • isArcConcaveTowardsPoint(arc: IPathArc, towardsPoint: IPoint): boolean
  • Check for arc being concave or convex towards a given point.

    Parameters

    • arc: IPathArc

      The arc to test.

    • towardsPoint: IPoint

      The point to test.

    Returns boolean

    Boolean true if arc is concave towards point.

isArcOverlapping

  • isArcOverlapping(arcA: IPathArc, arcB: IPathArc, excludeTangents: boolean): boolean

isArcSpanOverlapping

  • isArcSpanOverlapping(arcA: IPathArc, arcB: IPathArc, excludeTangents: boolean): boolean
  • Check for arc overlapping another arc.

    Parameters

    • arcA: IPathArc

      The arc to test.

    • arcB: IPathArc

      The arc to check for overlap.

    • excludeTangents: boolean

      Boolean to exclude exact endpoints and only look for deep overlaps.

    Returns boolean

    Boolean true if arcA is overlapped with arcB.

isBetween

  • isBetween(valueInQuestion: number, limitA: number, limitB: number, exclusive: boolean): boolean
  • Check if a given number is between two given limits.

    Parameters

    • valueInQuestion: number

      The number to test.

    • limitA: number

      First limit.

    • limitB: number

      Second limit.

    • exclusive: boolean

      Flag to exclude equaling the limits.

    Returns boolean

    Boolean true if value is between (or equal to) the limits.

isBetweenArcAngles

  • isBetweenArcAngles(angleInQuestion: number, arc: IPathArc, exclusive: boolean): boolean
  • Check if a given angle is between an arc's start and end angles.

    Parameters

    • angleInQuestion: number

      The angle to test.

    • arc: IPathArc

      Arc to test against.

    • exclusive: boolean

      Flag to exclude equaling the start or end angles.

    Returns boolean

    Boolean true if angle is between (or equal to) the arc's start and end angles.

isBetweenPoints

  • isBetweenPoints(pointInQuestion: IPoint, line: IPathLine, exclusive: boolean): boolean
  • Check if a given point is between a line's end points.

    Parameters

    • pointInQuestion: IPoint

      The point to test.

    • line: IPathLine

      Line to test against.

    • exclusive: boolean

      Flag to exclude equaling the origin or end points.

    Returns boolean

    Boolean true if point is between (or equal to) the line's origin and end points.

isBezierSeedLinear

  • Check if a given bezier seed has all points on the same slope.

    Parameters

    • seed: IPathBezierSeed

      The bezier seed to test.

    • Optional exclusive: boolean

      Optional boolean to test only within the boundary of the endpoints.

    Returns boolean

    Boolean true if bezier seed has control points on the line slope and between the line endpoints.

isChainClockwise

  • isChainClockwise(chainContext: IChain, out_result?: object): boolean
  • Check for flow of paths in a chain being clockwise or not.

    Parameters

    • chainContext: IChain

      The chain to test.

    • Optional out_result: object

      Optional output object, if provided, will be populated with convex hull results.

      • Optional hullPoints?: IPoint[]
      • Optional keyPoints?: IPoint[]

    Returns boolean

    Boolean true if paths in the chain flow clockwise.

Private isCircular

  • isCircular(bounds: IAngledBoundary[]): boolean

isLineOverlapping

  • isLineOverlapping(lineA: IPathLine, lineB: IPathLine, excludeTangents: boolean): boolean
  • Check for line overlapping another line.

    Parameters

    • lineA: IPathLine

      The line to test.

    • lineB: IPathLine

      The line to check for overlap.

    • excludeTangents: boolean

      Boolean to exclude exact endpoints and only look for deep overlaps.

    Returns boolean

    Boolean true if lineA is overlapped with lineB.

isMeasurementOverlapping

  • Check for measurement overlapping another measurement.

    Parameters

    • measureA: IMeasure

      The measurement to test.

    • measureB: IMeasure

      The measurement to check for overlap.

    Returns boolean

    Boolean true if measureA is overlapped with measureB.

isPathEqual

  • isPathEqual(pathA: IPath, pathB: IPath, withinPointDistance?: number, pathAOffset?: IPoint, pathBOffset?: IPoint): boolean
  • Find out if two paths are equal.

    Parameters

    • pathA: IPath

      First path.

    • pathB: IPath

      Second path.

    • Optional withinPointDistance: number
    • Optional pathAOffset: IPoint
    • Optional pathBOffset: IPoint

    Returns boolean

    true if paths are the same, false if they are not

isPointArrayClockwise

  • isPointArrayClockwise(points: IPoint[], out_result?: object): boolean
  • Check for array of points being clockwise or not.

    Parameters

    • points: IPoint[]

      The array of points to test.

    • Optional out_result: object

      Optional output object, if provided, will be populated with convex hull results.

      • Optional hullPoints?: IPoint[]
      • Optional keyPoints?: IPoint[]

    Returns boolean

    Boolean true if points flow clockwise.

isPointDistinct

  • isPointDistinct(pointToCheck: IPoint, pointArray: IPoint[], withinDistance?: number): boolean
  • Find out if a point is distinct among an array of points.

    Parameters

    • pointToCheck: IPoint

      point to check.

    • pointArray: IPoint[]

      array of points.

    • Optional withinDistance: number

      Optional distance to consider points equal.

    Returns boolean

    false if point is equal to any point in the array.

isPointEqual

  • isPointEqual(a: IPoint, b: IPoint, withinDistance?: number): boolean
  • Find out if two points are equal.

    Parameters

    • a: IPoint

      First point.

    • b: IPoint

      Second point.

    • Optional withinDistance: number

      Optional distance to consider points equal.

    Returns boolean

    true if points are the same, false if they are not

isPointInsideModel

  • Check to see if a point is inside of a model.

    Parameters

    • pointToCheck: IPoint

      The point to check.

    • modelContext: IModel

      The model to check against.

    • Default value options: IMeasurePointInsideOptions = {}

      Optional IMeasurePointInsideOptions object.

    Returns boolean

    Boolean true if the path is inside of the modelContext.

isPointOnCircle

  • Find out if point is on a circle.

    Parameters

    • p: IPoint

      Point to check.

    • circle: IPathCircle

      Circle.

    • Default value withinDistance: number = 0

      Optional distance of tolerance.

    Returns boolean

    true if point is on the circle

isPointOnPath

  • Find out if a point lies on a path.

    Parameters

    • pointToCheck: IPoint

      point to check.

    • onPath: IPath

      path to check against.

    • Default value withinDistance: number = 0

      Optional distance to consider point on the path.

    • Optional pathOffset: IPoint

      Optional offset of path from [0, 0].

    • Optional options: IIsPointOnPathOptions

      Optional IIsPointOnPathOptions to cache computation.

    Returns boolean

isPointOnSlope

  • isPointOnSlope(p: IPoint, slope: ISlope, withinDistance?: number): boolean
  • Find out if point is on a slope.

    Parameters

    • p: IPoint

      Point to check.

    • slope: ISlope
    • Default value withinDistance: number = 0

      Optional distance of tolerance.

    Returns boolean

    true if point is on the slope

isSlopeEqual

  • Check for slope equality.

    Parameters

    • slopeA: ISlope

      The ISlope to test.

    • slopeB: ISlope

      The ISlope to check for equality.

    Returns boolean

    Boolean true if slopes are equal.

isSlopeParallel

  • Check for parallel slopes.

    Parameters

    • slopeA: ISlope

      The ISlope to test.

    • slopeB: ISlope

      The ISlope to check for parallel.

    Returns boolean

    Boolean true if slopes are parallel.

lineSlope

Private loopIndex

  • loopIndex(base: number, i: number): number

modelExtents

  • Measures the smallest rectangle which contains a model.

    Parameters

    • modelToMeasure: IModel

      The model to measure.

    • Optional atlas: Atlas

      Optional atlas to save measurements.

    Returns IMeasureWithCenter

    object with low and high points.

modelPathLength

  • modelPathLength(modelToMeasure: IModel): number
  • Measures the length of all paths in a model.

    Parameters

    • modelToMeasure: IModel

      The model containing paths to measure.

    Returns number

    Length of all paths in the model.

pathExtents

  • Calculates the smallest rectangle which contains a path.

    Parameters

    • pathToMeasure: IPath

      The path to measure.

    • Optional addOffset: IPoint

    Returns IMeasure

    object with low and high points.

pathLength

  • pathLength(pathToMeasure: IPath): number
  • Measures the length of a path.

    Parameters

    • pathToMeasure: IPath

      The path to measure.

    Returns number

    Length of the path.

pointDistance

  • Calculates the distance between two points.

    Parameters

    Returns number

    Distance between points.

Private pointOnSlopeAtX

Private serializePoint

  • serializePoint(p: number[]): string

Private yAtX

  • yAtX(slope: ISlope, x: number): number

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc