Discuss Scratch

drf341
Scratcher
9 posts

Doing math

Hello
I am trying to create a module for a geometry class that looks at volume of 3d shapes. I am first having students build a cube, a prism, and a cylinder in scratch. So far that has worked out. However i want them to create a program in Scratch that will measure the volume of the shape that they just built. I have no idea how to do this operation using the existing blocks. I have the code for the cube if anyone can help.
Thanks
awesome-llama
Scratcher
1000+ posts

Doing math

How did your students build the objects? If it was done in pen, you can probably try to extract the coordinates of each vertex, and calculate the formula for each 3d shape with it.
asivi
Scratcher
1000+ posts

Doing math

Is this about nesting operators?
gtoal
Scratcher
1000+ posts

Doing math

if you are talking about actually measuring volumes and comparing to what is calculated by formula, clearly you can't do that in a 2D system. You would be able to measure areas that way by counting pixels (though that is expensive to do in Scratch) but it doesn't extend to 3D as Scratch doesn't support voxels. Maybe try this with the woodwork class teacher instead? - carve a model and measure volume by water displacement..?
drf341
Scratcher
9 posts

Doing math

I just want to find a way for them to use the formula base*width*height, pi*r^2*height/ and 1/2 height*width*length in scratch. The outcome that would be best is if they can store a length as x, a width as y and a height as z and then use some operation to multiply them.
ie.
using move blocks
1. start at x=-100 and y=-100 facing east (left):
2. move 100 units : note that this is a width measurement so i would like to store this as y
3. turn pi/2 units right : note this makes the sprite face up
4. move 100 units : note this is a height measurement so i would like to store this as a z
5. turn some degree to the left : note this move the sprite into the xz plane
6. move 100 units: note this is a length movement so i would like to store this as a x
7.-n. move/turn blocks to complete the shape
n+1. operation x*y*z
n+2. output operation n+1.
This is how i would imagine the code in scratch going but I am so unfamiliar with scratch to know if it will work. Like I said before I know the shape comes out, I don't know how to store the variables or the operations block to make it work.





footsocktoe
Scratcher
1000+ posts

Doing math

drf341 wrote:

I just want to find a way for them to use the formula base*width*height, pi*r^2*height/ and 1/2 height*width*length in scratch. The outcome that would be best is if they can store a length as x, a width as y and a height as z and then use some operation to multiply them.
ie.
using move blocks
1. start at x=-100 and y=-100 facing east (left):
2. move 100 units : note that this is a width measurement so i would like to store this as y
3. turn pi/2 units right : note this makes the sprite face up
4. move 100 units : note this is a height measurement so i would like to store this as a z
5. turn some degree to the left : note this move the sprite into the xz plane
6. move 100 units: note this is a length movement so i would like to store this as a x
7.-n. move/turn blocks to complete the shape
n+1. operation x*y*z
n+2. output operation n+1.
This is how i would imagine the code in scratch going but I am so unfamiliar with scratch to know if it will work. Like I said before I know the shape comes out, I don't know how to store the variables or the operations block to make it work.

Look in the green blocks for the math blocks.
Variables are stored automatically, but not from one opening of the project to the next unless you use the “cloud” version of a variable.

If you want to save a move as a variable then don't use the move blocks. Instead use the change x and change y blocks.

From your description above you are still trying to think in 3D and it's a 2D screen. If you just want them to use the formula then why don't you just code the formula? If they need an illustration you can upload some or draw them in the Scratch editor.


asivi
Scratcher
1000+ posts

Doing math

The project's creator is who must stablish the measure's units and the values for each dimension.
drf341
Scratcher
9 posts

Doing math

I don't think you guys are getting what I am asking and that's fine, thanks for trying. I figured it, now i just need to figure out how to print the answer.
asivi
Scratcher
1000+ posts

Doing math

Great! Congrats! have a nice day.
gtoal
Scratcher
1000+ posts

Doing math

drf341 wrote:

I don't think you guys are getting what I am asking and that's fine, thanks for trying. I figured it, now i just need to figure out how to print the answer.
I think I understand what you want to do. You want to draw a 3d object by using a virtual 3d turtle and then magically have the system tell you the volume of the object you outlined. Well, you can't. You can calculate the volume using the appropriate formulae but there is no analogue measuring equivalent available as a cross-check.

