Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 14th, 2006, 6:50 AM   #1
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
New programming challenge

Write a program to emulate a Spirograph. A Spirograph consists of two circles (gears, if you will), one inside the other. The inner circle rolls around the circumferance of the outer circle. A pen is attached at any point on the inner circle and traces a path as the circle rolls. The pattern will vary according to the diameter of the circles and the placement of the pen. You will need a couple of formulae for this one, but they're not tough.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 14th, 2006, 6:54 AM   #2
bivhitscar
Hobbyist Programmer
 
bivhitscar's Avatar
 
Join Date: Oct 2005
Location: Melbourne, Australia
Posts: 126
Rep Power: 3 bivhitscar is on a distinguished road
Interesting, though I have zero gui experience and I doubt this will work in a console window.
__________________
it's ironic considerate rarity patron of love higher knowledge engulfs me...
bivhitscar is offline   Reply With Quote
Old Jun 14th, 2006, 7:06 AM   #3
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,005
Rep Power: 5 lectricpharaoh will become famous soon enough
Spirograph, yeah, I had one of those as a kid. I only have one idea for emulating it, but it probably won't go anywhere, but we'll see if I can cobble something together.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Jun 14th, 2006, 10:22 AM   #4
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
there's a function for this, usually defined parametrically...trying to remember the name...CYCLOID!!! that's it!

x = a(t-sin(t))
y = a(1-cos(t))

this is an equation for the inner wheel travelling along a straight path, it just needs to be put inside of a circle...
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Jun 14th, 2006, 10:49 AM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Actually, the principal can be applied with the rolling gear either inside or outside the other gear. One would either add or subtract the radii, depending, before applying the transformation. All the ones I ever owned, however, had the rolling gear inside. Transformation from the straight-line case to the circular case merely means including the radius of the outer gear in the calculations involving the angle. While this requires some thought before hitting the keyboard, I'm sure it's far simpler than producing a 3-D killer game app in three weeks, with so little effort involved that one can release it at no charge (or with such a high chance of success that one can get others to do it on spec). Just a thought, of course; absorption of craft might work by osmosis if one sacrifices enough chickens.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 14th, 2006, 11:32 AM   #6
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 751
Rep Power: 3 Jimbo is on a distinguished road
Quote:
Originally Posted by bivhitscar
Interesting, though I have zero gui experience and I doubt this will work in a console window.
you need practice with ASCII art, obviously...

looks like another interesting one DaWei...
Jimbo is offline   Reply With Quote
Old Jun 14th, 2006, 7:43 PM   #7
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,005
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by DaWei
producing a 3-D killer game app in three weeks, with so little effort involved that one can release it at no charge (or with such a high chance of success that one can get others to do it on spec).
Hehehe. This almost had me making a tongue-in-cheek want ad post in the job offers forum so I could watch splinter9x and hervens48 fight for 'alpha dog' position.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Jun 14th, 2006, 8:03 PM   #8
bivhitscar
Hobbyist Programmer
 
bivhitscar's Avatar
 
Join Date: Oct 2005
Location: Melbourne, Australia
Posts: 126
Rep Power: 3 bivhitscar is on a distinguished road
Quote:
Originally Posted by Jimbo
you need practice with ASCII art, obviously...
Indeed I do. Though, it would probably take me months to get the art down, while the algorithm sits unused.
__________________
it's ironic considerate rarity patron of love higher knowledge engulfs me...
bivhitscar is offline   Reply With Quote
Old Jul 7th, 2006, 1:44 PM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
No takers. Well, here's one written in Python, using Boa Constructor and wxWidgets.




Code attached.
Attached Files
File Type: zip Spiro.zip (3.6 KB, 33 views)
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 7th, 2006, 2:01 PM   #10
Zap
Guest
 
Posts: n/a
I don't know enough about spirographs to do this... Besides, I really don't know much about windows graphics, yet. I wanted to master controls first. I'll learn, though...
  Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:22 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC