F#: Ballistics, Rocketry and Research 5/7/2009

image I just got back from the Foundation of Digital Games (FDG) Disney Cruise, and it WAS GREAT!  I had great conversations with some of the best game researchers and professors on the planet, and we all couldn’t use our cell phones or do email without paying a bunch of money.  ACM held the conference and the papers were awesome.  They will be posted shortly, and I will definitely link to them.  Then I went to the Imagine Cup US Nationals, and what a bunch of winning students!

Now I am looking forward to the Star Trek movie!  (Hence the images, I got in the Webmaster program).  WRT the Star Trek Movie, one of the things that I learned on the FDG Cruise was that Hollywood edit 194 of 196 movies using a Windows Based editor named Avid.  I think that this is quite a bit different than I thought was used.  image

Taking a look at the Star Trek web site and I see it uses Flash, which is kind of 10 minutes ago, Silverlight is so much cooler.  To use Flash, like they did on the Star Trek site, you are forced to use a modified version of javascript, which is the most boring actionscript created by Adobe.  Using Silverlight I can use C#, F#, VB, VC++, IronPython, IronRuby, and when it comes out IronPHP, the resulting sites are much more robust.  Silverlight works on Windows, Apple and some versions of Linux, inside of many of the browsers.  Flash doesn’t always work in all of the browsers and just recently started working in most of the browsers. The games appear to be the typical Flash based games, which means they are static and not all that interesting. The Star Trek Movie web site is awesome even if it is held back by 20th century technology in the 21st century.


Let’s move on with the reading of the program by Chris Smith called BurnedLands, scroll down to F#: Ballistics, Rocketry and Research 4/12/2009 in this blog.  Let’s face it, ballistics and rockets have to be understood before you get to view the Star Trek Physics.  We are looking at the Math Module, if you have downloaded the code as well as the F# add-in for Visual Studio or the stand alone versions of F#, we are reviewing the Math.FS code, and just a few of the lines (that is: the following code won’t work by itself):

Today, it will be one line only, as I want to get this posted:

type Vector< [<Measure>] 'a>(x : float<'a>, y : float<'a>) =

type Vector< [<Measure>]image

In F# types are:

  • Records: This is sum types are also referred to as union types
  • Tuples: These are a set of types composed to form a composite type similar to classes in C#


F# includes matrix and column vector types:

  • Matrix vector types are generic and use the form: Matrix<'a>
  • Column vector types, are generally used to describe direction and magnitude, they use the form: Vector<'a>

<[Measure] ‘a>

    • The Measure attribute tells F# that units kg, s and m aren't really types in the usual sense of the word, but are used to build units-of-measure. 
    • In this case, the [Measure] is telling the compiler to check the units for correctness. 
    • ‘a is a type parameterization, a special process in F# where a type is not known, but it will match the value that is returned, as you read the line you see that the ‘a is turned to the type of Float.  The purpose of this is to help the compiler to find more type errors at compile time and helps avoid casting.

(x : float<'a>, y : float<'a>) =

  • the variables x and y become the same variable type as ‘a

That’s it for today, for the next few posts, I will be discussing the new stuff that is coming out of Research.

Technorati Tags: F#,Star Trek,type Vectors,<Measure>