Thursday, August 20, 2009

SATA RAID

Ok, for a compter game we are working on we need to record full HDMI video to make a marketing trailer. My current computer could not handle it at all.

First the math: HDTV is 1290 x 1080 at 24 frames per second.
That works out to 1.4 MPixels at 3 bytes per pixel is 100 MB per second.
But there is also sound and some other overhead.

So we went to NewEgg and bought parts:
  • RAIDMAX SAGITTA 2 ATX-928WB Black case. (Cool blue lights!)
  • ECS Black Series A790GXM-AD3 AM3 AMD 790GX HDMI ATX AMD Motherboard
  • AMD Phenom II x4 955 Black Edition Deneb 3.2 Ghz AM3 socket Quad-Core CPU
  • 6 GB Ram
  • 4 SATA Western Digital Caviar 160 GB Drives
  • Vista Home Premium 64 Bit
  • DVD SATA Drive
  • A Screen 22" wide screen
  • RAIDMAX 630W Power supply (More nifty blue lights)
  • Silver Thermal Past (not needed)
  • Cables etc.
The total was 1005.34 USD

We also have a BlackMagic Intensity Pro for 200 USD. This is a HDMI video grabber card and claims to be able to suck up full HDMI video.

So it all showed up in about 3 days. Lots of boxes.

We put it all together.

Then configured it in the BIOS for RAID 5. That was a mistake. RAID 5 means that 3 of the 4 disks are used in parallel for reads and writes, and one is used for parity error correction. This makes it more reliable. After all the install and config, we put in the disk speed test program that came with the Intensity Pro, and we were getting about 350 MB per second read, but only about 50 MB/Sec write. It would never do for what we needed.

(I think the parity generation was slowing it down.)

So...

We reconfigured for RAID 0 with all four disks. This uses all 4 disks in parallel for reads and writes. After a complete reinstall of Vista etc. we ran the disk test again.

450 MB/Sec read and write.

Smokin'

This box is amazing. The click and open on programs is almost instantaneous.

TF

Tuesday, August 11, 2009

XNA Screen Projection

In XNA there is a method,

Vector3 GraphicsDevice.Viewport.Project(Vector3 source, Matrix projection, Matrix view, Matrix world)

that converts a world point to screen coordinates.

The return value is a Vector3. The X and Y is the screen location of the point. It may not be
within the GraphicsDevice.Viewport if the object is "off screen".

One point of possible confusion is the Z part of the return value. It is the depth into the Z buffer.
Your projection matrix has a near and far plane. A Z value of 0 is right on the far plane and is very far away into the screen. A Z value of 1 is a point near the observer, right on the screen plane.

A value of 0.5 would be half way between the far and near planes.

If the Z value is greater than one then the point is behind the observer.

After calling Project, you should check the Z value and if it is greater than 1 then don't draw anything.

Note: if the Z value is > 1 then that means that X and Y must be negated to figure out where the object is relative to the screen. This is important if you are doing a "Mario Smash Bros." style arrow that points off screen at an object that has flown off the edge. But Smash Bros has it easy because no objects ever can get behind the observer.

The reason that X and Y have to be negated is simple. Imagine that the object is behind your head while you are looking at the screen. Draw a line from the object, through your head, to the screen. That is the screen location of the object.

