Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Equation of a l...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 43843 of 48020
Post > Topic >>

Equation of a line (y=mx+c)

by gbvk@[EMAIL PROTECTED] Mar 12, 2008 at 09:25 AM

Hello,

i'm trying to implement "y=mx+c" into code to find the intercept of a
line.


#include <iostream.h>
#include <stdlib.h>
#include <math.h>

void main ()
{
	int Ax, Ay, Bx, By;
  	float Dx, Dy, Dist, Grad;

cout<<"Please enter the 'x' coordinate of the first point: "<<endl;
cin>>Ax;
cout<<"Please enter the 'y' coordinate of the first point: "<<endl;
cin>>Ay;
cout<<"Please enter the 'x' coordinate of the second point: "<<endl;
cin>>Bx;
cout<<"Please enter the 'y' coordinate of the second point: "<<endl;
cin>>By;

Dx=Ax-Bx;
Dy=Ay-By;
Grad= Dy/Dx;

cout<<"Gradient = "<<Grad<<endl;
}

is what i have so far to find "m".

Ex A(2,3) B(6,5)

As I understand the fomula would be;

y-Ay = Grad*(x-Ax)

substituing from A;

y-3=0.5*(x-2)
y-3=0.5x-1
y=0.5x+2

therefore "c" would be: 2

any idea on how i could code this?


G
 




 8 Posts in Topic:
Equation of a line (y=mx+c)
gbvk@[EMAIL PROTECTED]   2008-03-12 09:25:50 
Re: Equation of a line (y=mx+c)
"Victor Bazarov"  2008-03-12 12:55:19 
Re: Equation of a line (y=mx+c)
gbvk@[EMAIL PROTECTED]   2008-03-12 10:14:56 
Re: Equation of a line (y=mx+c)
Juha Nieminen <nospam@  2008-03-13 10:35:00 
Re: Equation of a line (y=mx+c)
gbvk@[EMAIL PROTECTED]   2008-03-12 10:32:34 
Re: Equation of a line (y=mx+c)
"Victor Bazarov"  2008-03-12 13:47:52 
Re: Equation of a line (y=mx+c)
Ron Natalie <ron@[EMAI  2008-03-12 14:40:49 
Re: Equation of a line (y=mx+c)
James Kanze <james.kan  2008-03-13 01:40:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 8:50:52 CDT 2008.