/
Tools.cs
executable file
·58 lines (51 loc) · 1.66 KB
/
Tools.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Collections.Generic;
using System.Linq;
using Microsoft.Research.Kinect.Nui;
using System.IO;
namespace Kinect.Toolbox
{
public static class Tools
{
public static List<Vector2> ToListOfVector2(this List<Joint> joints)
{
return joints.Select(j => j.Position.ToVector2()).ToList();
}
public static Vector3 ToVector3(this Vector vector)
{
return new Vector3(vector.X, vector.Y, vector.Z);
}
public static Vector2 ToVector2(this Vector vector)
{
return new Vector2(vector.X, vector.Y);
}
public static void Write(this BinaryWriter writer, Vector vector)
{
writer.Write(vector.X);
writer.Write(vector.Y);
writer.Write(vector.Z);
writer.Write(vector.W);
}
public static Vector ReadVector(this BinaryReader reader)
{
Vector result = new Vector
{
X = reader.ReadSingle(),
Y = reader.ReadSingle(),
Z = reader.ReadSingle(),
W = reader.ReadSingle()
};
return result;
}
public static bool TrySetElevationAngle(this Camera camera, int angle)
{
bool success = false;
try
{
camera.ElevationAngle = angle;
success = true;
}
catch { }
return success;
}
}
}