Showing posts with label Sketch. Show all posts
Showing posts with label Sketch. Show all posts

June 10, 2011

Angle Reference Circle in Processing

When I think back to trig, I seam to remember 0 degrees always being horizontal and to the right of the center. That turns out to be pretty arbitrary. Different programming languages tend to have different ideas about what angle is considered 0. It's not a problem, just something you need to know in order to get the angels your expecting. The following image is of a sketch I made in Processing to show what it considers 0. Turns out it's down and vertical. I went ahead and made the whole circle with some tick marks for practice. The labels show the angle in both degrees and radians. The lines in the center are random, the numbers on them just show the order in which they were created. The code to create them later served as the base for the branches in the random recursion tree from my last post.
I made a screen shot and used it as a reference to help visualize angles while programming but without the overhead of having a Processing sketch running. Perhaps it could be useful to someone else as well. If someone wants a cleaner version without the center lines, let me know and i will add it. Or just make your own. Here is the code I used, simplified a bit though so it just draws the main circle with tick marks and labels but does not put those random lines in the center.


May 31, 2011

Random Recursion Tree

One of my favorite things about programming is all the interesting mistakes along the way. Here are a few screenshots during my progress towards creating a tree using recursion.
      

This one was my favorite. I just wanted to print the angles at each vertex. I forgot to dial down the number of branches and was presented this awesome number tree.


At this point I more or less had it working. I still plan to do more but here are a few shots of a working randomly generated tree using recursion.