So, Atwood's Law. Yes, I'm thinking about writing a very light weight computational geometry library in JavaScript. I'm purposely going to target 2D computational geometry because (a) it is 'easier', (b) it can be more readily understood. So, I'm about to start work on the "kernel". I'm about to define a "line".
Well, how do I do that?
If I go back to what I taught college algebra students, then a line is
y = m x + b
Ah, yes, intercept-slope form. Beyond the fact that this is a very easy representation of a line, it is very fucking useless. Why? You can't express vertical lines. Let's look at another version
(y - y0) = (x - x0) m
Oh, yes, still useless. Can't express vertical lines. Ok, Ok. Back up, college algebra was apparently a waste of time since it didn't give a meaningful definition of line. Somewhere, probably graduate school, I realized a line a equivalence relationship of some sort. Aha, yes, a general form to a line.
a x + b y + c = 0
This is way better as I have a complete representation of a line. Yay! Ok, so, let's use it. I can take two of these bastards and solve the system of two unknowns. Ok, what happens when there is no solution?... uh, they are parallel and don't intersect. Ok, so, yes, I find the point at which they intersect. Is this useful? Well, it could be, but I've lost information. Let's look at this equation in vector form.
N (x - x0) = 0
This would be the normal-i-can't-remember-name-but-similiar-to-plane-equation form. This is a nice and cute representation, but it gives be a really poor way to intersect lines naturally. It has a beautiful explaination thou, basically, the line is a collection of all vectors that are orthogonal to to the normal (when translated to the origin). While this is a useless computational representation, it does tell us something useful about the general form. Namely, N = (a,b); isn't that nice.
So far, the general form has given us the most bang for our buck. However, it still sucks since this general form is a compressed representation of a line that enables me to (a) check to see if a point is in the line, (b) find more points in the line, (c) find a line that is perpendicular to it. In the platonic world, this set is awesome. However, the real world tend to suck and lines start somewhere. So, let's go back to that vector stuff and consider (briefly) an Affine linear combination.
L(k) = k * P1 + (1 - k) * P2
Is this a line? Well, it only has one variable and it has at least two points. Well, as cute and as insightful as this is; it is still useless. Too many operations.
L(t) = P0 + D t
This is what I am going to go with. I know where the line starts! I know which direction it is going! It is very easy to intersect two lines! It's easy to compute the normal of the line (use complex numbers to rotate D)! It is trivial to compute new points in the line! As an added bonus, I get rays and segments for free by trapping t in a one dimensional box. Yay!
Moral of the Story
There are many ways to represent the same or very similar data. The one you learned first was probably not the best.
Having been alive for a while, I've learned to try to think ahead of time to find the right representation for the data. That is, after-all, 90% of computing. If spend a bunch of your time writing algorithms, then you are probably doing something wrong.
Am I making the right decision? Not sure. See, now that I've decided which numbers to actually store. I now need to pick between an object, an array, or a composition of arrays. I'll benchmark that since that is part of the core, and it will affect both the performance, readability, and beauty of the code.
Final Decision: going with readability and the 3rd representation even thou it costs double the CPU cycles. Although, I am impressed with how fast JavaScript is.
Friday, September 2, 2011
Sunday, August 21, 2011
Using node.js as my Microsoft Word (+Bonjour)
I love the fact that node.js works on windows.
It's super duper cool.
I wrote yet another markdown processor this weekend as I was kinda out of range of internet to go and import one. I'll fix that later since my version is very weak. I also got a new computer, and I'm doing things a bit different. This should give me an opportunity to solve old problems using new technology.
The first one is printing files between operating systems. My wife has a printer, and I don't. I could solve my problem by buying a wireless printer, installing bonjour, or a USB stick. I'm too lazy for a USB stick, and I don't print enough to justify a wireless printer. The idea of installing bonjour makes me sick (why, I don't know). So, I made marp.
Marp is simply put an HTTP server + markdown + a template. That's it. But, now I can print from my wife's machine by walking to it. This is kinda sucky, but it solves my problem to the point where I am happy.
After spending two hours debugging and getting the markdown + template to where I wanted it for the first version, I hooked it up to node.js and a couple of path handlers, and I was done. I have a thing.
This is why I love programming. When I have problems, I can solve them.
This is also why I love the potential that is node.js. I can throw things together really fast that do really powerful things (I would call making a custom http server that resides in one file a powerful thing). The language isn't too terrible. The velocity I get is terrific. I can hammer simple things out really quick. The concurrency model is very easy to understand, so I don't have the typical race conditions that I would with threads. I can poop little products (that perform well) out very quickly, so I can iterate.
I am nervous about doing bigger things with it, but I'm optimistic that the node.js community will figure that stuff out.
It's super duper cool.
I wrote yet another markdown processor this weekend as I was kinda out of range of internet to go and import one. I'll fix that later since my version is very weak. I also got a new computer, and I'm doing things a bit different. This should give me an opportunity to solve old problems using new technology.
The first one is printing files between operating systems. My wife has a printer, and I don't. I could solve my problem by buying a wireless printer, installing bonjour, or a USB stick. I'm too lazy for a USB stick, and I don't print enough to justify a wireless printer. The idea of installing bonjour makes me sick (why, I don't know). So, I made marp.
Marp is simply put an HTTP server + markdown + a template. That's it. But, now I can print from my wife's machine by walking to it. This is kinda sucky, but it solves my problem to the point where I am happy.
After spending two hours debugging and getting the markdown + template to where I wanted it for the first version, I hooked it up to node.js and a couple of path handlers, and I was done. I have a thing.
This is why I love programming. When I have problems, I can solve them.
This is also why I love the potential that is node.js. I can throw things together really fast that do really powerful things (I would call making a custom http server that resides in one file a powerful thing). The language isn't too terrible. The velocity I get is terrific. I can hammer simple things out really quick. The concurrency model is very easy to understand, so I don't have the typical race conditions that I would with threads. I can poop little products (that perform well) out very quickly, so I can iterate.
I am nervous about doing bigger things with it, but I'm optimistic that the node.js community will figure that stuff out.
Saturday, August 20, 2011
New computer, No Microsoft Office Needed
So, I've put together and have a new gaming rig/development machine for home. I'm getting up my linux VM now so I can do the real work (Only need Windows for steam and the volume of game choices, alas, I'm a gamer hooked onto Windows like a damn crack baby).
Office Freedom
I neither need nor want Microsoft Office. Yes, I am working on a book. No, I don't need office. I'm using Markdown inside of Notepad++. Thank the heavens I no longer need power point, and if I do, then I'll probably be dead already and burning in the 5th level of hell. I'll be honest, I'm a bit sad about excel. I'll get over it. BUT, we do have node.js for windows now. This, combined with some CSV trickery will serve me very well. The idea of having a cross-platform scripting language that doesn't suck, has closures, and is network ready it very exciting.
Development Freedom
I don't need Visual Studio anymore since I have no desire to touch C#. It is, in my opinion, toxic for my health. My language at work is Java, but when I come home: OCaml or JavaScript. Now that node.js works on windows, I'll be able to do some very cool shit and have confidence that if my work pans out, I could actually sell it.
Office Freedom
I neither need nor want Microsoft Office. Yes, I am working on a book. No, I don't need office. I'm using Markdown inside of Notepad++. Thank the heavens I no longer need power point, and if I do, then I'll probably be dead already and burning in the 5th level of hell. I'll be honest, I'm a bit sad about excel. I'll get over it. BUT, we do have node.js for windows now. This, combined with some CSV trickery will serve me very well. The idea of having a cross-platform scripting language that doesn't suck, has closures, and is network ready it very exciting.
Development Freedom
I don't need Visual Studio anymore since I have no desire to touch C#. It is, in my opinion, toxic for my health. My language at work is Java, but when I come home: OCaml or JavaScript. Now that node.js works on windows, I'll be able to do some very cool shit and have confidence that if my work pans out, I could actually sell it.
The "Cloud" and my d:\ Drive
Basically, instead of migrating hard-drives and what-not to the new machine or using the network. I'm migrating all my stuff to a USB drive and S3. All my day to day stuff will be in Dropbox, and I'm working on my sync protocol now to mirror the USB drive to S3. It will be very pretty. So, this handles my data.
Data + Tools + Writing Tools = I Win!
What else do I need? Not much, I do say that I'm impressed with Windows 7 as a platform (although I don't want to develop for it anymore). Out of the box, it is pretty and not bad. I haven't had to fix the machine or anything. All the drivers worked. I'm glad I don't have to install a bunch of shit, and I don't want too. I'm only using Windows for games, and I'm getting really good performance in VirtualBox (even with the 2600K).
Happy, Happy, Joy, Joy
Thursday, August 11, 2011
New Computer Ordered
Ever since getting a woman, I've hardly spent anything on myself... hrmm. Anyway, today I fixed that and ordered a new computer. Why? because my current computer is dying like a thug.
- Corsair CC800DW Obsidian 800D Black Aluminum Full Tower ATX Enthusiast Case
- ASUS LGA 1155 SATA 6Gbps USB 3.0 Supported Intel Z68 ATX DDR3 2400 Motherboards P8Z68-V PRO
- Intel Core i7-2600K Processor 3.4GHz 8 MB Cache Socket LGA1155 Corsair Vengeance Blu 16 GB PC3-12800 1600mHz DDR3 240-Pin SDRAM Dual Channel Memory Kit
- Western Digital 300 GB VelociRaptor SATA 3 Gb/s 10,000 RPM 16 MB Cache
- Noctua 6 Dual Heatpipe with 140mm/120mm Dual SSO Bearing Fans CPU Cooler NH-D14
- Corsair Professional Series Gold High-Performance 850-Watt Power Supply
- EVGA 03G-P3-1584-AR GeForce GTX 580 3072MB GDDR5 PCB PCI-Express 2.0 Graphics Card
- Windows 7 Professional SP1 64bit
Saturday, July 16, 2011
Why Silicon Valley needs more money than NYC; wealth of a nation
Historically, before computers, I think Wall Street served a good purpose. It's ultimate goal was to make sure that great people who could transform the world had the resources needed to do so. The need to coordinate money into the hands of people who can use that money to create wealth is still needed. It's why the world needs investors. However, do we need Wall Street? Do we need the exchanges? Do we need Goldman Sachs?
These are fundamental questions. I don't know the answer, but I'm willing to bet the answer will converge to "No".
I think there is an opportunity for silicon valley to disrupt wall street.
I view wall street in aggregate as corrupt these days because it isn't about creating wealth; it's about managing and optimising money. Money is not wealth. I internally cry a bit when I see a math/computer science major head for NYC to make money. Will they make money? Yes. Will they make wealth for the nation? No.
I'm not really going to defend what I feel. I don't want too. I feel like Silicon valley needs to over-turn Wall street to change the leaders of the country.
We need people who want to make life better for everyone rather than exploit people with complex rules and financial instruments.
I believe we can build a better and brighter future.
The wealth of our nation has been derived from our ability to say "Fuck you nature" not "Let's subordinate most of the country to poverty".
When I look to silicon valley now, I see we are solving communication. This crazy thing called the Internet gives us new tools and new vehicles. I expect us to be able to vote from home. I expect us to remove the computational barriers that forced hierarchy on us. I expect the social web and the Internet to transform us into a culture of a switch rather than a hub.
I expect better out of us.
These are fundamental questions. I don't know the answer, but I'm willing to bet the answer will converge to "No".
I think there is an opportunity for silicon valley to disrupt wall street.
I view wall street in aggregate as corrupt these days because it isn't about creating wealth; it's about managing and optimising money. Money is not wealth. I internally cry a bit when I see a math/computer science major head for NYC to make money. Will they make money? Yes. Will they make wealth for the nation? No.
I'm not really going to defend what I feel. I don't want too. I feel like Silicon valley needs to over-turn Wall street to change the leaders of the country.
We need people who want to make life better for everyone rather than exploit people with complex rules and financial instruments.
I believe we can build a better and brighter future.
The wealth of our nation has been derived from our ability to say "Fuck you nature" not "Let's subordinate most of the country to poverty".
When I look to silicon valley now, I see we are solving communication. This crazy thing called the Internet gives us new tools and new vehicles. I expect us to be able to vote from home. I expect us to remove the computational barriers that forced hierarchy on us. I expect the social web and the Internet to transform us into a culture of a switch rather than a hub.
I expect better out of us.
Labels:
business,
technology
Why women shouldn't vote! (Men do stupid things)
In reading what is good about men? this early morning due to a bit of insomnia. It was an interesting read.
I'd like to apologize now for the link-bait title. I actually encourage women to vote (even more so now), and I have no problem with whatever feminists do. Also, for brownie points, I took women studies in college; primarily because I was seeking to understand why so women are so sparse in computer science.
In the "What is good about men?", if you take it as an axiom and ask follow-up questions. What are the consequences. What about women and voting? Why have women not had/have a vote? Why have men been against it? Why do men oppress it?
So, I was thinking about that when I was trying to get myself to sleep. It's interesting.
I think I got it. Initially, women didn't want to vote so they were not responsible for the stupid ass decisions the men were taking. That's nice, but why the aggression against it?
Well, I think the story goes like this. We are the children of victors. Once the victory is achieved, the peace settles in. A generation is born in peace and corruption and the conflicts moves inward. This corruption enables weaker men to gain prominence and weaker men need to put people into submission. That's where the differential is introduced.
As to laws and aggression, most people fear change and will fight based on that notion alone. Strong men embrace change because change is different, interesting, contains glory, and fun. Weak men fear change because strong men come out on top.
In any-case, I should return to sleep now. I thank HN for bringing it my attention whilst I desperately try to sneak back into bed.
Labels:
personal
Saturday, July 9, 2011
Nerd Rage: Bad Controls on iOS devices for games
Like, seriously, state machines are not hard.
Taking a few steps back, I bought a game on the App Store for over $0.99; when I spend more than $0.99, I expect magic and perfection.
When I get a buggy, clunky, and bad user experience, I get angry especially when I paid more than $0.99. Now, I could just sit from my magical armchair of developer perfection and complain, or I could write some crappy code and maybe educate some iOS fools with code. So, I spent 20 minutes to write an HTML5 joystick controller. Here it is world: angry code to do joysticks right.
Put this in your iOS 4 and enjoy the multi-touch-ness: http://ios.jeffrey.io/
Thoughts on good UX for mobile and games:
1. You need to control the event structure and not relegate it to some bounded box model. Bounded boxes are fine for buttons, but for things that need a level of fluidity and engagement, you need to control the entire screen.
2. You need to understand state machines and how to guarantee the absence of a bad state transition. Namely, the controls shouldn't stick nor flip-flop. It should be very simple.
3. You need to understand there are a multitude of thumb sizes.
4. You need to eat your own dog food.
I seriously wish I could get a refund. Argghhh!
Labels:
technology
Subscribe to:
Posts (Atom)