透過 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 軸方向量起:角度為正表示直線往右上升,為負則表示往右下降。

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 = \frac{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,而直線無法定義,因為通過單一點的直線有無限多條。

最後更新: