code logs -> 2009 -> Thu, 17 Sep 2009< code.20090916.log - code.20090918.log >
--- Log opened Thu Sep 17 00:00:09 2009
--- Day changed Thu Sep 17 2009
00:00
<@ToxicFrog>
http://www.funkyhorror.net/toxicfrog/IttToC.djvu
00:00
< Tarinaky>
Thanks.
00:00
<@ToxicFrog>
That should give you the grounding you need to tackle the Dragon Book.
00:02
<@ToxicFrog>
Feel free to ask about anything in it that I remember~
00:02
<@ToxicFrog>
...which, rereading the table of contents, should be most of it
00:03
< Derakon[work]>
Anyone willing to take a look at my "calculate the rotation needed to align two congruent triangles" function? http://paste.ubuntu.com/272406/
00:03
< Derakon[work]>
Hm, bestA1Point and bestA2Point are unused. *deletes*
00:05
< Derakon[work]>
...oh, wait, found it!
00:05
< Derakon[work]>
This is one place where I'd forgotten that all of my coordinates for this program are stored as (y, x) because that's the order they're given in the numpy data.
00:05
< Derakon[work]>
So my arguments to atan2 were reversed.
00:11
< Derakon[work]>
...except that now my results look worse. >.<
00:13
< Derakon[work]>
Ah hah, sign problem.
00:19 You're now known as TheWatcher[T-2]
00:22 You're now known as TheWatcher[zZzZ]
00:22
< Derakon[work]>
...ah hah, that's possibly the cause of my problem here. I'm finding congruent but flipped triangles.
00:22
< Derakon[work]>
No amount of rotation and translation is going to get those to align!
00:23
< Derakon[work]>
Not in 2D, anyway.
00:42
< Derakon[work]>
Yeah, there we go. Much better.
00:42
< Nathia>
http://bash.org/?630836
00:47 Derakon[work] [Derakon@Nightstar-d44d635e.ucsf.edu] has quit [[NS] Quit: Leaving]
00:52 AnnoDomini [farkoff@Nightstar-ac75753b.adsl.tpnet.pl] has quit [[NS] Quit: God created man, God created woman, but Samuel Colt made them equal.]
01:01 Orthia is now known as Reivthia
01:21 Derakon[AFK] is now known as Derakon
01:24
< Nathia>
CTCP VERSION reply from Khaled: eggdrop v1.6.15
02:00
< Tarinaky>
ToxicFrog: Having gone over the section on Finite Automata there doesn't seem to be anything vital the Dragon Book didn't cover but I'm still confused as to how I'm supposed to implement a NFA/DFA as an actual set of functions.
02:01
< Tarinaky>
Sorry, by functions I mean part of a program.
02:01
< Tarinaky>
Or simulate one would probably be a better way of phrasing it to.
02:09
< Nathia>
http://mibbit.com/pb/zpLtut
02:10
< Tarinaky>
:o
02:11
< McMartin>
Tarinaky: Is this a new project or part of your current one?
02:12
< Nathia>
http://bash.org/?759408
02:12
< Tarinaky>
Current one.
02:12
< Tarinaky>
It's worth stressing that in terms of lines of code I've made absolutely no net progress on my current progress >.>
02:12
< Tarinaky>
But hey. I know more than I did yesterday.
02:12
< Tarinaky>
>.>
02:14
< McMartin>
http://pastebin.starforge.co.uk/20 is a basic class interface for a character-based FSM.
02:14
< McMartin>
DFA or NFA.
02:15
< McMartin>
That said, this is the kind of thing that you should be using under the hood if you're writing a parser. You shouldn't be using it yourself.
02:16
< Tarinaky>
Well... I couldn't get flex and bison to behave and I think someone told me I should just do it from nothing :|
02:18
< McMartin>
Flex it'll probably be easier to get to behave than to do it on your own, for your task
02:19
< McMartin>
That said, building an FSM is good practice.
02:19
< McMartin>
If you hand-roll a parser though, you will not be hand-rolling a PDA. You should instead use recursive descent.
02:20
< Tarinaky>
Well... I did spend/lose about a week trying to get flex to work and it still hated me -.-
02:27 * gnolam has to try hard to not read "FSM" as "Flying Spaghetti Monster".
02:28
< McMartin>
I consider that an added bonus, really.
02:28
< Derakon>
Gnolam: http://jetbladeproject.blogspot.com/2009/08/fsm-isnt-just-spaghetti-monster.html
02:28
< gnolam>
There should really be a cog psych term for that sort of thing - abbreviations that take precedence over others in your mind.
02:29
< Tarinaky>
Homonym?
02:30
< gnolam>
Derakon: I know what a finite state machine is, and I know it's usually shortened to "FSM", but I can't help mentally expanding it to "Flying Spaghetti Monster" every time.
02:30
< Derakon>
Gnolam: yeah, I was just pointing out that I'd used the same idea in a blog post.
02:31
< Derakon>
Did you see the title?
02:31
< gnolam>
Tarinaky: They are homonyms, but there should be a term for /preferred/ meanings.
02:32
< Tarinaky>
Like... some sort of Preferred Homonym?
02:34
<@Kazriko>
freudian homonym?
02:35
< gnolam>
It either needs to be something snappy or something like "the McKennas-Mueller Precedence Model". The latter would of course have to make unsubstantiated assumptions on why it works as it does, and succumb to the reification fallacy every now and then.~
02:35
< gnolam>
Derakon: Yah
02:38 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has quit [[NS] Quit: Z?]
02:42
<@ToxicFrog>
Tarinaky: what kind of problems did you have with flex?
02:44
< Tarinaky>
Largely problems of documentation combined with issues trying to mix C with C++.
02:45
<@ToxicFrog>
Try doing it in pure C to start with.
02:45
<@ToxicFrog>
Simplifies matters greatly.
02:45
< Tarinaky>
ToxicFrog: Well, I got something that worked as a command line app just using Flex and Bison on their own.
02:45
< Tarinaky>
The problem is I had no idea how to integrate that into an actual program as a whole.
02:46 * Tarinaky thinks he might have worked out how to do the nfa and will now go silent for a while.
02:49
<@ToxicFrog>
Typically you start with just a lexer; once you have that you add the parser, but rather than doing the actual computation (as you did in the calculator) you assemble data structures.
02:57 Nathia [c0cb88fe@Nightstar-14e5d099.mibbit.com] has quit [[NS] Quit: sotired]
03:13 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has quit [Connection closed]
03:20 Vornicus-Latens [vorn@ServerAdministrator.Nightstar.Net] has quit [[NS] Quit: ]
03:21 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has joined #code
03:21 mode/#code [+o Vornicus] by Reiver
03:25 Attilla [The.Attilla@FBC920.642D35.FA4C32.0AF6BA] has quit [[NS] Quit: ]
04:42 Kazriko [kaz@teela.arkaic.com] has quit [Ping timeout: 121 seconds]
04:44 Kazriko [kaz@teela.arkaic.com] has joined #code
04:44 mode/#code [+o Kazriko] by Reiver
05:04 Syloqs-AFH [Syloq@NetworkAdministrator.Nightstar.Net] has quit [Connection reset by peer]
05:50 Vornicus is now known as Vornicus-Latens
06:39 Derakon is now known as Derakon[AFK]
08:09 AnnoDomini [farkoff@D553D1.3E7B9D.0A0AE4.A40723] has joined #code
08:09 mode/#code [+o AnnoDomini] by Reiver
08:16 GeekSoldier [Rob@Nightstar-89125a7e.ip.cablemo.net] has quit [Ping timeout: 121 seconds]
08:50 AbuDhabi [farkoff@Nightstar-f6416c3d.adsl.tpnet.pl] has joined #code
08:51 AnnoDomini [farkoff@D553D1.3E7B9D.0A0AE4.A40723] has quit [Ping timeout: 121 seconds]
08:54 AbuDhabi is now known as AnnoDomini
08:59 Rhamphoryncus [rhamph@Nightstar-a62bd960.abhsia.telus.net] has quit [Client exited]
09:06 You're now known as TheWatcher
10:43 Attilla [The.Attilla@FBC920.642D35.FA4C32.0AF6BA] has joined #code
10:43 mode/#code [+o Attilla] by Reiver
13:24 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
16:07 NSGuest-48271 [Syloq@NetworkAdministrator.Nightstar.Net] has joined #code
16:15 NSGuest-48271 is now known as Syloqs-AFH
16:16 Syloqs-AFH is now known as Syloqs_AFH
16:16 Syloqs_AFH is now known as Syloqs-AFH
16:17 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has joined #code
16:22 Derakon[work] [Derakon@Nightstar-d44d635e.ucsf.edu] has joined #code
17:00 Rhamphoryncus [rhamph@Nightstar-a62bd960.abhsia.telus.net] has joined #code
17:11
< Derakon[work]>
Okay, time to read up on transformation matrices...
17:12
< Derakon[work]>
I remember roughly how they work, but it's the details that always get me.
18:07 AgentIchiro [Smith@Nightstar-82ad4434.dsl.teksavvy.com] has joined #code
18:07 AgentIchiro [Smith@Nightstar-82ad4434.dsl.teksavvy.com] has quit [Connection closed]
18:36 Finale [c0cb88fe@Nightstar-14e5d099.mibbit.com] has joined #code
18:42 Seraph [c0cb88fe@Nightstar-14e5d099.mibbit.com] has joined #code
18:43 Finale [c0cb88fe@Nightstar-14e5d099.mibbit.com] has quit [NickServ (GHOST command used by Seraph)]
18:43 Seraph is now known as Finale
18:55
< gnolam>
... in general, or what kind of transformation?
19:08
< Derakon[work]>
Actually, I backed off of using transformation matrices when I realized that the expected output from this program is in non-matrix form.
19:08
< Derakon[work]>
Which is a bit annoying, but oh well.
19:19
< Namegduf>
Am I going to hell for using tabs in Python?
19:19
< Namegduf>
Because I hate space indented code.
19:20
<@jerith>
Some people use tabs, but PEP-8 recommends against it.
19:21
<@jerith>
If using spaces is a problem, you need a better editor.
19:21
< Namegduf>
Yeah... it's much stronger on "never mix", but says new projects should always use spaces.
19:21
< Namegduf>
It doesn't say *why*, though.
19:21
<@jerith>
Because that's what the standard library uses.
19:22
< McMartin>
And tabs look inconsistent across editors.
19:22
< Namegduf>
Consistent look isn't the point, though.
19:22
<@jerith>
And being consistent in something you cannot see trivially is important.
19:22
< Namegduf>
The look should be tailored to individual preference; I do my editing in an 80 width terminal and like a tab width of four, might decrease it to three or less.
19:23
< Namegduf>
People who edit in larger things might want indent levels of eight.
19:25
<@jerith>
IME, different formatting preferences between developers cannot be fixed by changing tabstops.
19:26
< Namegduf>
Indent size can, and that's the only one which has a legitimate need to vary depending on the size of the editor window.
19:26
<@jerith>
I worked on a project with people who wanted to use tabs instead of spaces.
19:26
<@jerith>
Half the code /they/ committed used spaces.
19:27
< KazWork>
lots of editors swap it to spaces anyway. :)
19:27
< Namegduf>
Evil editors.
19:27
< KazWork>
like Idle.
19:28
< KazWork>
PythonWin actually causes me problems sometimes with its indentions...
19:28
<@jerith>
Every editor I've seen with a halfway-decent Python mode uses four spaces by default.
19:28 * Namegduf is using vim, does not particularly care for a "Python mode".
19:28 * KazWork has started using Eclipse for python...
19:29
<@jerith>
I think vim uses your default indentation settings.
19:29
< McMartin>
vim has all kinds of suport for Python.
19:29
< Derakon[work]>
My vim's set up for four-space tabstops, auto-convert to spaces.
19:30
<@jerith>
(Mine is ":set ts=4 sw=4 et", so I wouldn't know.)
19:30
<@jerith>
That's usually the first thing I type into a strange vi when I want to look at code.
19:30
<@jerith>
Closesly followed by ":syn on"
19:32
<@jerith>
For anything serious I'm generally using The One Editor to Rule Them All.
19:32
< Derakon[work]>
ed?
19:32
< Derakon[work]>
Or perhaps you meant teco?
19:32
<@jerith>
No, that's The Standard Text Editor.
19:33
<@jerith>
The editor I had tentacles surgically attached in order to use more effectively.
19:34
< KazWork>
that operating system that's really cool, if only they made a good editor for it?
19:34
< Namegduf>
The Mozilla Suite of text editors?
19:35
<@jerith>
The editor that has me ripping other software apart in order to turn C-w into "not close the bloody window", even if I cannot make it "kill selected text".
19:35
< Tarinaky>
KazWork: I thought that was emacs?
19:36
<@jerith>
Tarinaky: Emacs is the editor to which I refer. :-)
19:36
< KazWork>
:)
19:36
< Namegduf>
Ah, so I guessed right.
19:36
< Tarinaky>
Ah. I thought we were discussing vi.
19:36
< AnnoDomini>
Where's that text editor comparison picture that Pi did when you need it...?
19:36
< Namegduf>
No, vim is awesome. :P
19:36
< Tarinaky>
http://lca2srv30.epfl.ch/sathe/data/emacs_learning_curves.png << This one?
19:36
<@jerith>
Emacs and vim are both awesome.
19:37
<@jerith>
Emacs fits my brain better, but vi is ubiquitous and requires far less setup.
19:37
< Derakon[work]>
I really like being able to do things like :'a,'bg/print/s/^/#
19:37
< Namegduf>
Vim fits me great.
19:37
< McMartin>
I find it amusing that Vim's wiki is on wikia, which is usually for insane fandoms
19:38
< Derakon[work]>
(If you can't parse that, it operates over a range defined by two previously-set markers a and b, finding lines that contain the text "print" and replacing their beginnings with #.
19:39
< Derakon[work]>
(In other words, it's a quick way to say "Turn debug mode off please")
19:40
<@jerith>
Derakon[work]: emacs lets you evaluate lisp expressions in regex replacements.
19:40
< Namegduf>
I mostly prefer tabs because they're a clean, single meaning, "increase indentation level by one" message.
19:41
< Namegduf>
While spaces don't carry as precise a semantic meaning.
19:41
< KazWork>
jerith: that's why I used VIM on linux, because it's the lazy solution. :)
19:41
< Namegduf>
In the same way use of <p> in HTML is superior to use of <br />.
19:42
< KazWork>
And you can get vi in very tiny versions to fit on gumstix and openwrt systems.
19:42
< Derakon[work]>
Namegduf: I don't think anyone's going to argue with you over this, not because they agree with you, but because tabs vs. spaces is a holy war.
19:42
< Derakon[work]>
Similarly, you aren't going to convince anyone you're right. ;)
19:42
< Namegduf>
Haha, okay.
19:44
<@jerith>
I like the idea of tabs over spaces. Usually, though, spaces are more practical.
19:44
<@jerith>
Consistency beats correctness more often than not.
19:45
< Derakon[work]>
I just really wish that Makefiles didn't insist on tabs.
19:45
<@jerith>
IIRC, make was originally a hack to play with lex/yacc.
19:46
<@jerith>
And by the time he realised tabs were a bad idea, he had about seven users and couldn't change.
19:51
< KazWork>
Heh.
19:55
< SmithKurosaki>
How goes
20:01 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has quit [[NS] Quit: Leaving]
20:01 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has joined #code
21:06 * Derakon[work] tries to figure out why his triangles aren't perfectly aligning.
21:08
< AnnoDomini>
Because they don't use the exact same points on the sides on which they connect?
21:09
< Derakon[work]>
My problem is, given two congruent triangles, to find the transformation that gets one to align with the other.
21:09
< Derakon[work]>
I'm getting very close, but not perfect results.
21:11 * Derakon[work] uploads the script here: http://paste.ubuntu.com/273069/
21:11
< Derakon[work]>
Alignment starts on line 52.
21:12
< Derakon[work]>
This is the kind of result I'm getting: http://derakon.dyndns.org/~chriswei/temp2/triangles.png
21:13
< Derakon[work]>
The red and green triangles are the two original congruent triangles; blue is green, transformed to align with red.
21:13
< Derakon[work]>
I suspect either that I'm applying transformations in the wrong order, or that my calculation of the rotation factor is off somehow.
21:14
< Derakon[work]>
Transformation is done using the transformPoint function; otherwise you should only need to worry about the code in the block starting at 52, and the functions that block calls.
22:24
<@Vornicus-Latens>
Der: are you using a matrix?
22:27
<@Vornicus-Latens>
If not, then I highly suspect your rotation ffactor calculation is off.
22:28
<@Vornicus-Latens>
(honestly, it's a lot easier to use a matrix. your matrix is [[a b c] [d e f] [0 0 1]], and you can solve using equations of the form ax_1 + by_1 + c = x_2 and dx_1 + ey_1 + f = y_2
22:30
<@Vornicus-Latens>
(Get three of these points, and you can use gaussian elimination to get [a b c] [d e f], and then use the matrix that /that/ creates to transform your points.)
22:39
<@Vornicus-Latens>
...Der: it's not immediately clear from that code, how do you throw around points?
22:48
< Derakon[work]>
Sorry, I was AFK.
22:48
< Derakon[work]>
Points are length-two tuples or lists, generally in (y, x) order.
22:48
< Derakon[work]>
Because the data I'm given is in (y, x) order.
22:49
< Derakon[work]>
I'm not using matrices because the expected output is X/Y translation, rotation, and zoom, as separate parameters. I suppose I could separate those out of the matrix when I'm done, though.
23:00
< Derakon[work]>
Re: Gaussian Elimination: these triangles are not exactly congruent; wouldn't that result in an unsolvable matrix?
23:00
< Derakon[work]>
Or is there room to handle fuzz?
23:00
<@Vornicus-Latens>
Gaussian elimination doesn't care.
23:01
<@Vornicus-Latens>
So long as they're both triangles, it will find a solution.
23:01
< Derakon[work]>
I think we can safely rely on our three points forming a triangle. :)
23:02
<@Vornicus-Latens>
Well, not if they're in a straight line. But you can check that.
23:02
< Derakon[work]>
I already have a constraint that no one angle of the triangle exceed 120?.
23:05
<@Vornicus-Latens>
All right then.
23:05 Vornicus-Latens is now known as Vornicus
23:08
< Derakon[work]>
I really wish that people used column-row instead of row-column when indexing into matrices. It makes so much more sense. >.<
23:21
< Derakon[work]>
Oh hey, numpy.linalg.solve() should do the heavy lifting for me.
23:26
<@Vornicus>
Yes, yes it should.
23:37
< gnolam>
Dammit. I'm too impressionable. My first thought when reading the backscroll was "Hey, that would make an excellent GPGPU application..."
23:37
< Derakon[work]>
What, a program that tries to align two images?
23:38
< gnolam>
Yep. :)
23:43
< Derakon[work]>
Okay, I have the Gaussian elimination system generating nearly-precise results...but the triangles still don't align! WTF.
23:44
<@Vornicus>
Are you using the same origin in both steps?
23:44
< Derakon[work]>
Yes; the images are the same size.
23:45
< Derakon[work]>
Re-pasted my code up here: http://paste.ubuntu.com/273148/
23:46
< Derakon[work]>
Looking at the output from the program, it looks like it's rotating in the wrong direction for this particular image set...
23:47
< Derakon[work]>
Oh, wait, no I'm not using the same origin.
23:47
< Derakon[work]>
In the matrix-solve step, the origin's in the upper-left corner. When drawing, it's in the middle. D'oh!
23:54
< Derakon[work]>
Hrm...doesn't seem to have changed anything. Odd.
23:57
<@Vornicus>
...Do me a favor, try changing the order you're doing the solve in.
23:57
<@Vornicus>
instead of filling the matrix from a2 and the vectors from a1, do it the other way around, but don't change anything else.
23:57
< Derakon[work]>
Will do.
23:59
< Derakon[work]>
Better.
23:59
< Derakon[work]>
Lemme run my test suite real quick.
23:59
<@Vornicus>
That Was Right, or THat Is A Bit Of Improvement?
23:59
< Derakon[work]>
That Was Like My Non-Matrix System Was Getting.
--- Log closed Fri Sep 18 00:00:03 2009
code logs -> 2009 -> Thu, 17 Sep 2009< code.20090916.log - code.20090918.log >