namespace CalculateGeometry {
// Point 接口 (x,y)
export interface Point {
x: number,
y: number,
}
// Line 接口 a*x+b*y+c = 0
export interface Line {
a: number,
b: number,
c: number,
}
// 根据已知两点坐标,求过这两点的直线解析方程: a*x+b*y+c = 0 (a >= 0)
export function makeline(p1: Point, p2: Point): Line {
let l: Line;
if (p2.y - p1.y >= 0) {
l = {
a: p2.y - p1.y,
b: p1.x - p2.x,
c: p1.y * p2.x - p1.x * p2.y,
};
} else {
l = {
a: p1.y - p2.y,
b: p2.x - p1.x,
c: p1.x * p2.y - p1.y * p2.x,
};
}
return tl;
}
}
04-24
09-09
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交