-1
私は2つのポイントAとBとポイントの母集団を持っており、それぞれのポイントからラインABまでの距離を求めたいと思います。数値の逆数を求める方法は?
まず、線の傾きを求め、次にY切片を求めます。 Distance between point & lineに続いて、2番目の00:48には、勾配(数)の負の逆数が必要であることが記載されています。
私は任意の数をとって、それの負の逆数を返す関数を望みます。 let inverseOfSlope = getInverse(slope);
してくださいと4castleコメント「の数の負の逆数」として感謝
getDistance(PointA: Object, PointB: Object, Target: Object)
{
// find slope of the line
let slope = (PointA.y - PointB.y)/(PointA.x - PointB.x)
// find y intercept
let yIntercept = PointA.y + ((-1 * slope) * PointA.x)
// find inverse negative of the slope
let newSlope = -1 * getInverse(slope);
// find new y-intercept
let NewYintercept = PointA.y + ((-1 * newSlope) * PointA.x)
// get point of intersection between the two lines
// by solving the two equations equal to each other
// calculate distance between target and point of intersection
// easy
// return result
}
数値の負の逆数は '-1/slope'になります。 – 4castle