Posts Tagged: javascript
Most recent displayed first:

FABRIK Algorithm (2D)
FABRIK stands for ForwardandBackward Reaching Inverse Kinematics, and it’s a very simple, fast, and clever solution to the inverse kinematics problem.
Let’s inspect this interesting algorithm in 2D.

Polygon Clipping (Part 2)
My previous polygon clipping tutorial dove into the GreinerHormann clipping algorithm. Unfortunately, this algorithm fails at common cases… so let’s revist the problem and try again.
The F. Martinez 2008 algorithm handles coincident edges (unlike GreinerHormann), but it still has some minor goofiness. Let’s solve this problem once and for all.

Polygon Clipping (Part 1)
Polygon clipping is an interesting problem: how do you intersect, union, or diff two polygons?
The GreinerHormann clipping algorithm is quite beautiful and intuitive. Let’s dissect it and take a look.

Genetic Algorithms
In my Ludum Dare 31 entry, Bunnies!, I used a very simple genetic algorithm to breed bunnies. It can seem like magic at first, but genetic algorithms are very simple at their core.

Shunting Yard (Part 3)
Let’s continue adding to our Shunting Yard code base.
In Part 2, we created operator precedence. This allowed us to delay application of operators indefinitely, using a stack. Next, we’ll focus on adding parentheses, so that the enduser can manually override precedence.

Shunting Yard (Part 2)
Let’s continue building a general purpose Shunting Yard algorithm.
We left off with barebones skeleton that implements a shunt to delay building of the abstract syntax tree (AST). Our skeleton left a lot to be desired. For this article, we’ll implement operator precedence.
Please read Part 1 first, since the code here builds directly on the source from that article.

Procedurally Generated Planet Textures
For my Ludum Dare entry, I procedurally generate the textures for the planets. In the game, my math is a little off, and I didn’t have time to derive the correct formula – but now, with unlimited time, I can think a little more clearly :).

Shunting Yard (Part 1)
The Shunting Yard Algorithm is, quite possibly, my favorite algorithm. It transforms a series of tokens into an abstract syntax tree, taking into account operator type, precedence, and parenthesis.
Through the next series of articles, I want to build a general purpose expression parser using the algorithm. By the end, we’ll have an algorithm that can be easily extended to add many different types of operators… any arity (unary, binary, ternary, etc), prefix, infix, and postfix.

TwoDimensional Bin Packing
Twodimensional bin packing turns out to be quite a pickle.
I was introduced to the problem as a 13 year old. My Dad’s friend, Keith, noticed I was taking a knack to programming, and wanted to see if I could help him. Keith was (and still is) a carpenter.
Keith wanted me to write a program where he could input a list of shapes, and the program would figure out the best way to cut a board of wood into those shapes, while minimizing scrap wood. Seems reasonable.
My 13 year old mind quickly exploded… I couldn’t figure out one simple, obvious way to do it. Eventually I gave up, to my ego’s dismay (and Keith’s disappointment!).

How to Fix Banding in Gradients
Photoshop’s gradient algorithm is quite disappointing. It is notorious for creating gradients with banding. Here is an example, attempting to create a gradient from
#222
to#333
:Photoshop's Gradient with Banding
Eeeww!
Can you see it? If you look closely, there are vertical “lines” in the image where the color changes. This is incredibly easy to fix algorithmically  but very difficult to fix any other way.