Showing posts with label Data Visualization. Show all posts
Showing posts with label Data Visualization. Show all posts

Monday, March 16, 2015

HarmTrace, or: How I Learned about Cabal Hell and Hated it Ever Since

For a music visualization project I'm trying to get HarmTrace, a haskell library, working. It is what Chordify uses in their backend to detect BPM and Chord changes, and Chordify is great on that.

I did not expect, however, that it would be so hard to install a haskell package. Turns out that the "package manager", Cabal, is famous for breaking dependencies and giving developers hell. To this date I've spent 15 hours on it, and I believe it's very close, but it's been a long and winding journey.

Current progress:

Upstream Mentor (creator of HarmTrace and co-founder of Chordify!) successfully contacted.

Mentor suggestion: Install it in a linux machine, with ghc-7.6.3.

Installation progress:

Mac: using GHC 7.6.3, and custom .cabal file, build gets stuck at hmatrix-gsl-stats-0.2 bug. Someone ran into this as well. His fix didn't work on my machine.

Linux: He suggests using linux for this. Ubuntu was installed in a VirtualBox and I tried to install Haskell-Platform on it. First try with Debian distribution, it bugged out; second try, it ran out of memory after ~5 hours. Oops. Guess I'll try it on my Mint.

The author who ran into hmatrix-gsl-stats problem wrote a post about installing it on Linux. After getting Haskell-platform installed, I'll follow his post for the rest.

Oh, and fragment of a script:

To install from online:
cabal install HarmTrace --with-ghc=ghc-7.6.3 --constraint="HarmTrace-Base==1.1.0.2" --constraint="uu-parsinglib installed" --allow-newer=uu-parsinglib,cabal

To build from local:

cabal configure --with-ghc=ghc-7.6.3
cabal build --with-ghc=ghc-7.6.3
cabal install --with-ghc=ghc-7.6.3

Tuesday, May 13, 2014

Literature Review: Fallacies

http://hfoss-fossrit.rhcloud.com/static/books/rhetological_fallacies.png


    Who
        David McCandless

    What
        Rhetological Fallacies

    Where
        http://hfoss-fossrit.rhcloud.com/static/books/rhetological_fallacies.png

    When
        April 2012

    The Gist
        A lively infographic about common rhetoric and logical fallacies. Categorized to "Appeal of the Mind", Appeal to the Emotions", "Faulty Deduction", "Garble cause and effect", "Manipulating Content", and "On the Attack".
        Whew, that was a lot.

    The Good
        1. Strong Graphical elements tat captivates attention.
        2. Large area of coverage.
        3. Categorization and color makes it easier to navigate.

    The Bad
        1. Would be easier to navigate if it's interactive instead of just a png.
        2. Would be easier to transfer the texts if it's interactive instead of just a png.
        3. Minor design flaws: Colors were helpful, but not very associative to content. Also, the top should not have the title touching the border.

    The Questions
    Hmm. There really isn't much to ask. The infographic is very extensive and well-written. The examples also help a lot, and the bottom of the graph shows where the data is coming from.

    Your Review
"Rhetological Fallacies" is an extensive infographic that teaches about common rhetoric and logical fallacies. Being able to recognize these fallacies not only helps with arguing against other's fallacies, but also makes one's own argument better, smarter, stronger. 1337/1337 leet hackers.

Tuesday, March 11, 2014

Data Visualization: If you ever need to use pokemon sprites in a programming project...

...Then you should consider using PokeStadium's pokemon sprite database. It has a nice structure that makes it very easy to be used in coding, as well as a large collection that covers different generations and perspectives.

Of the pokemon sprite databases I see on the 'net, many of them use some kind of content management system that makes confusing URLs of images and/or webpages, or they would put pokemons of a generation into one big spritesheet, then only display parts of it for each individual pokemon. While the former approach probably makes it easy to manage for the wiki editors and the latter approach reduces webpage loading time by reducing the requests made, none of them are for us data visualizers who just wants a single, clean image from a URL that can be generated by combining few magic worlds with, say, the poke-index of a pokemon.

Well, the PokeStadium's URL for X and Y (which are the most up-to-date ones and covers the most pokemon) goes like this:

"http://www.pokestadium.com/pokemon/sprites/img/main-series/6/x-y/" + poke-index + ".png"

And if you want to use some other versions, such as another Generation, another perspective, animated gif, or shiny, or an animated shiny Charmander from Gen 5 from the back perspective, just look up the pokemon with the sprite searcher, then look at the pictures' URL to figure out the magic words. And keep in mind that lower Gen won't have sprites for pokemon exclusive to higher Gen, and things will get more complicated for mega-evolution and different states of the same pokemon.

(Alternatively, you can also use the slightly less verbose serebii.net pokemon sprites - that's where the sprites in PokeStadium comes from.)

Here's a homework project I put up utilizing pokeSprites. Mouse over dots to see which they are.

Friday, March 7, 2014

How to Draw things on a Sphere

I'm working on a Processing project called "Nuclear Bundling Visualizer". Part of the project is to draw something on a geographic coordination. Turns out, it's pretty complicated!

To locate a point on the sphere:

Mr.Philipp Oehrlein wrote a good blog post about mapping data from Latitude and Longitude to points in 3D space. Here's his method for such conversion:

  private PVector toPointOnGlobe(float lat, float lng)
  {
    float _lat = radians(lat) * -1;
    float _lng = radians(lng);

    float x = radius * cos(_lat) * cos(_lng);
    float y = radius * sin(_lat) * (-1);
    float z = radius * cos(_lat) * sin(_lng);

    return new PVector(x, y, z);
  }

My teacher Joe Pietruch and I spent some time to figure out the other problem: What if I want to draw a flat object that is tangent to the sphere at such point? This would require finding out the 3D rotation that object requires.


    // #MAGICAL 3D ROTATION
    // 1. Since all discs are drawn on x and y only, suppose a vector is pointing     //    out normal to the disc (normal to the x and y plane)
    PVector discNormal = new PVector(0, 0, 1);
    // 2. Because rotate() rotates an angle around an axis (could be a vector),
    //    We need to rotate the disc on the plane the disc and a [line that 
    //    points from middle of sphere to the point on globe] forms
    PVector line = toPointOnGlobe(lat, lng);
    line.normalize();
    //    (cont. 2) and to do that, we get the vector normal to such plane using 
    //    cross()
    PVector axis = line.cross(discNormal);
    // 3. Find the angle that needs to be rotated
    float ang = PVector.angleBetween(line, discNormal);
    // 4. Rotate the flat circle on such plane, around that axis, by that amount 
    //    of degree.
    translate(v1.x, v1.y, v1.z);
    rotate(-ang, axis.x, axis.y, axis.z);

Well wasn't that a huge chunk...
[TODO] Make pretty 3D illustrations to show how it works step by step.