NaaLaa
Turtle graphics - Printable Version

+- NaaLaa (https://www.naalaa.com/forum)
+-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html)
+--- Forum: NaaLaa 7 Code (https://www.naalaa.com/forum/forum-4.html)
+--- Thread: Turtle graphics (/thread-76.html)

Pages: 1 2


RE: Turtle graphics - 1micha.elok - 02-15-2024

(02-15-2024, 08:18 AM)Tomaaz Wrote: ...
For smaller programs you could skip that part completely. 
...

Thank you for your response. I decided to make a small experiment, 
- The first experiment : I used sprawdz () which has katzolwia> 360 and katzolwia<0
- The second experiment :  I skipped sprawdz () 

The results are
- The first experiment produced some "shifted green lines"
- The second experiment produced a clean blue line

   

Code:
set window "Turtle Proof",640,360

reset() 'set angle to 0
set color 0,0,0;cls 'clear screen
iteration = 100

' First Experiment
' Use sprawdz () which has katzolwia> 360 and katzolwia<0
set color 0,255,0 'green
goxy(300,120)
for i = 1 to iteration
    forward(50)
    turnleft(45)
next

' Second Experiment
' Skip sprawdz () which has katzolwia> 360 and katzolwia<0
set color 0,0,255 'blue
goxy(300,220)
for i = 1 to iteration
    forward(50)
    turnleft3(45)
next

'pause
pln "Press ENTER to quit"
temp = rln()



RE: Turtle graphics - Tomaaz - 02-15-2024

Something similar is happening with the Koch Curve example. When you set recursion to 6 or more calls, all you get is a single pixel. I'm 99% sure it wasn't happening with Yabasic or EGSL It must be something related to number precision in NaaLaa.

I should have been more clear about what I meant by "smaller programs". It doesn't matter how many line of code there is. All that matter is number of turns.


RE: Turtle graphics - Marcus - 02-15-2024

(02-15-2024, 12:17 PM)Tomaaz Wrote: Something similar is happening with the Koch Curve example. When you set recursion to 6 or more calls, all you get is a single pixel. I'm 99% sure it wasn't happening with Yabasic or EGSL It must be something related to number precision in NaaLaa.

I should have been more clear about what I meant by "smaller programs". It doesn't matter how many line of code there is. All that matter is number of turns.

Nah, all numbers in n7 are doubles (64 bit floating point values). Remove the 'int' calls in turtle.n7 and you can run more iterations.


RE: Turtle graphics - Tomaaz - 02-15-2024

Thanx, Marcus! Smile


RE: Turtle graphics - 1micha.elok - 02-16-2024

Wonderful  Big Grin
Thank you Tomaaz, your Turtle library is very useful to produce amazing turtle graphics / arts.
Thank you also to Marcus for giving us an insight regarding numbers in n7.

Herewith another turtle experiment :
   

First experiment : turtle library contained int()           
     produced "shifted green lines"

Second experiment : turtle library without int()  
     produced clean blue lines

Code:
'-------------------------------------------------------------
' Modified turtle library
'  First Experiment : function forward (dlugosc) with int()
'  Second Experiment :function forward3(dlugosc) without int()
'-------------------------------------------------------------

include "turtle_modified.n7"

set window "Turtle Experiment",640,360
reset() 'set angle to 0
set color 0,0,0;cls 'clear screen
iteration = 100

'FIRST experiment
set color 0,255,0 'green
goxy(300,120)
for i = 1 to iteration
    forward(50)
    turnleft(45)
next

'SECOND experiment
set color 0,0,255 'blue
goxy(350,120)
for i = 1 to iteration
    forward3(50)
    turnleft(45)
next

'pause
pln "Press ENTER to quit"
temp = rln()