Tilt Calculator module (tiltcalc.mo)

Started by ewinemiller, September 11, 2016, 07:17:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Hi folks,

Posted here for feedback and suggestions; a module to calculate the appropriate tilt for tilt-shift lenses. Modeled after an android app I did a while back. Much quicker just to bring it up on the camera.

It puts a menu on the Debug tab.


Tilt Calculator

Tilt-shift lenses give amazing control of the depth of field by rotating the focus plane, but without knowing how much tilt to dial in, focusing can be frustrating and time consuming.
Tilt Calculator finds the tilt given your focal length and distance to the hinge point. No more trial and error focusing with your tilt-shift. Focus where you want it.

:Author: Eric Winemiller
:License: GPL
:Website: http://digitalcornersquid.com
:Summary: Tilt Calculator


#include <module.h>
#include <dryos.h>
#include <menu.h>
#include <config.h>
#include <math.h>

static uint32_t focal_lengths[] = { 17, 24, 45, 90 };
#define FOCAL_LENGTH_TEXT "17mm", "24mm", "45mm", "90mm"

static float units[] = {10, 25.4, 304.8};
#define UNITS_TEXT "cm", "inch", "feet"

static CONFIG_INT("tilt.calculator.focallength", focal_length_sel, 1);
static CONFIG_INT("tilt.calculator.unit", unit_sel, 1);
static CONFIG_INT("tilt.calculator.distance", distance_sel, 60);

static MENU_UPDATE_FUNC(degrees_update)
double height = distance_sel * units[unit_sel];
int degrees = roundf(1800.0f / M_PI * asinf(focal_lengths[focal_length_sel]/height));
MENU_SET_VALUE("%d.%d degrees", degrees/10, degrees%10);

static struct menu_entry tilt_calc_menu[] =
        .name = "Tilt Calculator",
        .select = menu_open_submenu,
        .submenu_width = 710,
        .children =  (struct menu_entry[])
                .name = "Focal Length",
                .priv = &focal_length_sel,
                .min = 0,
                .max = COUNT(focal_lengths)-1,
                .choices = CHOICES(FOCAL_LENGTH_TEXT),
                .help = "Select the lens focal length.",
                .name = "Unit",
                .priv = &unit_sel,
                .min = 0,
                .max = COUNT(units)-1,
                .choices = CHOICES(UNITS_TEXT),
                .help = "Select the unit for distance to hinge point.",
                .name = "Distance",
                .priv = &distance_sel,
                .min = 1,
                .max = 500,
                .help = "Select the distance to hinge point.",
                .name = "Tilt degrees",
                .update = degrees_update,
                .icon_type = IT_ALWAYS_ON,
                .help  = "[READ-ONLY] Set your tilt to this value.",

static unsigned int tilt_calc_init()
    menu_add("Debug", tilt_calc_menu, COUNT(tilt_calc_menu));
return 0;

static unsigned int tilt_calc_deinit()
menu_remove("Debug", tilt_calc_menu, COUNT(tilt_calc_menu));
return 0;





Hi folks,

I've posted the compiled version at


and the source is now available at


It's only been tested on a 5D mark III.

Are there any tilt-shift enthusiasts watching?

Right now it lets you pick from the four canon lenses, but there are a handful of off brands at different focal lengths (e.g. 35, 80). Any input on just trying to find all those for a short list vs. just letting you pick anything from any focal length 8-200? ML's menu scrolling works really nice so a big list like that is not as bad as it sounds. I'm leaning towards the later.



I just purchased the Canon 24mm TS-E II, will definitely check this out, thanks!
Sometimes you have to go out on a limb to get the fruit.



Great to see you experimenting. Like you I have a 5DIII and I have a 24 TS-E II.

I've posted about my experiences with this lens on my blog, eg http://photography.grayheron.net/2014/03/some-early-thoughts-on-tilt-shift.html

I did experiment with a Lua script to handle the simple DoF math, but in the end decided it wasn't worth the trouble, and now use the a simple approach of starting with a calc in my head (9/2J).

The reason being that the 35mm Tilt Shift at 24mm doesn't give you any refined access to tilting; and no feedback, like a dof on a non-tilt lens. The focusing process with the TS-E requires much iteration, eg using LV, that I found a tilt calculation beyond the 9/2J level not worth it.

The real value of ML with a TS-E is to use A-ETTR for exposure setting.

I offer the above as my experiences.




Nice work @ewinemiller and thanks for sharing a compiled version for 5D3. Definitely will give this a test run as I can borrow a 24mm TS-E II from where I work.
5D3.113 | 5D3.123 | EOSM.203 | 7D.203 | 70D.112 | 100D.101 | EOSM2.* | 50D.109


Hi all,

I updated this so that it starts with the canon focal lengths, but you can add and remove focal lengths now up to 10. The links in the second post are updated with the appropriate code and compiled module. It's been tested on 5D3 1.13.



Very slick. Thanks!
I'm learning for the first time with an inexpensive Ukrainian 80mm T/S and this is helping me get started. The ability to customize the lens list is perfect. I'm using it just above the subject (pinball playfield) and this helped me zero in on the tilt amount to use.


Until the where we land for source control question is settled, the code is squirreled away at https://github.com/ewinemiller/TiltCalculatorForMagicLantern