메뉴로 건너 뛰기 내용으로 건너 뛰기
COMMUNITY
Title [Jason Lee] Spiral question
Jason 선생님의 AP Computer Science Principles- AppDev L12 Loops_Spirals 12
Author ala*** Date Posted 2023-07-31 오후 9:30:44

Hello, Mr.Jason. I am Ruhan Lee. I bet I have met you in Maker's Academy. I am 11 years old, and I started CS Principles after taking my Statistics exam. I was watching your lesson on spirals and I saw that the spirals were made out of short lines and weren't completely curved. I thought I could make it curved so I changed a lot of code and I finally got to run it but it didn't look like a perfect spiral. (P.S. I didn't use arcLeft and arcRight on purpose).

Here's the code:


var n = 200;

var diameter = 50;

var x = 1;    

var increaseEvery = 180;

var sn = x/increaseEvery*10;

for (var i = 0; i < n; i++) {

  for (var j = 0; j < increaseEvery/x; j++){

    moveForward(x);

    turnRight( ((3600/diameter)/30) / x );

  }

  x = x + sn;

  

}


hide();

I took 30 minutes to find the error but I can't.

Here's also the website:

https://studio.code.org/projects/applab/7gjZ_0SI1aBo9jBhjaTMn7uXTRyHHiMk9dbgMBbETOk/edit

My email or username is ruhanlee2013@gmail.com

My password is codecodecode

Thank you.

2023-08-03 오전 10:39:54

I remember you Ruhan :)

How have you been? I see you're having fun studying as usual. 

before I answer your question, let me remind you that this is a public board and posting ID and pasword is unwise, to say the least.

I don't need your id, you can just 'share' your work with a link and I'll be able to inspect your code.

 

Anyhow, no matter what you do you cannot create a perfect circle on a computer. in your code you have to use moveForward(), which is a straight line, however short it is. computer screens are essentially rectangular grids, so you can make it look like a circle from a distance, but it will never lose its straight edges, even if you control it to the last pixel, two pixels will form a line, so... this effort is futile. 

 

Good job thinking about it, though. 

 

Jason.


PS change your password ASAP!! many people have read this post

Top