Archive for August, 2006

More GLens

Thursday, August 31st, 2006

Wow, check this out:

If I do say so myself, it looks quite sweet. So I have all the tracing code worked out. Now I just need to (a) add interactive features and (b) optimize the hell out of it (c) give it a little chromatic aberration. It’s terribly inefficient right now, but I just set it up so it works.

GLens Continued

Tuesday, August 29th, 2006

I coded all night and I actually got some tracing working. Oh boy! Only for the entrance of a lens, not the exit.
I’ve had enough dot products for one night.

Here’s a screen shot:

See, spheres are not ideal for lenses.

GLens

Sunday, August 27th, 2006

I coded my project a bit more. I decided to name it GLens for now. It’s a lens cad program licensed under the GPL, so why not? I wrote a class for sperical lenses today that just draws them. You input R1, R2, d, and the clipping height, and the centerpoint for each one. I am trying to decide between using real math, or just approximated linearized stuff to find the refraction angles and intersections. Since these are sperical lenses, real calculations wouldn’t be too hard. Kinda wish I payed a bit more attention in calc.

Here’s a screenshot:

Pseudo Ray Tracer

Saturday, August 26th, 2006

Well, I have for a while been curious about modeling how light is effected by lenses with a somewhat realistic computer simulation. My curiosity about chromatic aberrations is what started this nonsense, but I don’t think I will implement code for different wavelengths for a while. It won’t actually create images, but it will trace rays.

It will be in just two dimensions (for now) because lenses can be modeled in 2D. Calculations in 2D are also much cheaper.

I plan on making this a dynamic program where you can move the focal plane, objects, and the lenses around. Eventually, I will set it up so lenses can be moved in an animation or something to demonstrate and experiment with zoom lenses.

Sperical lenses will be the first things that I implement, but I definitely plan on being able to have aspherical lenses as well, represented with NURBS eventually. I really should brush up on my calculus so I can find how rays intersect with these (Newton’s method)… either that, or I could just turn them into line segments and solve a bunch of equations. Either way, I need to learn more math.

I am thinking OpenGL and GLUT for now…. C++, not C because I am an OO whore. I really want to have menus and drag & dropping too, ideally blenderlike, but probably much simpler.

Edit: Wrote a little code and my repository is at:
http://ohpie.com/svn/lens/trunk/

Rails Woes

Wednesday, August 23rd, 2006

Getting Rails to work was such a bitch. Maybe I am just stupid or my server is a bit nutty, but it took me like two evenings just to get damn scaffolding to work.

I also realized I had used MEDIUMINT for my user ID’s in my database for the AOL searches, and the user id went beyond the MEDIUMINT limit…. so I am rebuilding the database as I sleep tonight.

On the good note, I found a nice little article on making screen have a tablike status bar on the bottom. It works pretty nicely. Check it out here I enjoy it thoroughly. Couldn’t live without my screen and my zshell *sigh*.

I’ve also been using sed a lot more. I had a lot of arduous tasks to do at work today and sed helped out. Maybe didn’t hurry things up very much, but it made it more fun for sure. Regexes are your friend. And so is REXML when you have to change a lot of Visual Studio vcproj files. I mean, sure, using ruby to alter a bunch of Visual Studio projects sounds like a terrible idea, but it works great. Project files are XML, so you can just read em right in to a document. The only issue I had is that we use post-build steps with newlines characters… VS.NET turns it into a type thing in one of the attributes. REXML reads it in as &amp#x0d…which is annoying. Yay for the function String.gsub!() I just put them back in their place like a good little attribute. Writing these scripts is turning projects that would take days of cut & paste work and carpol-tunnel syndrome into projects that take hours.

Writing a script to do something is always more fun than doing the actual something…..

AOL Search Logs

Tuesday, August 22nd, 2006

I was curious how many numbers were in there that were in the form of a phone number (###-###-####)

mysql> select COUNT(*) from srec where Query
> regexp "[0-9]{3}-[0-9]{3}-[0-9]{4}";
+----------+
| COUNT(*) |
+----------+
|    4626  |
+----------+

Well, that’s certainly interesting

Facebook API

Saturday, August 19th, 2006

Well, the Facebook API was released a few days ago.  It uses REST to retrieve data.  There was a Java and a PHP library on the Dev site for it already… but I felt like making one for Ruby that could be used for Ruby scripts and Ruby on Rails apps because I wanted to make a web app that would turn your friends into vCards.  I wrote mine called FBLIB… it only has classes for users and friends so far since that’s all I was going to use.  It’s pretty elaborate though, except there is no error catching or documentation because I was writing this for myself in a hurry and I am lazy.

Anyways, I have it in my SVN repository at
http://ohpie.com/svn/fblib

After I finished writing it I realized that the Facebook API didn’t give you contact information, so it would be impossible to make useful vCards of all your friends.  So I give up.  Have fun with the source.  It’s licensed under GPL, and I think it’s a lot cleaner than the other Ruby facebook libraries I have seen in the Facebook Developer group.  It uses the REXML libraries that come with Ruby (REXML is pretty damn sweet!).

If you would like to contribute, drop me a line and I will give you write access to the repo.

Rolleiwhat?

Thursday, August 10th, 2006

Yay!  I was fiddling around with my rolleiflex today and I finally got the exposure counter mostly working, which is just fantastic.  Still, I wasted a ton of film trying to get it to work.  Ugh.  At least most of it was expired.

I shot two rolls that came out and they are drying right now.  It was getting dark and I didn’t have much to shoot, so I just took pictures of my cats, Apache and Lord Fuzzles, and some other randomness.  I’m also getting the hang of metal developing reels so I am happy.

Tomorrow is the company picnic which is bound to be fun.  I had to miss it the last year because it was after school started.  If the weather is anything like it was today it will be fantastic, just fantastic. :)

I was given a project at work to do which involves splitting MFC projects into two projects, one for the code and another for a resource only DLL.  There’s like 60 projects for me to do and I think my boss was planning on it taking several days/weeks, but I wrote a ruby script which automates 90% of the process.  I still have to modify 1 file in each project by hand, add each project to the solution, and deal with Visual Source Safe (EWWW, VSS is so bad).  I also have to test each project.  Oh by the way, I love REXML, the  built in XML ruby support.  It’s making my life so much easier because .vcproj files are XML and I can read it in and spit it out.  The only issue is that Visual Studio wants to “convert” the project once I open it up again probably because it isn’t the exact same formatting as the ones it outputs.  That’s the only actual difference I see.  Order of attributes and whitespace shouldn’t matter with XML.

I’ll post some pictures from my Rolleiflex when I get around to scanning them.

OMGentoo

Tuesday, August 8th, 2006

Well, last week I finally got around to plugging my desktop in after two months and moving.  I had gentoo on it and a lot of packages were out of date and broken and what not.  It’s understandable because the installation is probably a year and a half old and I was running ~x86 (the testing packages).  I also wanted to set my drives to have normal partitioning.  I’ve been running a software (md) raid 0 with 3 80gig drives for 2 years now and I haven’t had any problems, but I decided it’s best not to push my luck.

The plan was to install FreeBSD. Heh.  I got it almost working.  I got frustrated with the package system and I figure I will just save FreeBSD for a rainy day when I feel like upgrading my server (which is going on 331 days without a reboot).  Yeah, I fail at that.  I really like portage though…. a lot.  I can pretty much do a stage 1 gentoo install without docs.

Why am I going through all this effort to get a Unix/Linux machine up and running again?  Well, I have an idea for another project.  It involves a spotter plugin for the GIMP (somewhat like spot heal brush in Photoshop) but better?  Probably not better, but I have plans on making a special thing for making sure you inspect an entire image.  I’ll be damned if I have to develop GNU software on a Windows laptop with Cygwin!  Especially on a single monitor.

More BlackJack

Tuesday, August 8th, 2006

I finished adding splitting and doubling.

It works great so far.  Now I am going to run tests to see the best move for each hand.  There are really only about 200 different scenereos.  Let me explain.

The dealer can have 10 different cards (values) showing.  2-A.  You always want to hit if you have below a 9 (simple logic) and you always want to stand if you have 17 or greater.

It will first start by testing 16 versus the different dealer cards and work down.  (you need the higher ones to see what happens when you hit because it can become a higher combination).  After that it will go through all the soft ace hands.  Then it will test all the ones already done for doubling… and if it’s a better option than hitting.  Finally it will test splitting.

I do need to modify (or extend) the deck and table class to “set up” these situations.  I’d say a few more days until I get around to writing the code.

I updated the repository with the new code.  There’s also a README on how to run a simple test function (in case you want to try this at home)