Be the first user to complete this post
|
Add to List |
450. Given two coordinates, Print the line equation
Objective: Given two coordinates (x1, y1) and (x2, y2). Write a java program to construct a line equation that passes through the given coordinates.
Line Equation:
Given two coordinates (x1, y1) and (x2, y2) the line equation is y - y1 = m(x - x1) where m is the slope of the line, where slope = (y2-y1)/(x2-x1)
Example:
Given coordinates: [3,7] and [5,11] Line Equation: y = 2x + 1 Given coordinates: [2,2] and [4,12] Line Equation: y = 5x -8
Output:
Given coordinates: [2,2] and [4,12] Line Equation: y = +5x -8