I call this program Two Points. It's goal is to tell you everything there is to know about the relationship between the two points that you input. Such as: Distance, Midpoint, Slope and the equation of the line that intersects those points.
Already done: Distance, Midpoint, and Slope.
If you can think of anything else that should be added to this, do not hesitate to ask!

Not sure if this is the place to ask for code help. If it isn't please move this.
I am having trouble with getting the equation of the line that passes through the points. I am trying to get the slope from the points and then use the point-slope formula to get the equation. If there is an easier way, let me know! This is what I have:
Code:
Input "X1=",A
Input "Y1=",B
Input "X2=",C
Input "Y2=",D
ClrHome
(D-B)/(C-A)->E
E*A->F
F+B->G
Output(4,1,"Y="
Output(4,3,E
Output(4,6,"X-"
Output(4,8,G

Thanks for any help you can give!
As of right now your program is 97 bytes, there are a few ways to cut down.

Code:

Input "X1=",A 
Input "Y1=",B 
Input "X2=",C 
Input "Y2=",D 
ClrHome 
(D-B)/(C-A->E     //When storing values in Ti-basic you can leave of the ending parentheses.
EA->F     //no need to E*A when EA is the same thing
F+B->G 
Output(4,1,"Y=      //in ti-basic you can leave of the ending quotation mark if there is nothing that follows it
Output(4,3,E 
Output(4,6,"X-      //read note previous
Output(4,8,G

I know there is probably some advanced concept for this that weregoose could whip up but let's leave it simple. So for now this is the best way. Saved 4 bytes. I know it's not much but it really does add up to save bytes in large programs so just get used to optimizing. Your program seems pretty nifty.
Thanks! The code I have is not producing the correct answers though Sad
If I take (1,2) and (3,4), the equation is y=x+1
The code gives me y=x+3
Welcome to Cemetech, lanmonster! Be sure to Introduce Yourself in our topic for that purpose. At the risk of advertising, I just published a book about TI-BASIC that you might find helpful. Smile Anyway, about your method:

- You correctly calculate M = slope = rise/run
- For the calculation of the intercept, you need to satisfy the equation Y=MX+B, so you plug in X1 and Y1, reasonable enough
- Rearranging the equation, B=Y-MX=B-EA (in the future, you might want to consider different variable names). Therefore, I suggest this code:


Code:
Input "X1=",A 
Input "Y1=",B 
Input "X2=",C 
Input "Y2=",D 
ClrHome 
(D-B)/(C-A->M     //When storing values in Ti-basic you can leave of the ending parentheses.
B-EA->F
Output(4,1,"Y=      //in ti-basic you can leave of the ending quotation mark if there is nothing that follows it
Output(4,3,E 
Output(4,6,"X+      //read note previous
Output(4,8,F
Funnily enough, I have this exact algorithm as an example in one of my chapters. Smile
Thanks for your help!
lanmonster wrote:
Thanks for your help!
No problem, we're glad to help. Smile Feel free to stick around to discuss coding and technology with us and perhaps develop your TI-BASIC skills more.
can I post my entire code and ask for optimization help? I already took what you and zeldaking said in your code examples and applied across my code.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement