Some more optimizations:
-Get rid of the ending parentheses on all the menus.
-In line 61, get rid of "Goto ZZ", because Lbl ZZ comes directly after it.
-You may be able to get rid "ClrHome" in some spots - instead of doing ClrHome within each options block of code, why not do it before the menus, instead of within each option?
-Obviously, you could shorten some of the text that is displayed either on the home screen or the menus to save a little bit of space.

-toward the end of your code, you have

Code:

Output(B,8,sub("''''''''''''''''''''''''''",A,1

since all of those characters are the same, couldn't you just do this?

Code:

Output(B,8,"'
Michael2_3B wrote:
Some more optimizations:
-Get rid of the ending parentheses on all the menus.
-In line 61, get rid of "Goto ZZ", because Lbl ZZ comes directly after it.
-You may be able to get rid "ClrHome" in some spots - instead of doing ClrHome within each options block of code, why not do it before the menus, instead of within each option?
-Obviously, you could shorten some of the text that is displayed either on the home screen or the menus to save a little bit of space.

-toward the end of your code, you have

Code:

Output(B,8,sub("''''''''''''''''''''''''''",A,1

since all of those characters are the same, couldn't you just do this?

Code:

Output(B,8,"'


Good Job Micheal! My program got reduced from 1899 bytes to 1822 bytes... Cool

Answers to your bullets:

-Done, got rid of the ending parenthesis
-Done, got rid of "Goto ZZ".
-Not done, because when i tired to move "ClrHome"'s around the program it messed up my screen. Previous text was appearing over new text.
-Done, thanks for that Smart Tip!!! Good Idea Idea Very Happy

Here's my new code (anything more that can be optimized?):


Code:

Lbl W
Menu("Tranformation:","Translation",AA,"Reflection",BB,"Rotation",CC,"Dilation",DD,"Exit",Z
Lbl AA
1→M
ClrHome
Output(1,8,"Translation
Goto ZZ
Lbl BB
ClrHome
Menu("Reflection:","X-axis",B1,"Y-axis",B2,"Y=x",B3,"Y=-x",B4,"Go Back",W,"Exit",Z
Lbl B1
2→M
ClrHome
Output(1,10,"X-axis
Goto ZZ
Lbl B2
3→M
ClrHome
Output(1,10,"Y-axis
Goto ZZ
Lbl B3
4→M
ClrHome
Output(1,12,"Y=x
Goto ZZ
Lbl B4
5→M
ClrHome
Output(1,11,"Y=-x
Goto ZZ
Lbl CC
ClrHome
Menu("Rotation:","CW 90° (CCW 270°)",C1,"180°",C2,"CCW 90° (CW 270°)",C3,"Go Back",W,"Exit",Z
Lbl C1
6→M
ClrHome
Output(1,5,"CW 90° (CCW 270°)
Goto ZZ
Lbl C2
7→M
ClrHome
Output(1,11,"180°
Goto ZZ
Lbl C3
8→M
ClrHome
Output(1,5,"CCW 90° (CW 270°)
Goto ZZ
Lbl DD
ClrHome
Menu("Dilation:","From the Origin",D1,"Custom Origin",D2,"Go Back",W,"Exit",Z
Lbl D1
9→M
ClrHome
Output(1,6,"From the Origin
Goto ZZ
Lbl D2
10→M
ClrHome
Output(1,7,"Custom Origin
Lbl ZZ
Disp "","","Number of Points?","
Prompt D
D→dim(L₁
D→dim(L₂
D→dim(L₃
D→dim(L₄
ClrHome
1→B
For(A,1,D
Disp "Point"
Output(B,7,sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",A,1
B+3→B
If B>9
9→B
Prompt X
X→L₁(A
Prompt Y
Y→L₂(A
End
If M=1
Then
ClrHome
Disp "Move By?","
Prompt X
X+L₁→L₃
Prompt Y
Y+L₂→L₄
End
If M=2
Then
L₁→L₃
⁻L₂→L₄
End
If M=3
Then
⁻L₁→L₃
L₂→L₄
End
If M=4
Then
L₂→L₃
L₁→L₄
End
If M=5
Then
⁻L₂→L₃
⁻L₁→L₄
End
If M=6
Then
L₂→L₃
⁻L₁→L₄
End
If M=7
Then
⁻L₁→L₃
⁻L₂→L₄
End
If M=8
Then
⁻L₂→L₃
L₁→L₄
End
If M=9
Then
ClrHome
Output(1,7,"Scale Factor?
Disp "","
Prompt E
L₁*E→L₃
L₂*E→L₄
End
If M=10
Then
ClrHome
Output(1,7,"Scale Factor?
Disp "","
Prompt E
ClrHome
Output(1,4,"Center of Dilation?
Disp "","
Prompt X,Y
L₁-X→L₅
L₂-Y→L₆
L₅*E→L₅
L₆*E→L₆
L₅+X→L₃
L₆+Y→L₄
End
augment(L₁,{L₁(1→L₁
augment(L₂,{L₂(1→L₂
augment(L₃,{L₃(1→L₃
augment(L₄,{L₄(1→L₄
ClrHome
2→B
Output(1,8,"New Points: "
Disp ""
For(A,1,D
Disp "Point"
Output(B,7,sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",A,1
Output(B,8,"'
B+2→B
If B>9
9→B
Disp {L₃(A),L₄(A)
End
"
Pause
Menu("Plot the Images?","Yes",ZX,"New Points",NP,"Main Menu",W,"Exit",Z
Lbl NP
If M=1
Goto AA
If M≥2 and M≤5
Goto BB
If M≥6 and M≤8
Goto CC
If M≥9
Goto DD
Lbl ZX
Plot1(xyLine,L₁,L₂,plotsquare)
Plot2(xyLine,L₃,L₄,plotsquare)
DispGraph
ZStandard
Pause
ClrDraw
PlotsOff
Goto W
Lbl Z
ClrHome
Stop
I can't stress enough that the best way to learn is to do something yourself. In this case, that specifically means spending time with your code, figuring out something that you think will help optimize the program, trying it, and seeing what happens. If it works, great, you learned something. If it breaks the program, you have learned even more, and you'll continue to learn as you work to fix it. In this case, your program's individual lines are already quite optimized, so you should look at the program as a whole. Is there a way you can reorganize it to be smaller or clearer? Is there a way you can replace some of the Lbl/Goto flow with If/Then/Else/End, Repeat/End, or While/End? One of the important TI-BASIC programming lessons is that Lbl/Goto is easy, and slow. When you can optimize them out of your program, it almost always speeds them up. If it helps you in your learning process, please feel free to post a sort of running commentary of the experiments you try as you work on optimizing your program, and as always, we're especially willing to answer specific questions when you have shown that you are putting effort into the project yourself.
Program Testing Phase:

I have finally decided that I'm going to test my program on the Ti-83 and Ti-84 families. I have created this program by testing it on my TI-84+ CSE. I request you to help me out if you have any of the mentioned Calculators.

The following is the list of Calculators and the people who have decided to help me out (If you volunteered/want to volunteer, I will update the list):

TI-83 Plus: <slot empty>
TI-83 Plus Silver Edition: <slot empty>
TI-84 Plus: <slot empty>
TI-84 Plus Silver Edition: Electromagnet8
TI-84 Plus C Silver Edition: Myself

Here is the download link of the program.

If you don't mind, I would appreciate some screenshots of the program running on the calculator.
I agree with Kerm that some, if not most of the Lbls and Gotos could be eliminated with the use of loops. However, it seems that you are satisfied with the program for now. You can always look back at this program and optimize it more yourself once you get an understanding of the more advanced techniques. I did the same with my first program as well.

It seems that you want to release this program for the TI-83/84/+/SE/CSE family. In my opinion, it is easier to develop a program that displays anything on a monochrome calculator first and then port it to the TI-84+CSE. This is because the monochrome calculators have a smaller homescreen and a smaller graphscreen. However, this is not possible for you.

One of your problems is that some text is either running off of the screen or the text is wrapped and is displayed onto the next line. To fix this you could limit the length of text being displayed and/or change the arguments of Output() to fit the 8 row-16 column monochrome screen.
JLovern wrote:
Let me try my hand at converting the Lbl U*s to boolean:

Code:
(M=2)L₁-(M=3)L₁+(M=4)L₂-(M=5)L₂+(M=6)L₂-(M=7)L₁-(M=8)L₂→L₃

Here's the first half for U2 through U8.


Thanks for this JLovern. This optimized my program by a bit. The program got reduced from 1833 bytes to 1799 bytes... Cool

Many thanks to KermMartian and Mateo, who patiently explained this whole thing to me in SAX!

Any further optimization will be greatly appreciated. I have reproduced the code below:


Code:

Lbl W
Menu("Tranformation:","Translation",AA,"Reflection",BB,"Rotation",CC,"Dilation",DD,"Exit",Z
Lbl AA
1→M
ClrHome
Output(1,8,"Translation
Goto ZZ
Lbl BB
ClrHome
Menu("Reflection:","X-axis",B1,"Y-axis",B2,"Y=x",B3,"Y=-x",B4,"Go Back",W,"Exit",Z
Lbl B1
2→M
ClrHome
Output(1,10,"X-axis
Goto ZZ
Lbl B2
3→M
ClrHome
Output(1,10,"Y-axis
Goto ZZ
Lbl B3
4→M
ClrHome
Output(1,12,"Y=x
Goto ZZ
Lbl B4
5→M
ClrHome
Output(1,11,"Y=-x
Goto ZZ
Lbl CC
ClrHome
Menu("Rotation:","CW 90° (CCW 270°)",C1,"180°",C2,"CCW 90° (CW 270°)",C3,"Go Back",W,"Exit",Z
Lbl C1
6→M
ClrHome
Output(1,5,"CW 90° (CCW 270°)
Goto ZZ
Lbl C2
7→M
ClrHome
Output(1,11,"180°
Goto ZZ
Lbl C3
8→M
ClrHome
Output(1,5,"CCW 90° (CW 270°)
Goto ZZ
Lbl DD
ClrHome
Menu("Dilation:","From the Origin",D1,"Custom Origin",D2,"Go Back",W,"Exit",Z
Lbl D1
9→M
ClrHome
Output(1,6,"From the Origin
Goto ZZ
Lbl D2
10→M
ClrHome
Output(1,7,"Custom Origin
Lbl ZZ
Disp "","","Number of Points?","
Prompt D
D→dim(L₁
D→dim(L₂
D→dim(L₃
D→dim(L₄
ClrHome
1→B
For(A,1,D
Disp "Point"
Output(B,7,sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",A,1
B+3→B
If B>9
9→B
Prompt X
X→L₁(A
Prompt Y
Y→L₂(A
End
If M=1
Then
ClrHome
Disp "Move By?","
Prompt X
X+L₁→L₃
Prompt Y
Y+L₂→L₄
End
If M>1 and M<9
Then
(M=2)L₁-(M=3)L₁+(M=4)L₂-(M=5)L₂+(M=6)L₂-(M=7)L₁-(M=8)L₂→L₃
⁻(M=2)L₂+(M=3)L₂+(M=4)L₁-(M=5)L₁-(M=6)L₁-(M=7)L₂+(M=8)L₁→L₄
End
If M=9
Then
ClrHome
Output(1,7,"Scale Factor?
Disp "","
Prompt E
L₁*E→L₃
L₂*E→L₄
End
If M=10
Then
ClrHome
Output(1,7,"Scale Factor?
Disp "","
Prompt E
ClrHome
Output(1,4,"Center of Dilation?
Disp "","
Prompt X,Y
L₁-X→L₅
L₂-Y→L₆
L₅*E→L₅
L₆*E→L₆
L₅+X→L₃
L₆+Y→L₄
End
augment(L₁,{L₁(1→L₁
augment(L₂,{L₂(1→L₂
augment(L₃,{L₃(1→L₃
augment(L₄,{L₄(1→L₄
ClrHome
2→B
Output(1,8,"New Points: "
Disp ""
For(A,1,D
Disp "Point"
Output(B,7,sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",A,1
Output(B,8,"'
B+2→B
If B>9
9→B
Disp {L₃(A),L₄(A)
End
"
Pause
Menu("Plot the Images?","Yes",ZX,"New Points",NP,"Main Menu",W,"Exit",Z
Lbl NP
If M=1
Goto AA
If M≥2 and M≤5
Goto BB
If M≥6 and M≤8
Goto CC
If M≥9
Goto DD
Lbl ZX
Plot1(xyLine,L₁,L₂,plotsquare)
Plot2(xyLine,L₃,L₄,plotsquare)
DispGraph
ZStandard
Pause
ClrDraw
PlotsOff
Goto W
Lbl Z
ClrHome
Return
Let's see:


Code:
B+3→B
If B>9
9→B
//can be:
min(B+3,9→B //change this to 8, see my post below

Similarly:
B+2→B:If B>9:9→B
//can be:
min(B+2,9→B

Code:
If M=1
Goto AA
If M≥2 and M≤5
Goto BB
If M≥6 and M≤8
Goto CC
If M≥9
Goto DD
//can be (because you know M≥2, etc. if you didn't jump):
If M=1:Goto AA
If M≤5:Goto BB
If M≤8:Goto CC
Goto DD

Code:
If M>1 and M<9
Then
(M=2)L₁-(M=3)L₁+(M=4)L₂-(M=5)L₂+(M=6)L₂-(M=7)L₁-(M=8)L₂→L₃
⁻(M=2)L₂+(M=3)L₂+(M=4)L₁-(M=5)L₁-(M=6)L₁-(M=7)L₂+(M=8)L₁→L₄
End
//can be (assuming M is an integer):
If 4>abs(M-5
Then
expr(sub("1L₁-L₁1L₂-L₂1L₂-L₁-L₂",2M-3,2→L₃
expr(sub("-L₂1L₂1L₁-L₁-L₁-L₂1L₁",2M-3,2→L₄
End

And

Code:
L₁-X→L₅
L₂-Y→L₆
L₅*E→L₅
L₆*E→L₆
L₅+X→L₃
L₆+Y→L₄
//can be (assuming you aren't using L₅ or L₆)
X+E(L₁-X→L₃
Y+E(L₂-Y→L₆


This one is slightly advanced, but you can also just put, for example, :5 on its own line rather than :5→M, if you're going to jump to Lbl ZZ before any more variable-storing. This will store 5 into Ans, and if you write Ans→M after Lbl ZZ, it'll go right into M anyway.

Finally, you don't need to ClrHome after the lines with [something]→M because you already ClrHome'd before the menus, and the menus clear themselves from the screen. (Pretty sure about this, anyway... )

But that hack with expr( shouldn't really be necessary. Have you considered using a complex list for points, and storing them in the form {x₁+y₁i,x₂+y₂i,...}? It wouldn't be any smaller to store, and it's a major change. However, you only need to deal with half the lists, and some operations are much easier—for example, with your points stored in L₁:

-reflection across the x-axis is conj(L₁
-across the y-axis is -iconj(iL₁
-across x=y would be iconj(L₁
-rotation by 90, 180 and 270 degrees counterclockwise are iL₁, -L₁, -iL₁
-translation by (x right, y up) is L₁+x+yi
-dilation by a factor of A is AL₁. If it's around a point (x,y), where Z=x+yi, it's just Z+A(L₁-Z).

And the coordinates can be extracted easily: y with imag(L₁ and x with imag(iL₁ (don't use real( as it can break xLib and Omnicalc.)

Good luck with this program!
I just tried it on Jstified, and I entered 5 data points to be translated. After I inputted point C, it gave me a domain error at this:

Code:
Output(B,7,sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",A,1


It had displayed "Point " on the homescreen after I exited the program.

Here's a video:
You generate much menu's, each with their own label, nice to see, but not very fast. I always uses this code, which is longer but much faster. You may implement it some times to your own code


Code:

Disp "Reflection:"," X-axis"," Y-axis"," Y=x"," Y=-x"," Go Back"," Exit"
2->M
Output(M,1,">"
Repeat K=105
getKey->K
Output(M,1," "
max(2,min(7,M+(K=34)-(K=25->M
Output(M,1,">"
End
ClrHome
If M=2
Output(1,10,"X-axis"
If M=3
Output(1,10,"Y-axis"
If M=4
Output(1,12,"Y=x"
If M=5
Output(1,11,"Y=-x"
If M=6
Goto W
If M=7
Goto Z
Goto ZZ
caleb1997, are you sure the code worked before my change? In any case, the error is because you're trying to display the point name on row B when B=9, and there is no row 9 on the monochrome calculators. Change min(B+2,9) to min(B+2,8) and min(B+3,9) to min(B+3,8). (It also occurs to me that this method of displaying won't work on a CSE or CE, because there are more homescreen rows.)

PT_, I think speed isn't much of a priority; it would be acceptable for the label-finding to take up to .4 seconds or so.
  
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 4 of 4
» 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