dash–calculator

01 Vectors and Coordinates

Directed Line Segment Calculation Explained

Readout 01-0171 · Updated · Standard formula, shown below

Point x 6.00
Point y
5.67
Result, rounded to 2 decimal places
Length
7.21 units
Result, rounded to 2 decimal places
x₁
2
Input
You enter
x₁, y₁, x₂, y₂, Ratio m, Ratio n
You get
Point x, Point y, Length (units)
Rounding
2 dp

This calculator works out the coordinates of a point that divides a directed line segment in a given ratio, and it also gives the length of the segment. You enter the coordinates of the two endpoints (x₁, y₁) and (x₂, y₂), plus the ratio m : n, and you get the dividing point (x, y) and the distance between the endpoints. The calculation uses the section formula from coordinate geometry, which is the standard method for this task.

Formula

For a directed line segment from point A(x₁, y₁) to point B(x₂, y₂), the point P that divides the segment in the ratio m : n (meaning AP : PB = m : n) is found with the section formula:

P(x, y) = ( (n·x₁ + m·x₂) / (m + n), (n·y₁ + m·y₂) / (m + n) )

  • x₁, y₁ – coordinates of the first endpoint (the start of the directed segment)
  • x₂, y₂ – coordinates of the second endpoint (the end of the directed segment)
  • m – the first part of the ratio (the distance from A to P)
  • n – the second part of the ratio (the distance from P to B)
  • P(x, y) – the coordinates of the dividing point

The length of the segment (the distance between A and B) is the standard Euclidean distance:

Length = √( (x₂ – x₁)² + (y₂ – y₁)² )

All coordinates and lengths are in the same unit you use for the input coordinates. The ratio m : n must be positive (both m and n greater than 0). If m = n, the point is simply the midpoint.

Worked Example

Using the default values from the calculator: A = (2, 3), B = (8, 7), and the ratio m : n = 2 : 1.

First, find the x-coordinate of P:

x = (n·x₁ + m·x₂) / (m + n) = (1·2 + 2·8) / (2 + 1) = (2 + 16) / 3 = 18 / 3 = 6

Next, find the y-coordinate:

y = (n·y₁ + m·y₂) / (m + n) = (1·3 + 2·7) / (2 + 1) = (3 + 14) / 3 = 17 / 3 ≈ 5.67

So the point P is (6, 5.67). This means P is located 2/3 of the way from A to B, because the ratio 2:1 means AP is two parts and PB is one part of the whole (total 3 parts).

Now the length of the segment AB:

Length = √( (8 – 2)² + (7 – 3)² ) = √(6² + 4²) = √(36 + 16) = √52 ≈ 7.21 units

These match the calculator outputs: point (6.00, 5.67) and length 7.21.

What Is a Directed Line Segment?

A directed line segment is a line segment with a specific orientation – it has a starting point and an ending point. In notation, it is written as AB (with an arrow above), meaning it goes from A to B. The direction matters: segment AB is different from segment BA because the start and end are swapped.

In coordinate geometry, the directed segment is often used in vector problems, physics (displacement), and computer graphics. The “directed” part becomes important when you need to find a point that divides the segment in a given ratio – the ratio is measured from the start to the end, not the other way around.

For example, if you have a segment from A to B and you want to find the point that is 1/3 of the way from A, you use the ratio 1:2 (m=1, n=2). If you wanted the point 2/3 of the way, you would use m=2, n=1. The formula automatically handles this because m is always the part from the start.

How to Use the Calculator

Enter the coordinates of the two endpoints and the ratio. The calculator returns the coordinates of the dividing point and the length of the whole segment. Here are the steps:

  1. Identify the start point (x₁, y₁) and the end point (x₂, y₂) of your directed segment.
  2. Decide the ratio m : n. For example, if you want the point that is 3/4 of the way from start to end, use m=3, n=1 (because 3 parts from start, 1 part to end).
  3. Enter the values into the calculator.
  4. Read the output point (x, y) and the length.

The ratio m and n must be positive numbers. If you enter m=0 or n=0, the formula would give one of the endpoints, but it is better to keep both positive for a proper division.

Common Mistakes and Misconceptions