Note: UnProject is a method that does the inverse of Project. It converts a screen location (don't forget the Z part) to world space.

TF

Friday, July 10, 2009

The Easy Programming Allusion

The Utopian Requirement
On many project, I have seen the following logic...

  • Lets have a easy scripting language or visual programming lanuge so non-programmers can customize the system.
  • We currently have to have programmers put in custom code for each customer's need and it is expensive.
  • We'll let the analyst at the customer's company do the change instead so it is easy and inexpensive.
The Reality of Programming
What is wrong with this picture?

There are two types of changes to systems, configuration parameters, and code.
A configuration parameter is usually a single number or setting that has a very limited set of valid values. For example the department names in a company. Some programmer has thought out in advance what all the possible valid values will be and designed the program to handle them.
The second type of change is the one that causes the most trouble. It is a change in the logic and processing of the program. For example, maybe a 'if' statement that then calls any method available in the program to do processing. Such changes can bring down the whole house of cards that is the program.
Programmers deal with this by knowing the system well, making changes and debugging and testing.

The Flaw
The desire of management is to make such changes easy for a non-programmer. But there is a basic contradiction here. They want a person that does not know the code well, to make the change and not thoroughly test the whole system for interactions.

The Reality
What happens in the real world of product roll out, customer complaints, and emergency fixes to save the sales reps. account, is that the customer quickly gets the application into a state where is will not run, and then a programmer from the company ends up making the change, only now it is some 'scripting language' that is less flexible and powerful than the native language of the application.

The Exception
There is one exception in the real world to this logic, Excel.
Excel is the most widely used programming language in the world and is used mostly by non-programmers.

Why does this exception exits?
Because Excel spreadsheet language is a highly domain specific language in it's simple form. It lets you do simple math on cells. There is no sequential programming being done, no 'if' statements, and a highly limited and sanitized method set. If you make a mistake it tends to be located in exactly the cell you are editing.
Then Excel has deeper programming constructs which most users never use. Thus in some ways it is not being used as a programming language so much as simply customizing settings on cells, which are simple math.

The Secret Solution
There is a sweet spot of customization where the user is not programming, but simply customizing settings. If you can reduce your customers job to 'configuration' then you win.

So here is Keene's Rule of Customization:

"Only let your customer configure."

TF

Tuesday, June 30, 2009

Wrong Science, Write Answer, Wrong Execution

Congress is soon to pass a climate bill.

Wrong Science ?
The climate debate and the science behind it is inconclusive. On one side is the view the we create global warming by emitting CO2 and should stop it before the climate goes haywire and we have a disaster.

The evidence to support Global Warming is fairly good, and in some areas is the current best science we have. That does not make it correct and also the debate is not over. When the debate is over then science has stopped and there is nothing more to discover.

On the other side is the belief that Global Warming is not happening, or if it is, it is not our fault. The science for that point of view is also fairly good.

The data about global climate is buried under so many layers of politics, dogma, academic reputations and such, that even reading the raw scientific papers does not arrive at any clear conclusion.

So lets make a big assumption, that the whole Global Warming thing is one big mistake and hoax.


Write Answer
Ok, so then why cut carbon emissions, and do the economically painful, switch to non fossil fuels?

  • Firstly, the USA is currently shoveling cash at unbelievable rates at other nations to buy their oil. This is unsustainable from any point of view. (Yeah Pickens Plan!) We will go bankrupt as a nation trying to buy foreign energy.
  • Second, The oil is running out. We are just about out of 'Easy Oil' and as oil becomes more scarce, the price will be come increasingly volatile. As oil becomes harder to get, the funds to research and build a non-oil base infrastructure will not be available.
  • Third, The environment (not the climate) is damaged by fossil fuel burning, starting with the lungs of Humans.
  • Fourth, Oil is used to make plastics and fertilizer, not just for energy. The world food supply and much our modern junk we buy at WalMart is dependent on oil. It does not need to be. Fertilizer can be made from air and electricity. Plastics are the difficult one, and rubber for tires. That might be a far better use of oil.

Wrong Execution
So hooray for Obama and the climate bill. It forces a reduction in fossil fuel use and dependence on foreign oil.

And now for the main point (drum roll please)

The massive tax that the new climate bill represents $175 per household, with 105,480,101 households in the USA so that would be 18 billion dollars. There has been absolutely no talk about how the fees collected as 'carbon taxes' would be spent. There has also been no talk about how much money the carbon credits would rais for the government. The 18 billion dollar estimate is the best I can do for now. Maybe it is more like a trillion dollars? Who knows? It does not get talked about.

Not only that, there are zillions of loopholes in the bill so that the major emmiters of carbon won't suffer too much. So who is going to suffer if we are to actualy reduce carbon emissions? I bet it will be the middle class, as usual.

My crystal ball tells me that the money will go to social spending.

The correct answer should be to earmark ALL the money gathered from carbon sin taxes to alternate energy.

Could you imagine what 18 billion dollars of research into algae oil would do?

TF


Footnote: The down side...
Obama's climate bill will bankrupt the nation, while spending the money on 'lets be happy' programs. This will result in an economy with no money to change over to alternate energy, an no time to research alternatives before the oil runs out, leaving us in poverty and despair. Nations in poverty have no desire to help the environment. Conclusion: Obama's climate bill will be the worst thing ever for the climate.

Go Google 'The law of unintended consequences.'

Friday, June 12, 2009

What is 1 + 1?

  • A five year old: two
  • A mathematician: That is arbitrary symbol system and unless I know which system you are using the answers are infinite.
  • A Physicist: 1.95 +- 0.01
  • A Poet: The many splendors of love...
  • A Computer Programmer: printf("%d\n", 1+1);
  • A Computer Scientist: 10
  • Bush: that is classified for national security reasons.
  • Obama: How about we fund that research out of the stimulus money?
  • A Drunk: Shoe.
  • A Policeman: I'll ask the questions here unless you want to get tasered.
  • A Ninja: (Could not find one to ask)
  • Chuck Norris: That would be my Punch (tm) followed by my hallmark Roundhouse Kick (tm).
  • A Manager: Lets hold a meting to plan the response to that question.
  • A Consultant: I see we are funded for three weeks work, so come back in three weeks for the answer.
  • A Tester: Your program crashed while calculating the answer.
  • Buddha: Your attachment to the number one causes suffering for all beings.
  • The Pope: The correct question is what is 1 + 1 + 1.
  • Global Warming Alarmists: Our simulation shows that the answer will be increasing over time.
  • Global Warming Deniers: Our leading scientist says the answer is 2 but has recently been fired for saying so.
  • Mormons: Actually 1 + 2 or 1 + 3 works well too.
  • McDonald's Employee: Do you want fries with that.
  • Picasso: N

Tuesday, May 5, 2009

Worlds Apart

I recently read the article Heavy Boots and was struck by the difference of world view that some people can have.

The article is about "If you were standing on the moon and drop a rock, will it float away, or fall down". The answer is obvious to me. But then I got thinking...

I grew up with a father that designed the lunar orbiters in the 1960's, build telescopes for fun, we launched rockets, read SciFi, I have a degree in engineering. I can remember standing on a street on a hill in Spain in 1980, with a perfect starry sky, and several planets and moon in the sky, and the sun had just set. I could perfectly visualize the actual and relative motions of all the bodies in my mind.

So many people live in a different world than I do. They have no real concept of science or how the world around them works. It reminds me of the dark ages when the world was haunted by spirits and people were killed for witchcraft. (See Monty Python and the Holy Grail, "She's a witch!") Such persecutions were not done so much out of cruelty , but on response to a world view of "how things work".

There seems to be a common thread through conflict and conflicting world views.

1.) If you have conflicting world views, and you try to change the world view of someone else, they can get very angry. This seems to be because people see attacks on their world view as a personal attack on them self. Everyone's world view has a huge chunk in it called "I" and who "I" is. A change of world view is nearly impossible for anyone over 20, and difficult for anyone over 2.

