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.
README.rst
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
tiltcalc.c
#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.",
},
MENU_EOL,
}
}
};
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;
}
MODULE_INFO_START()
MODULE_INIT(tilt_calc_init)
MODULE_DEINIT(tilt_calc_deinit)
MODULE_INFO_END()
MODULE_CONFIGS_START()
MODULE_CONFIG(focal_length_sel)
MODULE_CONFIG(unit_sel)
MODULE_CONFIG(distance_sel)
MODULE_CONFIGS_END()
Regards