So for this week, I had some problems with the tutorial. Again, let me reiterate, I'm no pro at computer science, but I'm trying!
Specifically, I had problems with question 8.23 in our 'textbook' Picturing Programs. The question was to
make an animation of a picture on a white background (200x200) that would always have the y coordinate of 50 with a changing x variable.
So, I had a little bit of an idea of how to get started.
First I would need to define a function that puts an image on top of another image at a specific coordinate. And given the hint from the tutorial handout, this function would be 'place-image'.
My first attempt on DrRacket was this:
(define picture x-coordinate (place-image pic:hacker
x-coordinate 50
(rectangle 200 200 "solid" "white")))
(big-bang 10
(check-with number?)
(on-draw picture x-coordinate)
...And well it failed. The error message was: define: expected only one expression after the variable name picture, but found 1 extra part
You know, I don't know if it's just me but sometimes I wish the computer can talk more explicitly...
Anyways, I think the problem is that I need to let DrRacket know that I want the x-coordinate to represent, well, the x-coordinate. I went about many different ways and failed. So on Wednesday I went to ask my TA for help.
I didn't bring my attempted solution to the tutorial...and when my TA helped me, the animation worked... I didn't understand why I couldn't get it with my solution when it was essentially the same idea... until I got home and compared the TA's solution to mine and I realized I was missing a bracket. Really, a bracket?
So here's the TA's solution (with just the added brackets...)
(define (picture x-coordinate) (place-image pic:hacker
x-coordinate 50
(rectangle 200 200 "solid" "white")))
(big-bang 10
(check-with number?)
(on-draw picture)
(on-tick add1 1))
Well of course, the lesson isn't just that I need to be more careful with brackets but that this bigbang function is quite versatile and that defining a function before usiong bigbang can add much more dimension to the animation.
Friday, October 26, 2012
Friday, October 19, 2012
The Difficulties of Folding Paper
So we had our tutorial this week and there was section dedicated to folding paper. At first, I was wondering whether I'm enrolled in a computer science course. But it seems that paper folding or the crease patterns in paper folding has an awful lot to do with algorithms, which seems to be at the core of computer science (which I do hope to learn about in the following weeks).
Below is my attempt to discover the algorithm in knowing the crease patterns of folding paper.
Vertex pointing up = +
Vertex pointing down = -
The above was how I sorted out what crease patterns and how many creases there were per fold. The easiest to figure out was the number of creases just by staring at the numbers, which is 2n + 1 where 'n' is the number of folds. And it was also notable that '-' was always is in the centre
I had a few theories when I was comparing my second and third fold, but those theories fell apart when I reached by fourth fold.
Here was one of my theories that fell apart:
I'm not sure whether this is the simplest way to go about it, but for now this is my solution.
Below is my attempt to discover the algorithm in knowing the crease patterns of folding paper.
Vertex pointing up = +
Vertex pointing down = -
First Fold - 1
Second Fold + - - 3
Third Fold + + - - + - - 7
Fourth Fold + + - + + - - - + + - - + - - 15
I had a few theories when I was comparing my second and third fold, but those theories fell apart when I reached by fourth fold.
Here was one of my theories that fell apart:
- For the third fold, if we were start from the middle and compare what was on the right side to the left side, the signs were opposite of each other. At first there was one positive on the right side, and one negative on the left side. When we moved down more, the right side had 2 negative signs which is complementary to the 2 positive signs on the left. So as we move down from the middle, the signs alternate, and the number of each signs' occurrence increases by one, starting from the central '-'. Now this fold compared to the second fold was also opposite in signs to what was immediately beside the central '-'. This led to to hypothesize that the fourth folds would have a pattern like this: + - - + + - + - - + - - + + -. However this pattern is completely off from reality. Firstly, the immediate right and left signs of the central '-' is the opposite of what the third fold had. So, I needed a new hypothesis.
+ + - + + - - + + + - - + - - - + + - + + - - - + + - - + - -
The actual result (which really tested my fine motor skills):
was what I predicted! Tadah!
- The first fold will always be '-' which would always be in the center of subsequent folds
- The next fold will contain the pattern of the immediate previous fold's pattern on the right side of the central '-'
- On the left side of the '-' on the same fold (as 2), the pattern would be the opposite as the right side as the folds travel down from the middle towards the end
Monday, October 8, 2012
Bit
Like many, I am a frequent internet/computer user. However, I am a complete amateur in computer science. The simplest things seem to have bogged me down from the start and this simple thing I'm referring to is bits. Yes, bits.
I could not understand why 1+1=0 and then there was this whole 'carry 1' issue...
So after the lecture, I went home and searched how to add bits. Only after reading a few links and watching some YouTube videos (you see, I'm a visual learner), I was able to sort of get the hang of adding with bits. I looked back at my notes that I took from class, and what the professor did in class wasn't so confusing anymore. I only understood it completely after I've done several practice problems on my own without having to peak at the answer.
So now I have realized that bit is indeed a simple thing.
P.S. I am very glad I managed to understand bits before the next lecture came around because I would have been thoroughly confused when multiplication, adding negative numbers and fractions came about.
Edit: Here are some of the links I've used that were helpful:
http://academic.evergreen.edu/projects/biophysics/technotes/misc/bin_math.htm#addThis also helped me understood more on how to convert bit numbers to real numbers (that we use daily) as well as how to add them
http://www.youtube.com/watch?v=sFd5bnDdB3Q
The first minute of this video explained (really simply) on how to add bits
I could not understand why 1+1=0 and then there was this whole 'carry 1' issue...
So after the lecture, I went home and searched how to add bits. Only after reading a few links and watching some YouTube videos (you see, I'm a visual learner), I was able to sort of get the hang of adding with bits. I looked back at my notes that I took from class, and what the professor did in class wasn't so confusing anymore. I only understood it completely after I've done several practice problems on my own without having to peak at the answer.
So now I have realized that bit is indeed a simple thing.
P.S. I am very glad I managed to understand bits before the next lecture came around because I would have been thoroughly confused when multiplication, adding negative numbers and fractions came about.
Edit: Here are some of the links I've used that were helpful:
http://academic.evergreen.edu/projects/biophysics/technotes/misc/bin_math.htm#addThis also helped me understood more on how to convert bit numbers to real numbers (that we use daily) as well as how to add them
http://www.youtube.com/watch?v=sFd5bnDdB3Q
The first minute of this video explained (really simply) on how to add bits
Subscribe to:
Posts (Atom)