Mapping Octahedron

Hi all,

I’m new to this and not really familiar at all with how to code this.

My project is an octahedron with 15 LEDs on each side, in 3 rows. 7 LEDs on the bottom, 5 in the middle and 3 on top.

How would I map this? I

Hey Nick!

I think I can envision the layout, but to make a map, you’ll need to compute the position of each pixel in 3 dimensions, as well as know how it’s wired so you can map the pixel index into each (x, y, z) coordinate.

Here’s an example. Imagine an octahedron with one pixel at each vertex. Looking at it from above, I’m pretending that the wiring starts with the first pixel (index 0) is the one on top, closest to my point of view. Pretend it’s now wired to go to the rear left, clockwise around the middle section (pixel indices 1, 2, 3, and 4), and the last pixel is the vertex at the bottom, index 5.

Pixelblaze will scale these coordinates to have each axis go from 0 to 1 anyway, so I’ve chosen to think of the dimension in each axis from 0 to 2 to help me visualize it.

In this simple 5-pixel example, here’s the resulting map. Notice how the first entry in the map is pixel index 0, the first one wired.

function (pixelCount) {
  var map = []
  map = [
    [1,0,1], // Top
    [0,1,0], // Back left
    [2,1,0], // Back right
    [2,1,2], // Front right
    [0,1,2], // Front left
    [1,2,1]  // Bottom
  return map

Obviously yours is going to be much more complicated, having 120 mapped array elements. That’s why you might chose to generate the coordinates in the map javascript, instead of computing and entering them explicitly as in my example. I would make a helper function that can generate a portion of the overall map for any one of your 8 edges, given the start and end coordinates for each edge. Mapping in 3D space is always a challenge for me to rattle my brain looking for the old highschool algebra required. I hope this gives you a bit of a head start!

The payoff is great though: If you get it mapped, you can use any other 3D patterns people have shared in the pattern library.

I was re-reading your message and I think I misinterpreted that your LEDs are along the edges, when I now think you’re saying they’re on the faces, right?

As I re-envision your layout this way, can you describe or share a diagram of how you’ve wired it so I can brainstorm a map generator?

Hi Jeff,

Thanks for the replies. You’re right that the LEDs are on the faces. Here’s a photo.

Here’s how it’s wired. Data flows from bottom left to top right. This is how the top portion of the octahedron. The bottom panels go from bottom right to top left.

Hi @nickbeaulieu,
Are each of the 8 faces identical? Is this machined or laser cut? If so, then you probably have coordinates for each point, at least in 2D.

With that in hand, and given that each face is identical aside from its position/rotation in 3D space, you could transform the 2D coordinates for each face.

This article has a great explanation of how you could do that, along with functional example code. In fact, the renderer for the pixel map uses this!

Getting all of the angles and translations could be a bit tedious, but having a live preview should help!

You can also use other 3d tools or pixel mapping software to model and generate your map, and then convert it to a set of coordinates.

Thanks :slight_smile: I’ll take a look at that shortly. And yes, you’re right, each face is identical. Each panel was laser cut for the placement of each LED.

So this is what I’ve come up with:
function (pixelcount) {
var map = []
map = [
//side 1
//side 2
//side 3
//side 4
return map

Is there any way of streamlining that?

That looks pretty good!
May-10-2020 17-41-18

Keep in mind that it will normalize the height and width, but that looks like an octahedron!

Since you are doing straight coordinates, you don’t have to write a function, you can just have the array, but it’s already done and working.

eg these are equivalent:

function(pixelCount) {
return [
[1,2,3], ...



You might want this awesome XYZ sweep pattern by Roger Cheng to see if everything is mapped up right:

Its on the pattern site called “RGB-XYZ 3D Sweep” here:
You might have to page around a bit to find it.

cool, Thanks. I loaded that up and it seems that the blue works, sort of. It goes down one side and up the other. the green and red don’t quite work right.

When I put in the coordinates, do I have to put them in order of the direction the data flows?

Yes, the order of the coordinates in the map should match up with the pixel wiring.

Aww crap. Well that’s gonna be fun :stuck_out_tongue: thanks for the help :grinning: I’ll go and make sure they’re all in order and see how that goes.