通过MCP连接 →

输入计算

数学公式

广告

结果

@
直线方程
y = 0.5 · x + 1
slope-intercept form (y = a·x + b)
斜率 a 0.5
y 轴截距 b 1
两点距离 PQ 6.708204
斜率倾角 theta 26.565051

这个计算器能做什么

只要给出平面上的两个点 P(x1, y1) 和 Q(x2, y2),它就会以斜截式 \(y = a\cdot x + b\) 给出过这两点的直线方程。同时,它还会算出两点之间的距离,以及直线的斜率倾角(即倾斜角),结果可以按角度或弧度显示。

使用方法

填入两个点的坐标,再选择倾角要用角度(默认)还是弧度表示。计算器会即时算出斜率 \(a\)、y 轴截距 \(b\)、两点距离 PQ 以及倾角 \(\theta\)。坐标都是无量纲的纯数字,因此距离结果可套用任何一致的单位。

公式解析

设 \(dx = x_2 - x_1\),\(dy = y_2 - y_1\)。斜率为 \(a = dy / dx\)(纵向变化除以横向变化,即「升高/水平距离」)。y 轴截距为 \(b = (x_2\cdot y_1 - x_1\cdot y_2) / (x_2 - x_1)\),它等价于 \(b = y_1 - a\cdot x_1\)。距离由勾股定理得出:\(d = \sqrt{dx^2 + dy^2}\)。倾角为 \(\theta = \arctan(dy / dx)\),从 x 轴正方向量起:角度为正表示直线向右上方倾斜,为负则表示向右下方倾斜。

$$\begin{gathered} y = m\,(x - \text{x}_1) + \text{y}_1 \\[1.5em] \text{where}\quad \left\{ \begin{aligned} m &= \frac{\text{y}_2 - \text{y}_1}{\text{x}_2 - \text{x}_1} \\[0.4em] d &= \sqrt{(\text{x}_2 - \text{x}_1)^2 + (\text{y}_2 - \text{y}_1)^2} \\[0.4em] \theta &= \frac{180}{\pi}\arctan(m) \end{aligned} \right. \end{gathered}$$
Two points P and Q on a coordinate plane joined by a straight line, showing rise, run, slope angle and y-intercept
The line through P and Q: slope a is rise over run, b is the y-intercept, and theta is the slope angle.

实例演算

以 P(-4, -1) 和 Q(2, 2) 为例:\(dx = 6\),\(dy = 3\)。斜率 \(a = 3/6 = 0.5\)。截距 $$b = \frac{2\cdot(-1) - (-4)\cdot 2}{6} = \frac{-2 + 8}{6} = 1,$$因此直线为 \(y = 0.5\cdot x + 1\)。距离 \(= \sqrt{36 + 9} = \sqrt{45} \approx 6.7082\)。倾角 \(= \arctan(0.5) \approx 0.4636\) 弧度 \(\approx 26.565°\)。

Distance between two points shown as the hypotenuse of a right triangle with horizontal and vertical legs
The distance between P and Q is the hypotenuse of a right triangle with legs (x2-x1) and (y2-y1).

常见问题

遇到竖直线会怎样?当 \(x_2 = x_1\) 时,直线平行于 y 轴。此时斜截式无法定义,斜率和截距都会返回无穷大;但距离仍然等于 \(|y_2 - y_1|\),倾角为 \(\pm 90°\)。

水平线呢?若 \(y_2 = y_1\),则斜率为 0,倾角为 0,方程变为 \(y = b\)。

如果两个点重合呢?此时距离为 0,直线无法确定,因为经过同一个点的直线有无数条。

最后更新: