geometry-fns
v1.0.2
Published
A collection of functions for working with points geometry.
Downloads
5
Readme
geometry-fns
A collection of functions for working with points geometry.
Installation
npm i geometry-fns --save
API
areIntersected
判断两根直线是否相交,传入两条直线的起点和终点的x和y坐标。
import { areIntersected } from 'geometry-fns'
function areIntersected(
qx1: number,
qy1: number,
qx2: number,
qy2: number,
lx1: number,
ly1: number,
lx2: number,
ly2: number
): boolean
crossOverExperiments
跨立实验(求向量的叉积),传入一条直线的起点和终点的x和y坐标,跟另一个点的x和y坐标做跨立实验。
import { crossOverExperiments } from 'geometry-fns'
function crossOverExperiments(
lx1: number,
ly1: number,
lx2: number,
ly2: number,
x1: number,
y1: number
): number
distanceBetween
求两个坐标点之间的距离
import { distanceBetween } from 'geometry-fns'
function distanceBetween(
x1: number,
y1: number,
x2: number,
y2: number
): number
isConvexPolygon
判断是否凸多边形,传入一个数组包含多个点的x和y坐标组成的多边形
import { isConvexPolygon } from 'geometry-fns'
function isConvexPolygon(polygon: number[]): boolean
lineCrossedQuadrangle
判断直线是否穿过四边形,如果穿过就返回两条直线的坐标数组
import { lineCrossedQuadrangle } from 'geometry-fns'
function lineCrossedQuadrangle(
line: number[],
quadrangle: number[]
): [number[], number[]] | null
orthocenterOf
求多边形的重心
import { orthocenterOf } from 'geometry-fns'
function orthocenterOf(polygon: number[]): number[] | null