Given two coordinates (x1, y1) and (x2, y2), and m and n, find the co-ordinates that divides that divides the line joining (x1, y1) and (x2, y2) in the ratio m : n
Input : x1 = 1, y1 = 0, x2 = 2 y2 = 5, m = 1, n = 1 Output : (1.5, 2.5) Explanation: co-ordinates (1.5, 2.5) divides the line in ratio 1 : 1 Input : x1 = 2, y1 = 4, x2 = 4, y2 = 6, m = 2, n = 3 Output : (2.8, 4.8) Explanation: (2.8, 4.8) divides the line in the ratio 2:3
The section formula tells us the coordinates of the point which divides a given line segment into two parts such that their lengths are in the ratio m : n
How does this work?
From our diagram, we can see, PS = x – x1 and RT = x2 – x We are given, PR/QR = m/n Using similarity, we can write RS/QT = PS/RT = PR/QR Therefore, we can write PS/RR = m/n (x - x1) / (x2 - x) = m/n From above, we get x = (mx2 + nx1) / (m + n) Similarly, we can solve for y.
- Section formula for 3 D
- Legendre's formula (Given p and n, find the largest x such that p^x divides n!)
- Equation of straight line passing through a given point which bisects it into two equal line segments
- Find intersection point of lines inside a section
- Reflection of a point about a line in C++
- Find the other end point of a line with given one end and mid
- Check whether the point (x, y) lies on a given line
- Perpendicular distance between a point and a Line in 2 D
- Direction of a Point from a Line Segment
- Program to find the mid-point of a line
- Shortest distance between a Line and a Point in a 3-D plane
- Find an Integer point on a line segment with given two ends
- Find foot of perpendicular from a point in 2 D plane to a Line
- Ratio of the distance between the centers of the circles and the point of intersection of two transverse common tangents to the circles
- Ratio of the distance between the centers of the circles and the point of intersection of two direct common tangents to the circles
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : jit_t