Box for GoPro batteries


IMG_2200I recently bought a GoPro and wanted to make a box to store the batteries. To be clear, my model is Hero 4 Silver and is using these (AHDBT-401) batteries. It’s easy to find the electrical properties (3.8V DC, 1160mAh, 4.4Wh), not so easy to find the physical size. Here is a quick overview of the key dimensions I noted:

side size top

Out of this unreadable post-it, the important to remember is

  • the full battery measures 36 x 10.9 x 32.5 (in mm)
  • the bottom part of the battery, where GoPro is written measures 30 x 10.9 x 30 (in mm)

The design will be symmetric, to allow to store the battery facing the lid or the opposite side, to distinguish between full and empty ones. I also decided that 4 spare batteries is a good number.

I usually draw my laser-cut design with inkscape but I decided to follow a different path this time. I recently discovered fusion 360, which is free (as in free beer, not free speech) to use for hobbyist. So, for the first time, I did a full 3D model, that can be found here. You can play with the model online and explode it to see the various components.

This is one of my first parametric 3d design, I learnt quite a lot. It’s then definitely time for a pro vs contra using Fusion360 vs inkscape.

Pro fusion 360 / against inkscape:

  • design is fully parametric, changing thickness of material or size of the battery does not involve to restart the design from scratch. I typically had to move from using an m2.5 to a M3 screw (to match what I had in my inventory)
  • you can use standard parts in your design (I used a M3x12 bolt and nut)
  • You got full mechanical constraints, so you can play with your various pieces and check. I discovered an issue that way (there was not enough place for the nut) and avoided a prototyping iteration
  • There is friendly support on forums and a lot of very well made explaining videos (tutorials) on a youtube channel.
  • There is a CAM module, to do machining with a CNC (not tried yet)
  • the web viewer has support nice features. You can explode the components, select specific components (using design button, top left). Time to check the model again 😉

Pro inkscape / against fusion 360

  • inkscape is open-source, uses a standard format, stores locally. This allows to use version control and have lots of freedom (and is future safe)
  • fusion 360 has a 1-year long license that you can renew, courtesy of autodesk and is storing its data in autodesk cloud. It might stop at any time, locking you out of your own designs or forcing you to pay an (expensive) license
  • inkscape’s use of splines is more common for computer users (rather than bezier)
  • Doing a full 3D model currently takes me ~3x more times than drawing in inkscape. I think on complex design, the reduction in the number of iterations evens this out.

Overall, I’m super glad I tried Fusion 360, it’s quite easy to use and has super nice results. side

About the design itself, I wanted to have a design with a lid and it’s the first time I really have moving components. the trick I used was to deport the axis of rotation on the top-left to make the rotation work.

I used 2 bolts and nuts for the rotation (M3x12). Tightening them is enough to have a lid not opening.As usual, the box is also posted on thingiverse.

For bragging rights, some more pictures:

IMG_2171 IMG_2151 IMG_2206 IMG_2203



Box with non vertical sides


While creating a perch for our parrot, I stumbled upon something non trivial : if you want to assemble a box with non vertical sides, what cut angle are you supposed to use to have a nice assembly ? It’s obvious that it should be a trapeze, but what would be the α angle ?

Screenshot from 2016-02-16 13:21:13Easy peasy, let’s dig into the maths!

On the schematics, once assembly is done, we have B=B’ and A,B, B’, A’ in same plane.

Supposing that we have an angle β with vertical (meaning a standard box has β=0), this means

