Hey there! Sign in to join this conversationNew here? Join for free
Turn on thread page Beta
    • Thread Starter
    Offline

    0
    ReputationRep:
    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.
    Offline

    0
    ReputationRep:
    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:

    \textbf{v} = \left( \begin{array}{c} 1 \\ m \end{array}\right)
    where m is the gradient of 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
    • Thread Starter
    Offline

    0
    ReputationRep:
    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.
    Offline

    0
    ReputationRep:
    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
    • Thread Starter
    Offline

    0
    ReputationRep:
    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 :rolleyes: ) 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...
    Offline

    0
    ReputationRep:
    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
    • Thread Starter
    Offline

    0
    ReputationRep:
    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
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: February 7, 2010
Poll
“Yanny” or “Laurel”
Useful resources

Make your revision easier

Maths

Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

Equations

How to use LaTex

Writing equations the easy way

Student revising

Study habits of A* students

Top tips from students who have already aced their exams

Study Planner

Create your own Study Planner

Never miss a deadline again

Polling station sign

Thinking about a maths degree?

Chat with other maths applicants

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.