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
Intercept of two lines
Started by
Guest_ejbennett_*
, Jan 18 2009 03:53 AM
3 replies to this topic
#1
Guest_ejbennett_*
Posted 18 January 2009 - 03:53 AM
Guest_ejbennett_*
|
|
|
#2
Posted 18 January 2009 - 04:18 AM
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
This is kind of simple, but a simple explanation is usually very effective.
mathsisfun.com/equation_of_line.html
#3
Guest_ejbennett_*
Posted 18 January 2009 - 04:35 AM
Guest_ejbennett_*
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
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
Posted 18 January 2009 - 05:26 AM
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.
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.


Sign In
Create Account

Back to top










