/
JointAnalyzerTest.cs
147 lines (121 loc) · 4.13 KB
/
JointAnalyzerTest.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Microsoft.Kinect;
namespace SWENG.Criteria
{
[TestFixture]
public class JointAnalyzerTest
{
[SetUp]
public void Init()
{
}
[TestAttribute]
public void TestJointsAligned()
{
#region align on the x and z axis
Joint center = new Joint();
Joint[] otherJoints = new Joint[2];
SkeletonPoint sp = new SkeletonPoint();
sp.X = 1.0F;
sp.Y = 1.0F;
sp.Z = 1.0F;
center.Position = sp;
Joint joint1 = new Joint();
SkeletonPoint point = new SkeletonPoint();
point.X = 1.0F;
point.Y = 0.0F;
point.Z = 1.0F;
joint1.Position = point;
Joint joint2 = new Joint();
SkeletonPoint point2 = new SkeletonPoint();
point2.X = 1.0F;
point2.Y = 2.0F;
point2.Z = 1.0F;
joint2.Position = point2;
otherJoints[0] = joint1;
otherJoints[1] = joint2;
Assert.AreEqual(1.0F, JointAnalyzer.areJointsAligned(center, otherJoints), "Joints should be aligned but are not: X and Z axis");
#endregion
#region align on the y and z axis
center = new Joint();
otherJoints = new Joint[2];
sp = new SkeletonPoint();
sp.X = 1.0F;
sp.Y = 1.0F;
sp.Z = 1.0F;
center.Position = sp;
joint1 = new Joint();
point = new SkeletonPoint();
point.X = 21.0F;
point.Y = 1.0F;
point.Z = 1.0F;
joint1.Position = point;
joint2 = new Joint();
point2 = new SkeletonPoint();
point2.X = 0.0F;
point2.Y = 1.0F;
point2.Z = 1.0F;
joint2.Position = point2;
otherJoints[0] = joint1;
otherJoints[1] = joint2;
Assert.AreEqual(1.0F, JointAnalyzer.areJointsAligned(center, otherJoints), "Joints should be aligned but are not: Y and Z axis");
#endregion
#region align on the x and y axis
center = new Joint();
otherJoints = new Joint[2];
sp = new SkeletonPoint();
sp.X = 1.0F;
sp.Y = 1.0F;
sp.Z = 1.0F;
center.Position = sp;
joint1 = new Joint();
point = new SkeletonPoint();
point.X = 1.0F;
point.Y = 1.0F;
point.Z = 0.0F;
joint1.Position = point;
joint2 = new Joint();
point2 = new SkeletonPoint();
point2.X = 1.0F;
point2.Y = 1.0F;
point2.Z = 2.0F;
joint2.Position = point2;
otherJoints[0] = joint1;
otherJoints[1] = joint2;
Assert.AreEqual(1.0F, JointAnalyzer.areJointsAligned(center, otherJoints), "Joints should be aligned but are not: X and Y axis");
#endregion
}
[TestAttribute]
public void TestJointsMisaligned()
{
#region perpendicular
Joint center = new Joint();
Joint[] otherJoints = new Joint[2];
SkeletonPoint sp = new SkeletonPoint();
sp.X = 0.0F;
sp.Y = 1.0F;
sp.Z = 0.0F;
center.Position = sp;
Joint joint1 = new Joint();
SkeletonPoint point = new SkeletonPoint();
point.X = 0.0F;
point.Y = 0.0F;
point.Z = 0.0F;
joint1.Position = point;
Joint joint2 = new Joint();
SkeletonPoint point2 = new SkeletonPoint();
point2.X = 1.0F;
point2.Y = 0.0F;
point2.Z = 0.0F;
joint2.Position = point2;
otherJoints[0] = joint1;
otherJoints[1] = joint2;
Assert.AreEqual(0.0F, JointAnalyzer.areJointsAligned(center, otherJoints), "Joint vectors should be orthogonal (90 degrees)");
#endregion
}
}
}