\( tan(\alpha)=\frac{AB}{OA}=\frac{OA’.sin(\beta}{OA}\)

as OA = OA’, we have trivially \(\alpha=atan(sin(\beta))\)

If you need to be convinced, the animation above is done with β=30°. It’s been realized with pov and the code can be found on my POV repository on bitbucket.

And by the way, why did I need that ? Just to make it real :




Egg shape and camshaft


For some tinkering, I wanted to be able to draw a standard, egg-shaped cam and compute the displacement it was generating.

I thought this was a trivial problem, but I couldn’t find anything, so I’ll describe the path I used. As a side note, the end-goal was to generate some 3D animation with persistence of vision, so I was somehow constrained by what as doable with this software (knowing that I don’t generate anything and just use the software, so no real way of numerical solution and such)

The approach I followed seems to have been used for centuries by architect to create egg-shaped curves.

It uses 2 parameters, that I named r and h. I’ll describe the geometrical construction and then go to the calculus phase.

As a side note, I had great fun finding all of these and coining it into an article, hope you’ll like reading it as much as I had writing it 🙂 Some other may follow on related subjects, depending on interest / time.


  • Choose a point (O), this will be your center of rotation for your cam.Screen Shot 2016-01-25 at 6.14.54 PM
  • Draw a circle S1 (black one) , centered on O and radius r
  • Draw a diameter, creating points A and B on circle intersection.
  • Draw a perpendicular diameter and pick a new point C so that OC = h
  • From now, the construction is symmetrical, I’ll focus on one side.
  • Draw a circle S2 (red one) centered on A and going through B (hence, radius = 2r )
  • let D be the intersection of S2 and OC
  • Draw a circle S3 (green one) center on C and going through D
  • Your egg-shape is now, starting from bottom : S1 to B, then S2 to D then S3



Diameter of green circle

By definition,\(AD = 2r\)

Using pythagore on ACO, \(AC = \sqrt{r^{2}+h^{2}}\)

Then \(CD = \rho = 2r-\sqrt{r^{2}+h^{2}}\)

BOD Angle

If you project D on AB to have a new H point, then you have \(\widehat{HOD} = \widehat{BOD} = \beta\) and \(tan (\beta) = \frac{DH}{OH}\)

\(tan (\widehat{OAC}) = \frac{OC}{AO} = \frac{h}{r}\) then \(\widehat{OAC} = \alpha = tan^{-1}{\frac{h}{r}}\)

\(AH = 2r.cos(\alpha)\) and \(DH = 2r.sin(\alpha)\)

\( OH = AH – OA = 2r.cos(\alpha) – r = r(2.cos(\alpha)-1)\)

Finally : \(tan(\beta) = \frac{2r.sin(\alpha)}{r(2.cos(\alpha)-1)} = \frac{2.sin(tan^{-1}{\frac{h}{r}})}{2.cos(tan^{-1}{\frac{h}{r}})-1}\)

Polar coordinates

Let’s continue the fun, the end-goal is to have the polar coordinates of the cam…

We’ll use \(\theta\) as parameter and assume it’s value is 0 on AB axis. Function will have nice properties:

  • \(f(\theta+2\pi)=f(\theta)\)
  • \(f(\frac{3\pi}{2}-\theta)=f(\theta)\)

Meaning that we can focus on \([-\frac{\pi}{2},\frac{\pi}{2}]\)

On \([-\frac{\pi}{2},0]\), solution is trivial : \(f(\theta)=r\)

On \([0,\beta]\), solution is circle center on (-r,0) radius 2r, which has implicit equation

\( (x+r)^{2}+y^{2} = (2r)^2\)

Using standard polar replacements:

\( (f(\theta)cos(\theta)+r)^{2}+f^{2}(\theta)sin^{2}(\theta) = (2r)^2\)

The interesting function is now a second order equation, that can be trivially solved:


On \([\beta,\frac{\pi}{2}]\), solution is circle center on (0,h) radius ρ, which has implicit equation

\( x^{2}+(y-h)^{2} = \rho^2\)

or  \(f(\theta)^{2}cos^{2}(\theta)+(f(\theta)sin(\theta)-h)^{2} = (2r-\sqrt{r^{2}+h^{2}})^2\)

Again, the interesting function is now a second order equation, which can be (not so) trivially solved:

\(f(\theta)= h.sin(\theta)+\sqrt{h^{2}sin^{2}(\theta) +5r^{2} -4r\sqrt{r^2+h^2} }\)

Limits on parameter

Due to the way the cam is built, h must be positive.

In addition, the worst case is having D aligned with O and C (actually C = D), and then, using pythagore:

\( h \in [0,\sqrt{3}]\)

Realization with Pov-Ray

Now that we’re done with the maths, it’s time to do the actual stuff. Real implementation can be found on my POV repository, core is in an include file and there is a reference example file.

The cam itself is generated using CSG : intersection of cylinder and plan, the exact same way I’ve explained before. I encapsulated it into a macro with 2 parameters, h and r. With these explanations, reading the file is really straightforward.

The polar function is implemented using a bunch of functions within POV. There are a few caveats:

  • it seems recursion is not well supported and maybe using a modulo would be smarter
  • using an horizontal egg instead of a vertical one (i.e. changing the theta reference) would allow to have a symmetrical function (the current one has a pi/2 offset)
  • POV function do not allow to use #if statement (seems to be limited to global variable). Using select is a ice workaround but is really killing readability

To have an idea of how h parameter influences the result, quick matrix of rendering with r=1 and h variable:


Free bonus, script used for the rendering, with some image magick in it:


find $OUTPUT -iname "$BASE*.tga" -delete
for a in `seq 0.1 0.1 1.6`; do 
 povray -W200 -H200 +k0.1 -Iscene/$BASE.pov -O${OUT} Declare=h_parameter=$a
 convert ${OUT} -fill white -stroke red -pointsize 40 -gravity south -annotate 0 "h:$a" ${OUT2}

montage ${TOTAL} -geometry +2+2 result.jpeg

Using Persistence of Vision on Ubuntu

I’ve been using Persistence of Vision for almost 20 years. By using, I mean thaat I had times when I was pretty intensive users and most of the time where I didn’t touch it for spans of multiple years.

I recently decided to install it on my ubuntu, and there are some caveats that I’ll document here for safekeeping.

Installation: pretty easy

apt-get install povray

Configuration: not so easy

You need to configure it to work easily from command line. The following files are involved :

  • povray.conf, which describes security limitations mainly
  • povray.ini, which defines default behaviour for povray command line.

Both file should be in ~/.povray/3.7/ (or whatever pov version you’re using) Assuming your pov scenes and personal includes are in ~/pov

$ mkdir -p ~/.povray/3.7

$ cat povray.ini 
# FULL HD 16/10
$ cat povray.conf 
[File I/O Security]

[Shellout Security]

[Permitted Paths]

Default file for povray.conf  is in /etc/povray/3.7/povray.conf and it seems that the user version can’t extend rights but only restrict them.

Rendering a scene: now trivial

It is now as simple as typing

$ povray -Isample_lego.pov

and results as a tga being outputted in the ~/pov/output folder.  Examples of dubious quality can be found in my git repository on bitbucket.