Don Havey

Sustainably harvested information

Archive for the extending classes tag

Tutorial #1: More than one way to skin a sphere  

Electronsphere previewThis first tutorial will address the question of how to evenly distribute points on a sphere. It’s not as simple as it sounds.

I’ll be addressing one method today, which I’ll be calling the electronsphere. The idea is this: treat each point as if it were an electron – repelling all other electrons around it – and limit its maximum distance from a center point. You should end up with a pretty well-distributed sphere of points. The trick will be how to “skin” (triangulate) the sphere. More on that later…

For now, take a look at where we’re going: The final result

And download the classes: Electronsphere classes

When you’re looking at the example, give it about 30-60 seconds to resolve the positions of the electrons (longer on slower computers, waayyy faster within the Processing environment), then you’ll see triangles start to appear between the points on the sphere. Both processes are iterative and random, and therefore quite unpredictable, but they should produce quasi-accurate results.

Why should I distribute points on a sphere?

I’m not really sure. The first time I encountered the problem I was in need of a spherical shape that could be warped or dented. I used a more sensible approach than the electronsphere, which I’ll show in a later tutorial, but the electronsphere is much more exciting. By changing the repulsion between electrons, you could potentially use this to create a sphere of points that reacts to mouse movements or other interactions and warps a mapped image accordingly. That would be worthwhile.

What you’ll be learning

We’ll address all of these issues in this tutorial:

  • Extending classes
  • Node interaction: repulsion forces
  • Using vectors to constrain points and forces
  • Finding the circumcenter of a three-dimensional triangle (face)
  • Back face culling
  • And in general, how to set up an iterative Processing application

Let’s get started…
Read more…

The article has

2 responses

Written by Don

April 7th, 2008 at 9:41 am