PageRenderTime 35ms CodeModel.GetById 33ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Kinban.KinectMouseControl/Utilities.cs

#
C# | 40 lines | 33 code | 7 blank | 0 comment | 2 complexity | d8b035f6178e80ffa8fc12a6be653cba MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Text;
 5using System.Windows.Forms;
 6using System.Drawing;
 7using System.Windows.Media.Media3D;
 8
 9namespace Kinect.KinectMouseControl
10{
11    public static class Utilities
12    {
13        public static float ScaleNumber(float input, float inputLower, float inputHigher, float outputLower, float outputHigher)
14        {
15            if (input < inputLower)
16            {
17                return outputLower;
18            }
19
20            if (input > inputHigher)
21            {
22                return outputHigher;
23            }
24
25            var inputRange = inputHigher - inputLower;
26            var outputRange = outputHigher - outputLower;
27
28            var inputPercentOfRange = (inputHigher - input) / inputRange;
29
30            var output = outputHigher - (inputPercentOfRange * outputRange);
31
32            return output;
33        }
34
35        public static Point3D ToPoint3D(this Microsoft.Research.Kinect.Nui.Vector position)
36        {
37            return new Point3D(position.X, position.Y, position.Z);
38        }
39    }
40}