Tuesday, March 5, 2013

Quickhull experiment in js & html5 - part2

Cleaning up the code for Quickhull. Added more math routines in it. Created classes inside javascript. Its simple to create classes(objects only) in javascript. One has to use the Java Script Object Notation (JSON)

Example:


var bounding_box = {
    "min": {
        "x":0,
        "y":0
    },
    "max": {
        "x":0,
        "y":0
    }
};


The source code so far: QuickHull java script code. 

Needs to recursively call on the edge subdivision. That will be when I get time next :-)

Monday, February 25, 2013

Quickhull experiment in html5 - part1

More experiments on Javascript and html5 rendering..
Implementing the Quickhull algorithm. This will find out a fast optimal bounding volume encapsulating all the points.

Steps:

  1. Find the bounding box
  2. Find the points lying on the box, they form a quad..
  3. Eliminate the points lying inside the formed boundary
  4. Find the farthest point away from each edges and form a triangle of that edge with the point.
  5. Eliminate the points lying inside the triangle and add the two new edges to the hull
  6. Repeat the steps 3-5 till no points are found outside the hull.


So far, being able to capture points on canvas, was able to compute AABB and the inside quad, need to create a javascript datastructure for storing edges, and inserting edges in between. Remaining tomorrow...


The interactive canvas below (requires google chrome):