UNPKG

claw-machine-js

Version:

A physics based claw-machine simulation

34 lines (33 loc) 1.5 kB
import { IPosition } from '../interfaces/Position.ts'; /** * rotates the points for opening the claw * @param point the normal position of the point * @param pivot the anchor point for the rotation * @param angle the rotation angle */ export declare const rotatePoint: (point: IPosition, pivot: IPosition, angle: number) => IPosition; /** * Calculates the shortest distance from a point to a line segment. * * @param px - The x-coordinate of the point. * @param py - The y-coordinate of the point. * @param x1 - The x-coordinate of the start of the line segment. * @param y1 - The y-coordinate of the start of the line segment. * @param x2 - The x-coordinate of the end of the line segment. * @param y2 - The y-coordinate of the end of the line segment. * @returns The shortest distance from the point (px, py) to the line segment from (x1, y1) to (x2, y2). */ export declare const distanceToLineSegment: (px: number, py: number, x1: number, y1: number, x2: number, y2: number) => number; /** * Calculates the diagonal width based on the given claw width. * * @param clawWidth - The width of the claw. * @returns The diagonal width calculated using the Pythagorean theorem. */ export declare const calculateClawWidth: (clawWidth: number) => number; /** * checks if the new value is inside the set Boundary between 0 and maxValue * @param value the new value * @param maxValue the maximum value */ export declare function calculateBoundary(value: number, maxValue: number): number;