add get point to line min distance fun
This commit is contained in:
parent
f45f7f742d
commit
d3dda667b3
|
@ -46,6 +46,22 @@ export function filterNull (arr) {
|
|||
return tmpArr
|
||||
}
|
||||
|
||||
export function getPointDistance (pointOne, pointTwo) {
|
||||
const minusX = Math.abs(pointOne[0] - pointTwo[0])
|
||||
|
||||
const minusY = Math.abs(pointOne[1] - pointTwo[1])
|
||||
|
||||
return Math.sqrt(minusX * minusX + minusY * minusY)
|
||||
}
|
||||
|
||||
export function getPointToLineDistance (point, linePointOne, linePointTwo) {
|
||||
const a = getPointDistance(point, linePointOne)
|
||||
const b = getPointDistance(point, linePointTwo)
|
||||
const c = getPointDistance(linePointOne, linePointTwo)
|
||||
|
||||
return 0.5 * Math.sqrt((a + b + c) * (a + b - c) * (a + c - b) * (b + c - a)) / c
|
||||
}
|
||||
|
||||
export default function (Vue) {
|
||||
Vue.prototype.deepClone = deepClone
|
||||
Vue.prototype.deleteArrayAllItems = deleteArrayAllItems
|
||||
|
@ -53,4 +69,6 @@ export default function (Vue) {
|
|||
Vue.prototype.multipleSum = multipleSum
|
||||
Vue.prototype.randomExtend = randomExtend
|
||||
Vue.prototype.filterNull = filterNull
|
||||
Vue.prototype.getPointDistance = getPointDistance
|
||||
Vue.prototype.getPointToLineDistance = getPointToLineDistance
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue