Linear equation
lastmod 2023-02-02created 2014-09-0318 edits
A linear equation (also called a first-degree equation) is an equation whose highest-degree term has degree 1.
Category
Drawing on the coordinate plane
The most general form of the equation of a line is as follows.
Given the gradient m and the y-intercept b, the equation of the line is determined as follows.
Given two distinct points (x1,y1),(x2,y2), the equation of the line is determined as follows.
If x1 ≠ x2, it can be written as follows.
It can be obtained as an expression using the slope and y-intercept as follows.
| INFORMATION |
| For reference, the slope is |
General Form
- General Form of Equation of a Line
- Relative position of two lines - general form - Mathbang
- Finding a linear equation Ax + By + C = 0 given 2 points
The general form of a linear equation is as follows.
in one step by simply using the formula:
Python code
class GeneralForm:
"""
Ax + By + C = 0
"""
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
@classmethod
def from_points(cls, x1, y1, x2, y2):
"""
(y1 - y2)x + (x2 - x1)y + (x1y2 - x2y1) = 0
"""
a = y1 - y2
b = x2 - x1
c = (x1 * y2) - (x2 * y1)
return cls(a, b, c)
def calc_x(self, y):
return -1 * ((self.b * y) + self.c) / self.a
def calc_y(self, x):
return -1 * ((self.a * x) + self.c) / self.b
@property
def slope(self):
return -1 * (self.a / self.b)
See also
Favorite site
Intersection point of two lines
- Zetawiki - Intersection point of two lines
- answers.opencv.org - How to find the intersection point of two lines
- Github - opencv/modules/imgproc/src/min_enclosing_triangle.cpp
References
Pages that link here