Permalink
Browse files

Add convert_mm_to_screen_coords

  • Loading branch information...
1 parent 944fba4 commit 953e4e9aaa9544f946850bcb08c67a712255788b @iaguis iaguis committed Sep 13, 2012
Showing with 39 additions and 0 deletions.
  1. +30 −0 skeltrack/skeltrack-util.c
  2. +9 −0 skeltrack/skeltrack-util.h
View
@@ -566,3 +566,33 @@ convert_screen_coords_to_mm (guint width,
*y = round((j * dimension_reduction - height * dimension_reduction / 2.0) *
(z + MIN_DISTANCE) * SCALE_FACTOR);
}
+
+void
+convert_mm_to_screen_coords (guint width,
+ guint height,
+ guint dimension_reduction,
+ gint x,
+ gint y,
+ gint z,
+ 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)
+
+ /
+
+ (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 +
+ dimension_reduction * SCALE_FACTOR * height * z + 2.0 * y)
+
+ /
+
+ (2.0 * dimension_reduction * MIN_DISTANCE * SCALE_FACTOR +
+ 2.0 * dimension_reduction * SCALE_FACTOR * z));
+}
@@ -111,3 +111,12 @@ void convert_screen_coords_to_mm (guint width,
gint z,
gint *x,
gint *y);
+
+void convert_mm_to_screen_coords (guint width,
+ guint height,
+ guint dimension_reduction,
+ gint x,
+ gint y,
+ gint z,
+ guint *i,
+ guint *j);

0 comments on commit 953e4e9

Please sign in to comment.