You are Here: Home >< Maths

# Finding the end points of a line? watch

1. Well, long story short, I'm doing some programming coursework, and a part of it requires me to find the end coordinates of a line with a known start point, length, and gradient.
I'm pretty sure that this can be done, as with only the above information it is achievable graphically.
I just can't think what it is, when I find out, I'll probably kick myself though
From how far I've got, is that I'll end up with 2 different coordinates (as the length could be either way along the line away from the starting point)

Cheers for any help, it's really appreciated.
2. Hey R.C. Well yes its not so much difficult as cumberson, I think just requires some lateral thinking ;D.

I am assuming from what you said we are working in 2D here. I think a good algorithm would be to first find a normalised vector parallel to your line (can I ask how do you arrive at the gradient, because it may be you can make more efficient code). Now your hopefully see why we want to do this in a little while.

So first do you agree that this vector v would be parallel to your line:

Now we want to normalize this vector, this you can do ;D. Now from here have a think, you now have coordiantes of you start position, a (scalar) distance to the end position and a (unit) normalized vector parallel to your line. This should be enough info to solve your problem now, and using this info you can still find the two end coordiantes that you require.

Have a go and post back any thoughts if you get stuck
3. Thanks for that, I'll give that a go in the morning (or most likely the afternoon because I doubt I'll be up that early :P )

And basically, I ask the user to input the beginning coordinates, and end coordinates of a line, and the length of the line that will come off perpendicular from those points, I then need to find the end points of those lines. So I can find the gradient of the beginning line by delta y divided by delta x, then the gradient of the perpendicular line is then -1 divided by that value.
4. Ah rite ok R.C, thanks for the info on the program, yeh hopefully you should be able to use what I said. I deffinalty hear on the afternoon buissness ;D
5. Thanks very much, I think I've worked it out Or atleast, I get the right answer now :P

What I ended up with (after a bit of checking back on some C4 vectors ) Was the following:

Vector of starting point = VA
Vector of end point = VB
Normalised vector of parallel line = VP
Length of line = L

VB=VA+L(VP)

Or in general terms (as I'll be using it) where:
(x0,y0) = Starting coordinates of the line
(x1,y1) = End coordinates of the line
L = length of the line
m = gradient of the line

If you can see a problem with it, can you let me know, but now I'm going to try and work out how to program this...
6. No thats exactly what I would have done , looks fine to me.

As a small note, in the future you might like to think about using the LaTeX system built in to the SR forum, you can have a look here. I only say that for your own easieness , from the looks of it youve create that equation in another program, (probably using latex?) and then had to upload it, something that could be alot easier ;D.

Anyway nice one on the work there, good luck with the rest of your program
7. I knew there was something but I didn't know where to find it/how to use it, cheers for that I actually Used the equation writer in word, print screened, then uploaded :P

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: February 7, 2010
Today on TSR

### Uni league tables

Do they actually matter?

### University open days

• University of Exeter
Wed, 24 Oct '18
Wed, 24 Oct '18
• Northumbria University
Wed, 24 Oct '18
Poll
Useful resources

### Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

### How to use LaTex

Writing equations the easy way

### Study habits of A* students

Top tips from students who have already aced their exams