2.) When people see you as threatening their well-being according to their world view, they will violently defend them selves.

Therefore...
  • Religious conversions are almost never a change in world view, they are a coming home to what is viewed as the world view they always had but never quite had right.
  • Wars are always justified as "If we don't act they will kill us." This may seem obvious, but in any war both sides always are justified this way. E.g. The Iraq war. If the USA didn't do something, those #$%@# terrorists will come over here and kill us." and the terrorists justify their actions as, "Those foreigners are trying to foster democracy which will reduce our power and will result in our death". (Note: I won't dignify their actions as actually religiously motivated. The leaders are thugs that justify their actions by assuming all the rest of the world is thugs, and there are a few rank-and-file terrorists that are actually motivated by religious ideals. See Bully below.)
  • Teenagers are solidifying their world view, but run hard up against reality, and so it is a difficult time of life.
  • Religion and Science: Many religions see science as an attack on their safety and salvation and that of their children. Scientists see religion as undermining the science that has brought us such a high standard of living, and endangering lives.
  • Swine Flu: The recent Swine Flue Hysteria, in several countries they want to or have killed all the pigs. This exactly fits a world view that includes pigs being fundamentally unclean, the flu has to do with cleanliness, governments can not be trusted, and a past history that includes plagues, and western science that is simply one more way for the heathen invaders to lie.
  • In politics, government decisions can be a basic way of ensuring standard of living and opportunities for people. There seem to be two basic world views on the USA, one is 'government is the problem' typified by the Republican view, and 'government is the solution' typified by the Democratic view. Thus politics is a very serious game indeed. We could argue quite a bit about whether Republican and/or Democratic actions seem to match such stated world views.
  • A bully or crook. there is a world view that the world is difficult, everyone is a bully (some more successful than others) and the only way to survive as a person is to be the most skilled bully. "Survival of the Strongest". The opposing view is along the lines of Brotherhood, or "I am a child of God, and so is everyone else", etc.
  • Pacifists: there is a world view that violence is unjustified no matter what. This vew tends to follow along the lines that the world has a 'rightness' to it and if we would just calm down, the bullies will change their world view.
  • Elitists: The world view that I am smarter than most every one else and I know what is best for you, so toddle along there and let me run things. This is one of the most dangerous world views there is. It is the exact opposite of brotherhood. (Ok, I'll bite, this is Obama all the way.)
Such a list could go on and on.

Now look at the specific conflicts of out time in light of this. Think "what are the conflicting world views". Who holds which views? (Not necessarily the neat packaged world views the opposition supposedly has.)
  • Us vs. Terrorism
  • Science and Religion
  • Bailouts vs. Let-em-die
  • Right to Choose vs. Right to Life
  • Global Warming vs. Many alternate priorities and conclusions.
  • Socialized "fill in the blank" vs. Free Market.
  • What Paris Hilton wears vs. Who is Paris Hilton?
  • Save the Planet vs. Save the Humans.
  • USA vs. China
  • Illegal Immigrants vs. Jobs
  • Inner Peace vs. Outer Appearance
  • Paper vs. Plastic vs. Bring Your Own Bag (Yes I'm serious about this one. It is a shallow placeholder for much deeper beliefs.)
  • Gun Control vs. Right to Bear Arms.

So what is the whole point here. Ill preach a bit now using absolutes...

If people would just realize that rule number one is "If it involves violence, be very cautious".
If justifying your acts of violence includes any level of indirect reasoning, it is almost certainly wrong.
Violence is always a result of conflicting basic world view issues. In all cases violence will never change someone's view.
Seek to understand first.

What would ever justify violence?
A direct and obvious attack on person, your family, or your ability to be left alone to 'do your own thing'.

All other cases should be handled with talking, and talking, and talking.

And then there is something deeper. Our values, world view, and beliefs are really conclusions that we have drawn from our individual experience. Everyone is in this same trap of a single thread of experience. 'They' can't hold any other world view because it is a result of their experience. Once you truly understand this, you can be very tolerant of others. Maybe this is the ultimate 'Brotherhood'.

There but for the grace of God, go I.

Your Fellow Human Being
TF

Wednesday, April 22, 2009

Air Energy vs. Ocean Energy

With all this talk about climate change and such, I got curious about how much total energy is stored in the heat in the atmosphere vs. the oceans. It seems that we talk about climate change, but because we are humans, we are highly biased toward the air being the climate and somewhat ignore the oceans. If we were all dolphins, we would see the oceans and ignore the air.

SO lets get some numbers, all gleaned from Google searches, mostly with hits on Wikipedia...

Weight of the atmosphere: 5.1x10^18 kg.
Weight of the oceans: 1.5x10^21 kg.

So the water out weighs the atmosphere by 294 times.

But, water holds more heat per kg than air...

The specific heat of water: 2.015 kJ/kg-K.

This means that it takes 2015 Joules of energy to raise one killogram of water by one degree Kelvin or Centigrade.

the specific heat of air: 1.0 kJ/kg-K

So water holds about twice the heat per pound than air, so

The total heat needed to change the temperature of the ocean vs. the air is
588 times greater
.

My point?

the global temperature that we all measure and quote as 'global warming' is irrelevant.

The oceans are the real climate and fluctuations in the atmosphere are trivial.

TF