Jump to content

Intercept of two lines

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Guest_ejbennett_*

Guest_ejbennett_*
  • Guests
Hi,

I am wondering if anyone knows of a simple way for a program to work out when two lines intercept (of the form y=mx+c). The problem is that there are two main methods to solving simultanious equations like this, but i cant think how to describe this in logic for, i just see the equations and know which to do.

Is there a function that can do this? Any help will be welcomed, if you need more info just let me know

Cheers
Ed

This is for C language by the way

#2
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
If i understand u correctly, your problem is not a programming one. It seems to be a math problem. You need to know exactly what you want to code b4 u attemp to code.
This is kind of simple, but a simple explanation is usually very effective.
mathsisfun.com/equation_of_line.html

#3
Guest_ejbennett_*

Guest_ejbennett_*
  • Guests
sorry obviously i have not been clear;

I have got two equations in my program so far, i just need to solve to find out when they intercept each other.

Usually if i were to do this myself i would either subtract one from the other, or divide one from another in a way that would remove one of the variables (x or y), so that i could solve for one of them. Once i know one i sub that into one of the original equations to find the remaining unknown value.

My problem is that i cant work out how to portray all of that into coding (unless writing a hundred lines or so), so i am wondering if there is a simlpe way to do this in programing or if there is already a function written to do this.

Thanks

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What you need to do is your usual process on these two equations:

y=m1*x+b1
y=m2*x+b2

You need to check for parallel lines (m1==m2 and b1<>b2) before you apply whatever formula results.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog