Wednesday, April 16, 2008

Marshaling between Managed and Unmanaged Code

A good article on the marshaling of data from managed to unmanaged code and vice versa.

Marshaling between Managed and Unmanaged Code from CLR Inside Out:-- MSDN Magazine, January 2008

Al Gore: New thinking on the climate crisis (video)

TED | Talks | Al Gore: New thinking on the climate crisis (video)

Cool Quotes by Einstein

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.

The secret to creativity is knowing how to hide your sources.images

The only thing that interferes with my learning is my education.

Education is what remains after one has forgotten everything he learned in school.

Two things are infinite: the universe and human stupidity; and I’m not sure about the universe.

Not everything that counts can be counted, and not everything that can be counted counts. (Sign hanging in Einstein’s office at Princeton)

Imagination is more important than knowledge.

Reality is merely an illusion, albeit a very persistent one.

Great spirits have often encountered violent opposition from weak minds.

The whole of science is nothing more than a refinement of everyday thinking.

Technological progress is like an axe in the hands of a pathological criminal.

We can’t solve problems by using the same kind of thinking we used when we created them.

According to a friend of mine (Josh Morey) - many of them are either un-sourced or missattributed. So quote these at your own peril!

25 Best Microbreweries in the U.S.

from: Drinking Across America: A Look at the 25 Best Microbreweries in the Country | Travelhacker

    1. Anchor Brewing Company: San Francisco’s Anchor Brewing Company offers a beer experience that you just don’t see often these days. It’s made in a gorgeous brewery modeled after traditional, historic brewhouses. Because of this, each brew is “virtually handmade,” a quality that beer lovers are sure to appreciate. Their most famous beer is Anchor Steam, which has a uniquely rich flavor. Make a reservation to tour their brewery and see how beer is made in this brewery that embraces the brewhouses of old.
    2. Full Sail Brewing Company: The “specialists in the liquid refreshment arts” at Full Sail are “stoked to brew,” and it shows through their beers. This employee owned brewery in Oregon is home to award-winning beers like the Full Sail Amber, IPA, LTD and Wassail, which all picked up a gold medal at this year’s World Beer Championships. Even better, the brewery is located (and open for tours) in Hood River Oregon, a gorgeous little surf town that’s a favorite of windsurfers and skiiers alike.
    3. Real Ale Brewing Company: Located in the Texas Hill Country, Real Ale is a nice place to stop by if you’re on a scenic drive. They use the nearby Blanco river for brewing water, which Owner Brad Farbstein touts as “some of the best brewing water for the styles of beer that we make.” Their tours and tasting hours are on Friday afternoons, making a stop by the brewery a great way to kick off your weekend with a good quality beer.
    4. Stone Brewing Company: Stone brews “big character” beers, like their intensely strong Arrogant Bastard Ale, which, by the way, you’re not worthy to drink. The brewery has a restaurant and beer garden in which you’re free to enjoy their tasty brews.
    5. Saint Arnold: Beer lovers, from connoisseurs to frat boys, love to visit Saint Arnold’s. Why? Their tours are essentially a beer drinking free-for-all party. Held every Saturday at 1, visitors are treated to a history of beer and the brewery, followed by a celebration with free flowing taps and a fun ambiance. Spend one of four tokens to fill a glass, whether it’s a small one provided with the tour, or a large glass purchased from the brewery. Some of their best-loved brews include the Brown Ale, which offers a slight hint of chocolate pudding, and the Fancy Lawnmower, a beer that won the Kolsch gold medal at the Great American Beer Festival this year.
    6. Redstone Meadery: The Redstone Meadery is unlike any of the other breweries on this list, as they create something completely different. Redstone’s tiny brewery puts out honey wine, or mead, an ancient beverage enjoyed by drinkers from Vikings to Beowulf. Six of their meads won medals at the International Mead Festival, including their 2002 Reserve and Sunshine Nectar, which earned Gold. Just the meadery’s aroma is enough to turn you on to their brews: a visit to their facility is sure to be sweet.
    7. Avery Brewing: Avery brews perhaps some of the hoppiest beers in Colorado. As “big beer” lovers, this family owned brewery’s team of hopheads creates intensely flavored brews that are favorites among beer afficionados. Just think of your favorite brewery’s specialty ale: nearly every one of their beers is just as big and robust. These beers are sure to please, as is a visit to the brewery, where you can sample all of their creations and even try cask ales that you can’t find anywhere else.
    8. Flying Dog Brewery: Flying Dog Brewery takes the cool prize. These brewers used to be friends and neighbors with Hunter S. Thompson, and use artist Ralph Steadman for all of their labels. But their excellence doesn’t stop there. They have some truly awesome beers, ranging from the Horn Dog barley wine to the In Heat Wheat. If you tour the brewery, you’ll have a chance to drink a fresh brew straight from the fermenter, and even check out the unique whiskey distillery next door.
    9. Left Hand Brewing: Left Hand’s philosophy is all about balance: of fun activities and of great beer. They work towards a perfect balance of malt and hops, a process that’s evident in all of their beers. This year alone, they’ve raked in 9 awards for their brews, including their intriguing Juju Ginger Ale, which was awarded Best of the Rockies in the Spiced Beer category at the US Beer Tasting Championships.
    10. Dogfish Head: Dogfish has some strong, special brews that hopheads are sure to love. They have a line of time-hopped IPAs, ranging from 60 to 120 minutes. They also have a complex Raison D’Etre, which was voted American Beer of the Year by Malt Advocate Magazine in 2000, and the Midas Touch Golden Elixir, a beverage that showcases ingredients that were found in drinking vessels in King Midas’ tomb. Check out both their brewery and brewpub if you’re in the Delaware area.
    11. New Belgium Brewery: For New Belgium, like many others, brewing is a labor of love. From delivering beer by station wagon to becoming the country’s first brewery to subscribe to wind-generated electricity, this brewery has a rich history and rich beers to match. Their Belgian-inspired brews are a treat, particularly the Sunshine Wheat, a refreshing hefeweizen with a citrus bouquet.
    12. Rahr and Sons Brewing Company: Rahr & Sons is a family owned brewery in North Texas. The brews are only available in Texas, but they’ve won national awards. Rahr’s Blonde Lager, Ugly Pug, and Summertime Wheat have all been recognized at the US Beer Tasting Championships.
    13. Redhook: Redhook’s beers “defy ordinary.” Their flagship beer, the ESB, or extra special biiter, is styled after bitters served in England. They have recently merged with Widmer Brothers Brewing Company, the brewers credited with bringing the hefeweizen to America.
    14. The Lost Abbey: The Lost Abbey has beers for saints and sinners alike, offering beers modeled after the brews created by monks in Belgium as well as numerous other styles. At the Great American Beer Festival this year, The Lost Abbey took home three medals, and was crowned the nations’ best small brewery.
    15. Rogue Brewery: Rogue’s founders fled the corporate life in favor of the food and beverage industry. Significant brews include the Brew 10,000, which was brewed in a limited batch using ultra premium ingredients, and the Chipotle Ale, dedicated to Spanish author Juan de la Cueva. Most recently, their Imperial Stout took a Bronze medal at this year’s Great American Beer Festival, and Shakespeare Stout took Guld at the Stockholm Beer & Whiskey Festival.
    16. Russian River Brewing Company: Russian River is an example of what happens when a skilled champagne company, in this case Korbel, tries their hand at brewing beer. It’s now owned by a husband and wife team and has won numerous awards, from gold medals for individual beers to Champion Brewery and Brewmaster. Their adventuous beers include a double IPA and wine barrel-aged ales.
    17. Lagunitas: Lagunitas prides themselves on “steadily losing less money each month,” a feat achieved by the growing popularity of their quality beers. From their Imperial Stout to seasonal ales like the Lagunator, you’re sure to find something tasty.
    18. Allagash Brewing Company: Allagash started out brewing a Belgian Wit beer, Allagash White, and has expanded to a variety of bottle conditioned beers. This involves a second fermentation in the bottles after the initial fermenting in tanks. It adds an air of complexity to the beers, and the novelty of drinking a “living” beer.
    19. New Glarus Brewing Company: New Glarus was founded by Deborah Carey, the first woman to found and operate a brewery. They have recently moved to New Glarus, Wisconsin, and their facility, currently under construction, is designed to look like an old-world Switzerland town square. Their most popular brew is the Spotted Cow, a blonde ale. Also notable is the Wisconsin Belgian Red, which has won a number of awards worldwide. Last year, New Glarus took the Midsize Brewery of the Year award at the Great American Beer Festival.
    20. Deschutes Brewery: Deschutes is located on the banks of the Deschutes river, offering a small brewpub and specialty brewing facility. They have a number or unique beers, from the Obsidian stout to the Jubelale.
    21. Big Sky Brewing: Big Sky “makes water fun” by pouring their hearts into every beer. Their beer sells in thirteen states, most popularly in Montana. Their brews include Moose Drool, Scape Goat, and Big Sky IPA.
    22. Harpoon Brewery: Harpoon is one of the largest craft breweries in New England, due in large part to their great beer. Located in both Massachusetts and Vermont, they’ve been a large part of the rebirth of microbrewing. They’re best known for the Harpoon India Pale Ale, but their Munich Dark, hefeweizens, and brown are not to be missed.
    23. Great Divide Brewing Company: Great Divide, based in downtown Denver, offers a number of challenging beers. The most popular is the Denver Pale Ale, followed closely by the Hibernation ale. So far, they’ve collected twelve awards from the Great American Beer Festival. They have since ventured into “big beer” territory, producing beers like the Oak Aged Yeti Imperial Stout and Hercules Double IPA.
    24. Independence: Independence’s Rob Cartwright started out brewing beer with his mom at the tender age of 14. Since then, he’s brewed beers for both personal consumption and hand-crafted style. This Austin beer offers loads of flavor and easy drinking. Independence beers include the seasonal Jasperilla Old Ale, Bootlegger Brown Ale, and Freestyle Wheat Beer.
    25. Bear Republic Brewing Company: In the heart of wine country, Bear Republic offers an award winning beer experience. Ingredients at Bear Republic are hand-selected, and recipes are developed over several years. Their Racer 5, Red Rocket, and Heritage ales have been recipients of gold, silver, and bronze medals. This brewery was awarded the Great American Beer Festival’s Small Brewing Company of the Year.

Download YouTube Videos as MP4 Files

The following page has the best bookmarklet for downloading YouTube videos in a format that makes it compatible for loading on to an IPOD.

Download YouTube Videos as MP4 Files

or just right click on the following link %20Download%20as%20MP4%20'+%20%20((navigator.userAgent.indexOf('Safari')!=-1)?'(control-click%20and%20select%20Download%20linked%20file%20as)':('(right-click%20and%20select%20Save%20'+%20(navigator.appName=='Microsoft%20Internet%20Explorer'?'target':'link')%20+'%20as)'))+'';}void(0);">Get YouTube video and select "Add to favorites...". (And if you choose Links as the create in folder - the short-cut will appear on the links toolbar).

Save  LinksSave  Links

Now if you are not familiar with bookmarklets - they are URL bookmarks that contain code within them that allow them to do some amount of processing.

 Download

Once you have added the above bookmark-let, if you click on the bookmark while viewing a YouTube video - you will get a link in the Video's author box, which will allow you to download the video as an MP4. (And this occurs without refreshing the page - so you can decide to download the video in the middle of watching a video without having to worry about restarting the video)

I also found that the format of the video as downloaded - works great on the IPOD nano. I had to make no changes to the video, nor convert it (size or encoding) using a tool like SUPER(c). It just works - and works great!

Makes it so much easier to take PodCasts with you on the iPod.

Sunday, April 06, 2008

LIDAR in India

 LidarFig1TUcvLG

Here is a recent news article on how India plans to use LIDAR technology in The Telegraph - Calcutta (Laser Light on Terror)

Airborne Altimetric LiDAR Where does India stand?

The Indian Institute of Technology at Kanpur (IIT-K), seems to be at the fore-front of LIDAR research in India. Here are some links from that organization.

IIT Kanpur page on LIDAR: http://home.iitk.ac.in/~blohani/: Dr. Bharat Lohani is part of the Civil Engineering department at IIT-K and does most of the research into LIDAR.

International School on LiDAR Technology: http://home.iitk.ac.in/~blohani/LiDARSchool2008/index.html : A workshop on LIDAR that is currently in progress at IIT-K. This is the workshop that the news article from "The Telegraph - Calcutta" references.

LAS Convertor : A convertor utility that allows you to move between LAS formats as well as to ASCII.

Limulator : LIDAR data capture simulator. The simulator generates LiDAR data similar to a real LiDAR sensor for further display and analysis

 

Shameless self-plug:

LIDAR Analyst : The LIDAR tool created by my group at VLS for automated feature extraction from LIDAR data. www.LidarAnalyst.com

Friday, April 04, 2008

Why should you be recycling more?

Hopefully the following video will show you why:

And here is more information if you are interested:

PBS Podcast: http://www.npr.org/templates/story/story.php?storyId=1298536

The cause of the plastic cloud is a natural phenomenon called the Gyre - a swirling vortex of ocean currents - and here is more information on how it causes the plastic cloud:

http://science.howstuffworks.com/great-pacific-garbage-patch.htmTurtlebagPic

http://en.wikipedia.org/wiki/North_Pacific_Gyre

The natural currents combined with the fact that plastics do not bio-degrade - they disintegrate in the presence of sun-light. This results in the plastic pieces that slowly keep disintegrating into smaller and smaller pieces until they are plastic molecules. At this point they just float around as nothing can degrade them further. And unless we find a solution - these molecules are going to keep floating around making the oceans one large plastic cloud. This causes further problems - as it contaminates the fish as well as pollutes beaches.

Finally, this is not a new phenomenon:

http://www.mindfully.org/Plastic/Ocean/Pacific-Garbage-Patch27oct02.htm

Bottom line: Its a problem caused by humans - and an easy solution exists - recycle - at least your plastics!

Coz like diamonds - plastics are FOREVER!

pacific-garbage-patch30oct07

Thursday, April 03, 2008

UI Design - Prototyping

Recently I was looking for a tool that I could use to mock up UIs. Prototyping of UIs and getting user feedback is an exercise that developers often overlook - but is extremely important - because the interface is the "application" as far as the user is concerned.

Typically - I have used a paper and pencil for UI design prototyping.

Why is prototyping using a simple tool important? If you expend a lot of energy developing a UI - especially via code - then it becomes very hard to let it go. A simple form of prototyping - allows you to get a feel for the interface with the least amount of energy. In addition - it allows you to gather feedback and constantly rearrange and add UI elements to get an interface that you users want - and allows for a productive workflow.

So what is important during prototyping?

  1. Should require little effort to create and change
  2. Should allow you to explore and iterate over the design with your users.
  3. If using a tool - it should be simple to use by developers as well as end users and other stake holders in the project. (which is why paper or a white board will never become old fashioned)
  4. Whatever you use - it should be able to communicate your idea universally to all the project's stake holders.

The following video - a presentation by Manuel Clement - shows how one can use PowerPoint for prototyping. (He calls it wireframe prototyping)

http://www.microsoft.com/expression/events-training/globalevent/player/Default.html?South-Korea_Manuel-Clement_Keynote_Wireframe-Prototyping-Using-PowerPoint-2007=Manuel_Clement=Wireframe-Prototyping_Using_PowerPoint_2007

I like the idea of using PowerPoint - because you get a softcopy that you can save, email and use as a tracking tool of your project's design history. Paper is still useful - especially as a first step. (I remember using PowerPoint 2000 when I took a UI class for the purpose of designing a touch-screen ticket kiosk for a public transportation system - and the results were pretty good - allowing for non-linear progression through screens).

As a follow-up I found this website - that provides a download of a power-point file from which you can copy and past commonly used design controls like buttons, scroll bars and window elements.

pptprorotypetoolkit

link:http://www.istartedsomething.com/20071018/powerpoint-prototype-toolkit-01/

The following article has some useful steps on configuring the master slide which will make prototyping multiple dialogs/screens quicker - by creating the basic canvas on the master slide.
http://www.jansfreeware.com/articles/misc-prototyping.html

Vertex Normals

Recently I had to create a 3D model in OpenFlight. The model was made up of a mesh - a list of points and a list of triangles that reference the points in the list by index.

Writing out the mesh just as it is - leads to a flat colored object.

The reason for this is that without normals - the viewer doesn't know how light is reflected off the faces of the model. This is why we need to provide information about the normals for the model. Normals are used in Gouraud shading, Phong shading and other lighting models.

From all my experience with 3D graphics - there was one normal assigned to each face in the model. In other examples I have worked with - this surface normal is then applied to each vertex that makes up the face - a simplified vertex normal.

The only issue with one normal being assigned to all vertices connected to a face - is that the model will have sharp edges - even though it might be a smooth surface. This can look especially terrible when you try and model cylinders, domes or any surface that has a curve on it.

To alleviate this problem - vertices are assigned normals based on the average of all the normals of the faces that, that vertex is a part of.

3d shading

The above example shows an example of shading based on different types of normals.

From left to right:

  • No normals - the first image shows what a 3d model looks like without any normal information - it looks flat.
  • Normals based on the main face - when normals are assigned based on just the main face that they belong to - then the model looks very faceted.
  • Vertex normals based on a combination of surface normals of the faces that contain that vertex - then the model results in a smooth - realistic looking 3d model.

What you need for vertex normal calculations:

  1. Code to compute normal
    The easiest way to do this is to treat the edges of the triangle as vectors (where the triangle is a face of the mesh/object).
    The normal is then computed as the cross product of 2 of the adjacent vectors.
    The normal is then normalized.

As pseudo-code

  • for each vertex i in VertexList v
    • n <== Zero Vector
    • for each triangle j that shares ith vertex
      • n <== n + Normalize( Normal(triangle j) )
    • end for
    • n[i] = Normalize(n)
  • end for

An optimization:

If you look at the above pseudo-code - you will notice that the algorithm runs in will take (n x m) loops to complete, where n is number of vertices and m is the number of triangles. Typically m can approach and even exceed the number of vertices n. Thus the above algorithm has a complexity close to O(n2).

A useful optimization that one can use is instead of looping over the vertices - you loop over the triangles.

  • for each vertex i in VertexList v
    • n[i] <== Zero Vector
  • for each triangle j in TriangleList t
    • n <== Normalize( Normal(triangle j) )
    • for each vertex i in triangle j
      • n[i] <== n[i] + n
    • end for
  • end for
  • for each vertex i in VertexList v
    • n[i] <== Normalize(n[i])
  • end for

This reduces the complexity of the algorithm to O(m) and runs much faster than the original algorithm.

Finally - if you look at the paper Generating Vertex Normals, you will see that there are some useful heuristics that you can apply for more realistic effects based on the application. (such as weighting the average of the normal based on the area of the triangle - vectors make it easy to compute the area of a triangle too).

Useful articles on vertex normal computation:

A Comparison of Algorithms for Vertex Normal Computation (pdf)

Generating Vertex Normals (pdf - contains pseudocode for vertex normal calculation)

Face and Vertex Normal Vectors (Direct3D 9)

A Vector Type for C# - a vector class with useful methods for performing vector arithmetic.

Tuesday, April 01, 2008

LASIK - Week 2 and 3 Report

Nothing much to report about the last 2 weeks.

The dryness is slowly reducing and I need less and less of the artificial tears. My vision has been improving too. Overall my eyes seem to be doing great.

As for problems: Blurred vision as soon as I wake up - maybe occurred a couple of times over the last two weeks. Sometimes I do get a head-ache when I am working on the computer for extended periods (10+ hours). Night time vision still has halos around really bright lights - but it does feel like it is reducing as time goes by.

The main thing at this point is to take regular breaks - especially while I am working on the computer.