Page 1
Index
See this article in english 
Page 2
Intersection of lines in 2D

Lines in 2D

Alexander Hristov

General equation

The general equation of a line has the form

ax + by + c = 0

where a and b cannot be simultaneously 0.

 

Parametric Equation

Slope equation

Point and slope

For any non-vertical line

  • y = ax+b, where a is the slope of the line.

or, if you know the slope φ and b, then

  • y = tg(φ)x + b

 

 

 

Vector equation of a line

Let rp be the radus-vector of a point p laying on the line. Let also d be the directional vector of the line : a radius vector with the same slope as the line and (usually) with a norm (length) of 1. 

Vector equation of a line

Then the equation of the line in vector form can be expressed as:

r(t) = rp + d.t, where t varies continuously between -∞ and +∞. This equation is valid in any number of dimensions.

Expressing the vector equation of a line in cartesian coordinates, we arrive at exactly the parametric equation:

Vector equation of a line in cartesian coordinates

 

Line through two points

Line through two points

If x1 ≠x2

a = tg(φ) = (y2-y1)/(x2-x1)

b = y2- ax2 = y2- x2(y2-y1)/(x2-x1)

To retrieve the slope,

φ  = Math.atan2(y2-y1,x2-x1)

If x1= x2 the equation is x = x1 (or 1.x + 0.y - x1 = 0). The slope is π/2

 

 

Line crossing the axis at (x0,0)  and (0,y0)

Line through two points

This is a particular case of the previous situation

a = tg(φ) = -y0/x0

b = y0

To retrieve the slope,

φ  = Math.atan2(-y0,x0)   [in Java]

Line characteristics

Form Slope (φ) intersects X at Intersects Y at
y = ax + b arctan (a) x  = -b/a  (never, if a = 0) y = b
y = y0t + yf
x = x0t + xf

If If x0 ≠ 0, arctan( y0/x0)

If x0= 0, π/2

x =xf - x0 yf/y0

(never, if y0 = 0)

y =yf - y0 xf/x0

(never, if x0 = 0)

ax+by+c = 0

if b 0 arctan (-a/b),

if b = 0, π/2

x = -c/a  (never, if a = 0) y = -c/b (never if b = 0)
x1,y1,x2,y2
(two points)

arctan((y2-y1)/(x2-x1))

If x2 = x1, π/2

(never, if y1=y2)

(never, if x1=x2)

 

Conversions between different forms

From To Transformation
ax + by + c = 0 y = fx + g If b ≠0,  f = -a/b,  g = -c/b
If b = 0,  not possible

y = fx+g

ax+by+c = 0

a = -f, b = 1, c = -g
y = y0t + yf
x = x0t + xf
y = fx+g

If x0 ≠ 0 ⇒f = y0/x0, g =yf - xf/x0

If x0 = 0 not possible

y = fx+g y = y0t + yf
x = x0t + xf


xf = 0
yf = g

y = y0t + yf
x = x0t + xf
ax+by+c  = 0

If x0 ≠ 0 ⇒ c= (xfy0 - x0yf), a = x0, b = -y0

If x0 = 0 ⇒c = -xf, a = -1, b = 0

x1,y1,x2,y2
(two points)
y = ax + b

If x1 ≠x2, a = (y2-y1)/(x2-x1),  b = y2- x2(y2-y1)/(x2-x1)

If x1= x2 , not possible

x1,y1,x2,y2
(two points)
y = y0t + yf
x = x0t + xf

Let .

Then
yf = y1
xf = x1

x1,y1,x2,y2
(two points)
ax+by+c = 0

a =(y2--y1)

b =(x1-x2)

c = (x2y1--y2x1)

 

 

Comments

 

Add a Comment

Name (optional)
EMail (optional, will not be displayed)

Text