The closest you might come is to slice the object in one plane and add up the areas of the 2D slices multiplied by the depth of the slices. This will of course be an approximation, much like applying Simpson's rule to a curve.
drf341
Scratcher
9 posts

Doing math

If you would like to see what i was trying to do I posted the project. It creates a cube of variable size then spits out the volume using Base*Width*Height. I even got it to print out sets of cubes in both the vertical and horizontal direction plus it gives the volume. This was a proof of concept that I can have students use, and it can be done. I also created a cylinder, and though I have not applied the math I will eventually.
gtoal
Scratcher
1000+ posts

Doing math

drf341 wrote:

If you would like to see what i was trying to do I posted the project. It creates a cube of variable size then spits out the volume using Base*Width*Height. I even got it to print out sets of cubes in both the vertical and horizontal direction plus it gives the volume. This was a proof of concept that I can have students use, and it can be done. I also created a cylinder, and though I have not applied the math I will eventually.

Originally you said “However i want them to create a program in Scratch that will measure the volume of the shape that they just built.”. If all you really want to do is just draw the shapes and calculate the volume mathematically from the various formulae for solid objects, then I'm not really sure what help you are asking for except perhaps a little help with better drawings. Calculating pi*r^2*h shouldn't be that hard, but I can see that drawing a cylinder in perspective (or even half-decent isometric projection) might be a bit tricky if you're new to Scratch.

It's not the coding we're having trouble with in helping you out, it's understanding precisely what sort of help it is you're asking for.

My guess is you want something like this? https://scratch.mit.edu/projects/164499059/

Last edited by gtoal (June 3, 2017 22:20:34)

drf341
Scratcher
9 posts

Doing math

Yes, that linked project was what I was looking for. The drawing does not matter as long as the math works. The problem was I did not know how to declare variables in scratch, nor did I know how scratch uses those variables to do the math and display the outcomes. I program in C++ and Python, but we can't teach every kid those just to aid geometry but scratch looks promising. So I am testing ideas. I appreciate the help, and if you have any other ideas please share them.
gtoal
Scratcher
1000+ posts

Doing math

drf341 wrote:

Yes, that linked project was what I was looking for. The drawing does not matter as long as the math works. The problem was I did not know how to declare variables in scratch, nor did I know how scratch uses those variables to do the math and display the outcomes. I program in C++ and Python, but we can't teach every kid those just to aid geometry but scratch looks promising. So I am testing ideas. I appreciate the help, and if you have any other ideas please share them.
Unfortunately displaying text (or numbers) nicely in Scratch turns out to be an advanced topic. The method I used was a lot simpler but not very attractive: the orange boxes are effectively a debug mechanism where Scratch itself shows the values of variables directly. (They're called ‘reporters’ in Scratch speak I think)

You'll pick up Scratch soon enough - once you can relate it to how things are done in real programming languages like you're used to, it'll start falling into place rapidly.

Quickest way for an experienced programmer to learn is use the search engine to find related programs and pore over their internal code. Fortunately the design of the Scratch environment is centered around all the sources being accessible to everyone (with the ‘look inside’ button)

Some of it is non-intuitive at first if you already have programming experience - paradoxically the kids who have none usually get into it faster than those of us with some decades of coding behind us! But very soon you'll hit a threshold point where it all makes sense (at which point you get a bit annoyed at some of the limitations now you understand what they are) but work through that and it'll become fun again as you take it as a challenge to outwit Scratch's limitations :-) There are a few old hands such as Griffpatch and TheLogFather who've made a career out of not letting Scratch's limitations defeat them :-) (I give those names as examples of people whose code is worth studying once you get past the basics; until you get there, users like deck26 and drmcw are probably better examplars to study, as their code is aimed at teaching new users and does things sensibly but without extreme trickery)
drmcw
Scratcher
1000+ posts

Doing math

(They're called ‘reporters’ in Scratch speak I think)
They're called monitors. Reporters are blocks that return values.
gtoal
Scratcher
1000+ posts

Doing math

drmcw wrote:

(They're called ‘reporters’ in Scratch speak I think)
They're called monitors. Reporters are blocks that return values.
thanks, I was always a bit unsure about that.

Powered by DjangoBB