Page 1 of 2

Double Origin Graphing

Posted: Thu Apr 15, 2010 5:14 am
by Geti
I graphed a = 2b:
Image
So I was in a lecture about maths a few days ago and heard about these wacky things called Double Origin Graphs, where there are two origins (funnily enough) and each point on the graph is defined by the angle between each point (eg 1,2) would be a point 1 rad from origin 1 and 2 rads from origin 2. "linear functions" in this coordinate system are to the form a = nb+c, where a is angle from O1, b is angle from O2, n is any real number and c is a constant (also any real number), and come out as crazy patterns.
Anyway, I decided to create something to draw graphs for double origin coordiant systems.

Currently this project doesnt do recursion (and it should, as the graphs get way more funky as the revolutions tick on), or constants (which it also should, but i was neglectful). It graphs a function not as a line but as a cloud. I did this because drawing lines is for pansies and real men like their graphs with a healthy spattering of dithered neon glow, but mostly cause line drawing wasn't working , and it looked cooler this way anyway.
Oh yeah, drawing is broken when O2 is under and to the left of O1. You'll get a nice black area between them.

Anyone wanting to get recursion going, fix the draw function or put in a line drawing mode, be my guest.

EDIT: oh yeah, quick note, there's no real text editing and I didn't put error handling in. don't try and go ahead with NaNs in the fields, it doesn't like that.

DROPBOX HERE

Re: Double Origin Graphing

Posted: Thu Apr 15, 2010 7:29 am
by kikito
I don't understand any of the maths behind it, but it is interesting nonetheless.

Any chance of using colors instead of shades of gray?

Re: Double Origin Graphing

Posted: Thu Apr 15, 2010 11:21 am
by Geti
Well, yes. Currently it just draws the "cloud" based on how close a is to nb, where a is the angle to origin 1 and b is the angle to origin 2 (n is the coefficient you provide). without recursion, the biggest missing feature, you get no really interesting patterns though. eh.

what would you like for colours? like a gradient or something?

Re: Double Origin Graphing

Posted: Thu Apr 15, 2010 11:25 am
by vrld
That looks really cool!
Never heard of double origin graphs before and a quick google search wasn't very helpful. What are they normally used for? Did you talk about triple origin graphs (then in 3d i think) or even n-origin graphs? Interesting stuff.

Re: Double Origin Graphing

Posted: Thu Apr 15, 2010 12:05 pm
by Geti
We didn't talk about n or 3 origin graphs, it was more a passing reference than a discussion on the coordinate system, more about looking at things differently than anything. I found them pretty interesting though, so i'll probably expand this at some point.

I don't think they're actually used for anything, either. You could probably find uses if you tried. It's just another way of defining a point's location given reference points. you just need 2 of them.

Re: Double Origin Graphing

Posted: Fri Apr 16, 2010 4:25 pm
by Thursdaybloom
This crashes every time I try and use it. As it says generating graph Love closes ad I get the OSX "program has quit unexpectedly" message. Is this just me or have other OSX users had this happen?

Re: Double Origin Graphing

Posted: Fri Apr 16, 2010 7:21 pm
by ChimpNimsky
Thursdaybloom wrote:This crashes every time I try and use it. As it says generating graph Love closes ad I get the OSX "program has quit unexpectedly" message. Is this just me or have other OSX users had this happen?
Me too. OS X 10.5.8 PPC, 0.6.2. Every time.

Re: Double Origin Graphing

Posted: Sat Apr 17, 2010 2:42 am
by bmelts
Yeah. It crashes on my Mac too. Which is a problem, since I'm responsible for the Mac port :ehem:

The issue is easily fixable in the Lua code itself: change the for loops in getgraph to go from 0 to 511, instead of 1 to 512. The changed version is how it should be anyway - graphics origins are generally at (0,0) - as 512 is out of bounds, and thus trying to access it, on Mac OS X at least, causes a segfault. This is probably something that should be checked for by LÖVE - setPixel naively trusts the coordinates it's passed, instead of doing any sort of bounds-checking. The fact that it only crashes on Mac OS X, however, confuses me.

Re: Double Origin Graphing

Posted: Sat Apr 17, 2010 6:32 am
by Geti
Oh. I thought the imagedata coordinates would be consistent with lua's general use of 1 rather than 0 as a starting point, apologies anyone on OSX. I'll update the drop.

Re: Double Origin Graphing

Posted: Sat Apr 17, 2010 7:00 am
by bartbes
You never noticed the window starts at (0,0) as well?