One very common mistake is swapping m and n. Remember, m is the distance from the start to the dividing point, and n is from the dividing point to the end. If you swap them, you get a completely different point – the one that divides the segment in the ratio n : m instead.

Another mistake is using the formula for external division when you need internal division. The formula above is for internal division – the point lies between A and B. For external division (point outside the segment), the formula is different: P = ( (m·x₂ – n·x₁) / (m – n), (m·y₂ – n·y₁) / (m – n) ), with m ≠ n. This calculator only handles internal division.

Unit mix-ups are also common. If your coordinates are in meters, the length will be in meters. If you mix feet and meters, the result will be wrong. Always use the same unit for all coordinates.

Finally, rounding too early can cause errors. In the worked example, we got 5.666…, but if you round to 5.7 before using it in further calculations, you might get a slightly different answer. Keep full precision until the final step.

Real-World Applications

The section formula is not just a math exercise – it appears in many practical fields:

  • Computer graphics: Interpolating between two points on a line, such as moving an object from one position to another over time.
  • Physics: Finding the center of mass of a system of two particles, where the ratio is based on masses.
  • Surveying and mapping: Determining a point along a straight boundary line at a given fraction of the distance.
  • Robotics: Path planning – calculating intermediate waypoints along a straight path.
  • 3D modeling: Subdividing edges of polygons or meshes.

In all these cases, the directed nature of the segment matters because the ratio is always measured from the start point.

Limitations and Extensions

This calculator works for a 2D plane. If you have a 3D segment, the same formula applies to each coordinate separately: x, y, and z. For example, the x-coordinate of the dividing point is (n·x₁ + m·x₂)/(m+n), and similarly for y and z.

The formula assumes a straight line between the two points. If you are working on a curved surface (like the Earth), you would need geodesic calculations instead.

Also, the ratio m : n is assumed to be positive. If you need a ratio like 2 : -1 (external division), this calculator will not work – you would need the external division formula.

For points in higher dimensions, the same pattern extends: each coordinate is a weighted average of the corresponding coordinates of the endpoints.

Frequently Asked Questions

What is the difference between a line segment and a directed line segment?
A line segment is just the set of points between two endpoints, with no direction. A directed line segment has a specific start and end, so it has an orientation. The notation AB (with an arrow) means from A to B, and BA would be the opposite direction.

How do I find the midpoint using the section formula?
Set m = n = 1. Then the formula becomes P = ((1·x₁ + 1·x₂)/2, (1·y₁ + 1·y₂)/2) = ((x₁+x₂)/2, (y₁+y₂)/2), which is exactly the midpoint formula.

What if the ratio is given as a fraction, like 2/3?
A fraction like 2/3 means the point is 2/3 of the way from the start to the end. In that case, the ratio m : n is 2 : 1 (because 2 parts out of 3 total). So m = 2, n = 1. If the fraction is 1/4, then m = 1, n = 3.

Can the calculator find a point outside the segment?
No, this calculator only finds points that lie between the two endpoints (internal division). For external division, you would need a different formula, and the ratio would involve a negative value.

Does the order of endpoints matter?
Yes, it changes the result. If you swap the endpoints, the dividing point will be different because the ratio is measured from the start. For example, with A=(0,0), B=(10,0), and ratio 1:2, the point is at 3.33 from A. If you swap A and B, the point is at 6.67 from the new start (which is the original B).

What units should I use for the length?
Use the same unit as your coordinates. If your coordinates are in meters, the length is in meters. If they are in feet, the length is in feet. The calculator does not convert units – it just uses the numbers you give.

Related

Formula used
in x1 | x₁ | - | 2 | -100000 | 100000
in y1 | y₁ | - | 3 | -100000 | 100000
in x2 | x₂ | - | 8 | -100000 | 100000
in y2 | y₂ | - | 7 | -100000 | 100000
in m | Ratio m | - | 2 | 0 | 1000
in n | Ratio n | - | 1 | 0 | 1000
out px | Point x | - | (n * x1 + m * x2) / (m + n) | 2
out py | Point y | - | (n * y1 + m * y2) / (m + n) | 2
out len | Length | units | sqrt((x2 - x1)^2 + (y2 - y1)^2) | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More on this panel

The whole Vectors and Coordinates panel →