MCPで接続 →

計算を入力してください

公式

広告

結果

@
直線の方程式
y = 0.5 · x + 1
slope-intercept form (y = a·x + b)
傾き a 0.5
y切片 b 1
2点間の距離 PQ 6.708204
傾きの角度 θ 26.565051

この計算ツールでできること

平面上の2点 P(x1, y1) と Q(x2, y2) を入力すると、その2点を通る直線の方程式を傾き切片形 \( y = a\cdot x + b \) で求めます。あわせて2点間の距離と、直線の傾きの角度(傾斜角)も計算します。角度は度数法(度)と弧度法(ラジアン)のどちらでも表示できます。

使い方

2点それぞれの座標を入力してください。傾きの角度は度数法(初期設定)か弧度法のいずれかを選べます。入力すると、傾き \(a\)、y切片 \(b\)、2点間の距離 PQ、角度 \(\theta\) がすぐに計算されます。座標は単位を持たない数値として扱うため、距離の結果は一貫した単位であればどの単位系でも利用できます。

計算式の解説

\( dx = \text{x}_2 - \text{x}_1 \)、\( dy = \text{y}_2 - \text{y}_1 \) とおきます。傾きは \( a = dy / dx \)(縦の変化量を横の変化量で割った値)です。y切片は \( b = (\text{x}_2\cdot\text{y}_1 - \text{x}_1\cdot\text{y}_2) / (\text{x}_2 - \text{x}_1) \) で求められ、これは \( b = \text{y}_1 - a\cdot\text{x}_1 \) と同じ値になります。距離は三平方の定理から \( d = \sqrt{dx^2 + dy^2} \) です。傾きの角度は \( \theta = \arctan(dy / dx) \) で、x軸の正の向きを基準に測ります。 $$ y = m\,(x - \text{x}_1) + \text{y}_1 $$ $$ \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. $$ 角度が正なら右上がりの直線、負なら右下がりの直線を表します。

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 = (2\cdot(-1) - (-4)\cdot 2)/6 = (-2 + 8)/6 = 1 \) なので、直線は $$ y = 0.5\cdot x + 1 $$ です。距離 \( = \sqrt{36 + 9} = \sqrt{45} \approx 6.7082 \)。角度 \( = \arctan(0.5) \approx 0.4636\ \text{rad} \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).

よくある質問

垂直な直線の場合はどうなりますか? \( \text{x}_2 = \text{x}_1 \) のとき、直線はy軸に平行になります。傾き切片形では表せないため、傾きと切片は無限大(\(\infty\))として返されます。距離は \( |\text{y}_2 - \text{y}_1| \) のまま求められ、角度は \( \pm 90° \) になります。

水平な直線の場合は? \( \text{y}_2 = \text{y}_1 \) のときは傾きが0、角度も0となり、方程式は \( y = b \) になります。

2点が同じ座標のときは? 距離は0となり、直線は定義できません。1つの点を通る直線は無数に存在するためです。

最終更新: