This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-03-29 03:18:41

jedidiahzhu
Scratcher
Registered: 2011-01-16
Posts: 85

Space

I need to make a project showing the sun, moon, and earth moving in the solar system. HELP!!

I need the earth to orbit the sun, the earth to spin, the moon to orbit the earth, and for the earth to tilt toward the moon.

Last edited by jedidiahzhu (2012-03-31 00:35:32)

Offline

 

#2 2012-03-29 04:45:26

xJira
Scratcher
Registered: 2012-03-24
Posts: 91

Re: Space

For homework? Ya teacher is mean ^__~ But I'll try to help you ...

First you need 3 objects of course ...

The moon (I'll do that later) and the sun, which has the code

when gf clicked
go to x: (0) y: (0)
Then you need an earth which is flying around you sun ... a good startpoint would be
when gf clicked
go to x: (-170) y: (0)
Next the movements of the earth. I created a variable I named "walker". First, I set the walker to zero. Also, I told the earth to do the first half of the movent until its y-position is smaller than zero. The earth shall change x by 1,69 every round so that it moves to the right!

when gf clicked
go to x: (-170) y: (0)
forever
set [walker] to (0)
repeat until <(x position) < [0] >
change x by [1,69]
end
It also has to go up and when then down and thats what the "walker" is for.

when gf clicked
go to x: (-170) y: (0)
forever
set [walker] to (0)
repeat until <(x position) < [0] >
change x by [1,69]
change y by [3-walker] // of course you need a mathblock: [(3) - (walker)]
change [walker] by (0.03)
end
Ok, the first round, it moves 3 up (3-0, because the walker is 0) then 3-0.03, then 3-0.03-0.03 and so on. When it's above the earth, it will be
change y by [0] //because the walker will be 3 ... and 3 - 3 is of course 0 ;D
After this, it will go on like 3-3,03 (=-0,03)  ... 3-3,06 (=-0,06)  and so on and that gives negative numbers so the earth starts moving down ... I hope you understood how this works XD
How I found these crazy numbers? Trying, Trying, Trying ;D But somehow it works xD

Ok, this orders, move to the right and up and then to the right and down will end, when the earth reaches the point x = 0 and y = 170

Because then, it must start moving to the left and down and then to the left and up, so first we need another loop and have to set the walker to zero again ...

when gf clicked
go to x: (-170) y: (0)
forever
set [walker] to (0)
repeat until <(x position) < [0] >
change x by [1,69]
change y by [3-walker]
change [walker] by (0.03)
end
set [walker] to (0)
repeat until <(x position) > [0] > //know it does this until x is larger then 0 because then it made the whole circle 
change x by [-1,69] //__________or more or less eclipse around the sun and starts again with the first loop.
end
now it changes x by -1,69 and moves to the left again.
First the earth is supposed to move down, so we say "Change y by -3" (instead of +3)
and of course we need the walker again to make it move up again after a while, so ...

when gf clicked
go to x: (-170) y: (0)
forever
set [walker] to (0)
repeat until <(x position) < [0] >
change x by [1,69]
change y by [3-walker]
change [walker] by (0.03)
end
set [walker] to (0)
repeat until <(x position) > [0] >
change x by [-1,69]
change y by [-3 + Walker] //+ walker, so that it will be -3 + 3 = 0 at one point, like in the other loop
change [walker] by [0,03]
end
Well, you could say "(+) Walker - 3" instead of "-3 + walker"

when gf clicked
go to x: (-170) y: (0)
forever
set [walker] to (0)
repeat until <(x position) < [0] >
change x by [1,69]
change y by [3-walker]
change [walker] by (0.03)
end
set [walker] to (0)
repeat until <(x position) > [0] >
change x by [-1,69]
change y by [Walker - 3] //+ walker, so that it will be -3 + 3 = 0 at one point, like in the other loop
change [walker] by [0,03]
end
Ok, thats how the earth would move around the sun! And the moon ... I will try something and post later  smile

Offline

 

#3 2012-03-29 09:26:12

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Space

Much easier way:

when gf clicked // in sun sprite
go to x:(0) y:(0)

when gf clicked // in earth/moon sprite
go to x:(0) y:(100)
set [n v] to (0)
forever
clear
change [n v] by (1)//replace 1 with desired orbit speed for moon.
point towards [sun v]
turn ccw (87) degrees
move (5) steps
switch to costume [earth v]
stamp
change x by (([sin v] of (n)) * (50))//replace 50 with the desired orbit radius of the moon
change y by (([cos v] of (n)) * (50))
switch to costume [moon v]
stamp
change x by (([sin v] of (n)) * (-50))//remember, -50 not 50
change y by (([cos v] of (n)) * (-50))
Of course, these orbits are circular. In reality, the orbits are elliptical, but I'm sure you math teacher isn't that mean. Anyway, enjoy this script, it's fun to watch!

If your math teacher asks, by the way, say, "It is based on the principal that a tangent to a circular orbit will be perpendicular to the corresponding radius; and plotting all solutions of cos(arcsin(x)) returns a circle."
Memorize it. That ought to stun him!

Last edited by Hardmath123 (2012-03-29 09:40:31)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#4 2012-03-30 08:45:40

jedidiahzhu
Scratcher
Registered: 2011-01-16
Posts: 85

Re: Space

jedidiahzhu wrote:

I need to make a project showing the sun, moon, and earth moving in the solar system. HELP!!

I need the earth to orbit the sun, the the earth to spin, the moon to orbit the earth, and for the earth to tilt toward the moon.

Hi guys, thanks for all your replies, but I want to do a 3D one (No, my teacher didn't tell me to do it). This way I can show the earth's tilt in a more easy way.

Right now, I managed to do the sun and the earth; they are working perfectly.

This is the address of what I did so far: http://scratch.mit.edu/projects/jedidiahzhu/2433783

The moon, however, is not cooperating. I have no idea how to make it orbit the earth.

Thanks all!

Offline

 

#5 2012-03-30 09:32:58

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Space

Ah. Interesting idea. You'll have to use a bit of trigonometry: keep incrementing a variable X and set the Earth's X position to sin(x)*100. Then set the moon's X position to X position of Earth + sin (x)*50.

Also, you'll need to constantly use Set X to (X mod 360).

Finally, to counter the layers problem, make sure:

Earth is above Sun when X>180, below at all other times.
Moon is above Earth when X>180, below at all other times.

Last edited by Hardmath123 (2012-03-30 09:36:00)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6 2012-03-30 12:21:09

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Space

Hardmath123 wrote:

Much easier way:

when gf clicked // in sun sprite
go to x:(0) y:(0)

when gf clicked // in earth/moon sprite
go to x:(0) y:(100)
set [n v] to (0)
forever
clear
change [n v] by (1)//replace 1 with desired orbit speed for moon.
point towards [sun v]
turn ccw (87) degrees
move (5) steps
switch to costume [earth v]
stamp
change x by (([sin v] of (n)) * (50))//replace 50 with the desired orbit radius of the moon
change y by (([cos v] of (n)) * (50))
switch to costume [moon v]
stamp
change x by (([sin v] of (n)) * (-50))//remember, -50 not 50
change y by (([cos v] of (n)) * (-50))
Of course, these orbits are circular. In reality, the orbits are elliptical, but I'm sure you math teacher isn't that mean. Anyway, enjoy this script, it's fun to watch!

If your math teacher asks, by the way, say, "It is based on the principal that a tangent to a circular orbit will be perpendicular to the corresponding radius; and plotting all solutions of cos(arcsin(x)) returns a circle."
Memorize it. That ought to stun him!

Not quite....needs to be set x/y to not change x/y by.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#7 2012-03-30 12:49:27

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Space

AtomicBawm3 wrote:

Hardmath123 wrote:

Much easier way:

when gf clicked // in sun sprite
go to x:(0) y:(0)

when gf clicked // in earth/moon sprite
go to x:(0) y:(100)
set [n v] to (0)
forever
clear
change [n v] by (1)//replace 1 with desired orbit speed for moon.
point towards [sun v]
turn ccw (87) degrees
move (5) steps
switch to costume [earth v]
stamp
change x by (([sin v] of (n)) * (50))//replace 50 with the desired orbit radius of the moon
change y by (([cos v] of (n)) * (50))
switch to costume [moon v]
stamp
change x by (([sin v] of (n)) * (-50))//remember, -50 not 50
change y by (([cos v] of (n)) * (-50))
Of course, these orbits are circular. In reality, the orbits are elliptical, but I'm sure you math teacher isn't that mean. Anyway, enjoy this script, it's fun to watch!

If your math teacher asks, by the way, say, "It is based on the principal that a tangent to a circular orbit will be perpendicular to the corresponding radius; and plotting all solutions of cos(arcsin(x)) returns a circle."
Memorize it. That ought to stun him!

Not quite....needs to be set x/y to not change x/y by.

Oops. Error in copying the blocks, my bad...

EDIT: No, it should be change. Try it out yourself! So, not my mistake!  big_smile

Last edited by Hardmath123 (2012-03-30 12:52:35)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#8 2012-03-31 00:36:45

jedidiahzhu
Scratcher
Registered: 2011-01-16
Posts: 85

Re: Space

Hardmath123 wrote:

Ah. Interesting idea. You'll have to use a bit of trigonometry: keep incrementing a variable X and set the Earth's X position to sin(x)*100. Then set the moon's X position to X position of Earth + sin (x)*50.

Also, you'll need to constantly use Set X to (X mod 360).

Finally, to counter the layers problem, make sure:

Earth is above Sun when X>180, below at all other times.
Moon is above Earth when X>180, below at all other times.

Huh. No idea what you're talking about, but thanks! XD I'll try it.

when gf clicked
go to [computer v]
broadcast [post new topic on forum v]
wait until <(reply?)=[true]>
think [Read reply] for (2) secs
wait until <(finished reading?)=[true]>
say [HUH?!]

Last edited by jedidiahzhu (2012-03-31 00:40:26)

Offline

 

Board footer