Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
capsikin Guru Joined: 30/06/2020 Location: AustraliaPosts: 341
Posted: 05:03am 21 Jul 2020
Copy link to clipboard
Print this post
I modified it to run on the CMM2 and it took about 15 seconds.
starttime=timer
10 GOTO 40 20 XE = - X * S1 + Y * C1 : YE = -X * C1 * C2 - Y* S1 * C2 + Z * S2 : ZE = - X * S2 * C1 - Y *S2 * S1 + Z * C2 + RHO 30 SX = D * XE / ZE + CX : SY = CY - D * YE / ZE :RETURN 40 RHO = 30 : D = 350 : THETA = .1 : PHI = 1 : CX =140 : CY = 96 : S1 = SIN (THETA) : S2 = SIN(PHI) : C1 = COS (THETA) : C2 = COS (PHI)
' 50 DEF FN Z(X) = COS (.1 * (X * X + Y * Y)) FUNCTION FNZ(X) FNZ = COS (.1 * (X * X + Y * Y)) END FUNCTION
'60 HGR2 : HCOLOR= 3
70 FOR X = -20 TO 20 STEP .3 80 FL = 0 90 FOR Y = - 20 TO 20 STEP .07 100 Z = FNZ(X): GOSUB 20 110 IF SX < 0 OR SX > 279 OR SY < 0 OR SY > 191 THEN FL = 0 : GOTO 140 120 IF FL = 0 THEN FL = 1 : PIXEL SX,SY '130 HCOLOR=3:HPLOT SX,SY:HCOLOR=0:HPLOT SX,SY+1 TO SX,191 PIXEL SX,SY : LINE SX,SY+1, SX,191,,255 ' Colour 255 is blue, so I can see where it's drawing. 140 NEXT Y,X '150 PRINT CHR$(7):GET Q$:TEXT print @(0,200) "Time: ";timer-starttime
berighteous Senior Member Joined: 18/07/2020 Location: United StatesPosts: 110
Posted: 08:53am 21 Jul 2020
Copy link to clipboard
Print this post
SWEET! Thanks. yeah, I had it plotting a dot in white and then drawing a black line down to the bottom of the screen to clear out anything under it to clean up the plot. The program came originally from "Microcomputer Graphics: by Roy E. Meyers 1982
I ordered my CMM2 on 7/2 from RicTech but it hasn't shipped yet. I paid for the shipping upgrade to EMS so it should move faster and be trackable when it starts moving though!
mkopack73 Senior Member Joined: 03/07/2020 Location: United StatesPosts: 261
Posted: 12:24pm 21 Jul 2020
Copy link to clipboard
Print this post
Actually I just ran a little test - generated sin+cos using the MMBAsic functions for all Integer angles from 0 to 90. Then regenerated then and put them into a 2D array (one column for sin one for cos). Then timed how long it would take to lookup the sin and cos for all 0-90 from the table.
Math functions took 2.212 ms Look up table took 2.742 ms
So I’d say use the math functions!
berighteous Senior Member Joined: 18/07/2020 Location: United StatesPosts: 110
Posted: 04:47pm 21 Jul 2020
Copy link to clipboard
Print this post
the remembered to convert degrees to radians before you calculated sines and cosines, right?
mkopack73 Senior Member Joined: 03/07/2020 Location: United StatesPosts: 261
Posted: 06:08pm 21 Jul 2020
Copy link to clipboard
Print this post
Yes.
With the math functions version I do that conversion on the fly (in the loop)
With the table lookup I do it when populating the table not when performing the lookup. Which just shows how much slower the lookup is in that it’s not even having to perform the conversion to radians first.
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10067
Posted: 02:20pm 26 Jul 2020
Copy link to clipboard
Print this post
New record with 5.05.04RC12. berighteous' code now takes 10.78 seconds
Edited 2020-07-27 00:25 by matherp
diabolus Newbie Joined: 25/05/2020 Location: United KingdomPosts: 12
Posted: 02:18am 12 Jun 2021
Copy link to clipboard
Print this post
Necro thread bump, using the latest firmware posted in the last few days. Running a Circuit Gizmos Color Maximite 2 at 504Mhz.