views:

244

answers:

3

Does anyone have some useful beginner tutorials and code snippets for playing with basic geometric shapes and geometric proofs in code?

In particular something with the ability to easily create functions and recursively draw them on the screen. Additional requirements, but not absolute, support for Objective-C and basic window drawing routines for OS X and Cocoa.

A specific question how would one write a test to validate that a shape is in fact a square, triangle, etc. The idea being that you could draw a bunch of shapes, fit them together and test and analyze the emergent shape that arises from the set of sub shapes.

This is not a homework question. I am not in school. Just wanted to experiment with drawing code and geometry. And looking for an accessible way to play and experiment with shapes and geometry programming.

I am open to Java and Processing, or Actionscript/HaXe and Flash but would also like to use Objective C and Xcode to build projects as well.

What I am looking for are some clear tutorials to get me started down the path.

Some specific applications include clear examples of how to display for example parts of a Cantor Set, Mandelbrot Set, Julia set, etc...

One aside, I was reading on Wikipedia about the "Russell's Paradox". And the wiki article stated:

Let us call a set "abnormal" if it is a member of itself, and "normal" otherwise. For example, take the set of all squares. That set is not itself a square, and therefore is not a member of the set of all squares. So it is "normal". On the other hand, if we take the complementary set that contains all non-squares, that set is itself not a square and so should be one of its own members. It is "abnormal".

The point about squares seems intuitively wrong to me. All the squares added together seem to imply a larger square. Obviously I get the larger paradox about sets. But what I am curious about is playing around with shapes in code and analyzing them empirically in code. So for example a potential routine might be draw four squares, put them together with no space between them, and analyze the dimensions and properties of the new shape that they make.

Perhaps even allowing free hand drawing with a mouse. But for now just drawing in code is fine.

+1  A: 

I highly recommend NeHe for any beginner OpenGL programmer, once you complete the first few tutorials you should be able to have fun with geometry any way you want.

Hope that helps

Maciek
Thanks. The tutorials look useful. I will check them out.
Gordon Potter
OpenGL is all about drawing very primitive objects. This is probably not what you want. Are you looking for writing an application similar to Kig? http://edu.kde.org/kig/screenshots.php
drhirsch
+2  A: 

I guess OpenGL might not be the best starting point for this. It's quite low-level, and you will have to fight with unexpected behavior and actual driver issues. If you emphasize the "playing" part, go for Processing. It's a programming environment specifically designed to play with computer graphics.

However, if you really want to take the shape testing path, an in-depth study of computer vision algorithms in inevitable. On the other hand, if you just want to compare your shapes to a reference image, without rotation, scaling, or other distortions, the Visual Difference Predictor library might help you.

Malte Clasen
+4  A: 

If you're willing to use C++ I would recommend two libraries:

boost::GGL generic geometry library handles lots of geometric primitives such as polygons, lines, points, and so forth. It's still pretty new, but I have a feeling that it's going to be huge when it's officially added into boost.

CGAL, the Computational Geometry Algorithms Library: this thing is huge, and will do almost anything you'll ever need for geometry programming. It has very nice bindings for Qt as well if you're interested in doing some graphical stuff.

bstamour