Tag Archives: geometry

Finding Collisions of Circles and Line Segments in Javascript

The JavaScript program below creates a field full of circles and line segments of random size, position, and velocity, and calculates and displays the collisions between them. To see the code in action, copy it into an .html file and … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

Finding Collisions of Circles in JavaScript

The JavaScript program below creates a field full of circles of random size, position, and velocity, and calculates and displays the collisions between them. To see the code in action, open it in a web browser that runs JavaScript.

Posted in Uncategorized | Tagged , , , , | Leave a comment

Triangulating a Polygon with the Ear-Clipping Algorithm in JavaScript

The JavaScript program below, when run, draws a complex polygon, converts that polygon to triangles using an “ear-clipping” algorithm, and displays the results. To see it in action, copy the code into an .html file and open that file in … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

Finding the Convex Hull of a Set of Points in JavaScript with the Jarvis’s March Algorithm

The JavaScript code below, when run, generates some random 2D points and then finds their “convex hull”, using the relatively simple algorithm known as “Jarvis’s March” or “the Gift-Wrapping Algorithm”. See the Wikipedia page for more details. There are other, … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , | 2 Comments

Plotting, Drawing, and Intersecting Bezier Curves in JavaScript

The JavaScript code below, when run, plots and draws two Bezier curves (one is a straight line), and calculates and draws their bounding boxes. It also makes an attempt to find and highlight the intersections between them, though the keen … Continue reading

Posted in Uncategorized | Tagged , , , , | 1 Comment

Performing Rotation with Quaternions in JavaScript

The JavaScript code below performs some rotations on a set of coordinates around a pair of axes, using quaternions to do the calculations. To see the code in action, copy it into a .html file and open that file in … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

Converting Triangles into Scan Lines

The JavaScript code below converts each of several different triangles into a series of “scan lines” (that, is, horizontal lines of pixels on a display), and then displays those scan lines (or actually, only every third one, so that you … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment