Permalink
Browse files

Fix formula for converting mm to values

It was assuming that width is greater then height which might not
be the case.
  • Loading branch information...
1 parent 953e4e9 commit 64be22c3492e0c52041d35b1dcf9267699e4cd71 @iaguis iaguis committed Sep 26, 2012
Showing with 25 additions and 7 deletions.
  1. +25 −7 skeltrack/skeltrack-util.c
View
@@ -577,15 +577,33 @@ convert_mm_to_screen_coords (guint width,
guint *i,
guint *j)
{
- *i = round (
- ((gfloat) SCALE_FACTOR *dimension_reduction * MIN_DISTANCE * width *
- width + dimension_reduction * SCALE_FACTOR * width * width * z +
- 2.0 * height * x)
+ gboolean is_vertical =
+ height > width? TRUE : FALSE;
- /
+ if (is_vertical)
+ {
+ *i = round (
+ ((gfloat) SCALE_FACTOR * dimension_reduction * MIN_DISTANCE * height *
+ width + dimension_reduction * SCALE_FACTOR * height * width * z +
+ 2.0 * width * x)
+
+ /
- (2.0 * dimension_reduction * MIN_DISTANCE * SCALE_FACTOR * width +
- 2.0 * dimension_reduction * SCALE_FACTOR * width * z));
+ (2.0 * dimension_reduction * MIN_DISTANCE * SCALE_FACTOR * height +
+ 2.0 * dimension_reduction * SCALE_FACTOR * height * z));
+ }
+ else
+ {
+ *i = round (
+ ((gfloat) SCALE_FACTOR * dimension_reduction * MIN_DISTANCE * width *
+ width + dimension_reduction * SCALE_FACTOR * width * width * z +
+ 2.0 * height * x)
+
+ /
+
+ (2.0 * dimension_reduction * MIN_DISTANCE * SCALE_FACTOR * width +
+ 2.0 * dimension_reduction * SCALE_FACTOR * width * z));
+ }
*j = round (
((gfloat) dimension_reduction * MIN_DISTANCE * SCALE_FACTOR * height +

0 comments on commit 64be22c

Please sign in to comment.