D
Daniel Moore
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
The three rules of Ruby Quiz:
1. Please do not post any solutions or spoiler discussion for this
quiz until 48 hours have elapsed from the time this message was
sent.
2. Support Ruby Quiz by submitting ideas and responses
as often as you can! Visit: <http://rubyquiz.strd6.com>
3. Enjoy!
Suggestion: A [QUIZ] in the subject of emails about the problem
helps everyone on Ruby Talk follow the discussion. Please reply to
the original quiz message, if you can.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Mathematical Image Generator (#191)
This week's quiz is about the generation of images based on
mathematical functions. The red, green, and blue values at each point
in the image will each be determined by a separate function based on
the coordinates at that position.
Here are some functions to get started:
Math.sin(Math:I * ?)
Math.cos(Math:I * ?)
(? + ?)/2
? * ?
(?) ** 3
The question marks represent the parameters to the functions (x, y, or
another function). The x and y values range between 0 and 1: the
proportion of the current position to the total width or height.
Feel free to add your own functions, but keep in mind that they work
best when the inputs and output are between -1 and 1.
Example Output:
http://strd6.com/?attachment_id=145
depth: 3
red: Math.sin(Math:I * Math.cos(Math:I * y * x))
green: Math.sin(Math:I * (Math.sin(Math:I * y)) ** 3)
blue: (Math.cos(Math:I * Math.cos(Math:I * y))) ** 3
The depth is how many layers of functions to combine. The bottom layer
is always x or y. Depth 3 is where things begin to get a little bit
interesting, but 5 and higher is much more exciting.
Performance can be an issue with so many computations per pixel,
therefore the solution that performs quickest on a 1600x1200 image
with depth of 7 will be the winner of this quiz!
Good luck!
The three rules of Ruby Quiz:
1. Please do not post any solutions or spoiler discussion for this
quiz until 48 hours have elapsed from the time this message was
sent.
2. Support Ruby Quiz by submitting ideas and responses
as often as you can! Visit: <http://rubyquiz.strd6.com>
3. Enjoy!
Suggestion: A [QUIZ] in the subject of emails about the problem
helps everyone on Ruby Talk follow the discussion. Please reply to
the original quiz message, if you can.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Mathematical Image Generator (#191)
This week's quiz is about the generation of images based on
mathematical functions. The red, green, and blue values at each point
in the image will each be determined by a separate function based on
the coordinates at that position.
Here are some functions to get started:
Math.sin(Math:I * ?)
Math.cos(Math:I * ?)
(? + ?)/2
? * ?
(?) ** 3
The question marks represent the parameters to the functions (x, y, or
another function). The x and y values range between 0 and 1: the
proportion of the current position to the total width or height.
Feel free to add your own functions, but keep in mind that they work
best when the inputs and output are between -1 and 1.
Example Output:
http://strd6.com/?attachment_id=145
depth: 3
red: Math.sin(Math:I * Math.cos(Math:I * y * x))
green: Math.sin(Math:I * (Math.sin(Math:I * y)) ** 3)
blue: (Math.cos(Math:I * Math.cos(Math:I * y))) ** 3
The depth is how many layers of functions to combine. The bottom layer
is always x or y. Depth 3 is where things begin to get a little bit
interesting, but 5 and higher is much more exciting.
Performance can be an issue with so many computations per pixel,
therefore the solution that performs quickest on a 1600x1200 image
with depth of 7 will be the winner of this quiz!
Good luck!