This repository has been archived by the owner on Jun 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Floor.cs
111 lines (99 loc) · 3.01 KB
/
Floor.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
namespace GesturalMusic
{
/// <summary>
/// A basic struct to store our floor points
/// </summary>
public struct Floor
{
public Point3D backLeft, frontLeft, frontRight, backRight, centroid;
public Floor(Point3D backLeft, Point3D frontLeft, Point3D frontRight, Point3D backRight, Point3D centroid)
{
this.backLeft = backLeft;
this.backRight = backRight;
this.frontLeft = frontLeft;
this.frontRight = frontRight;
this.centroid = centroid;
}
override public String ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("Back Left: {0}\n", this.backLeft);
sb.AppendFormat("Back Right: {0}\n", this.backRight);
sb.AppendFormat("Front Left: {0}\n", this.frontLeft);
sb.AppendFormat("Front Right: {0}\n", this.frontRight);
sb.AppendFormat("Centroid: {0}\n", this.centroid);
return sb.ToString();
}
public void SetFloorPoint(int index, Point3D p)
{
// 3 2
// q3 | q2
// ------------
// q1 | q0
// 1 0
// KIN
switch (index)
{
case 0:
frontRight = p;
break;
case 1:
frontLeft = p;
break;
case 2:
backRight = p;
break;
case 3:
backLeft = p;
break;
}
}
public void SetCentroid(Point3D p)
{
this.centroid = p;
}
public Point3D GetPointAtIndex(int index)
{
// 3 2
// q3 | q2
// ------------
// q1 | q0
// 1 0
// KIN
Point3D point = frontRight;
switch (index)
{
case 0:
point = frontRight;
break;
case 1:
point = frontLeft;
break;
case 2:
point = backRight;
break;
case 3:
point = backLeft;
break;
}
return point;
}
public void UpdateFloorPointRelative(int cornerSelected, Vector3D offset)
{
Point3D basePoint = this.GetPointAtIndex(cornerSelected);
this.SetFloorPoint(cornerSelected, Point3D.Add(basePoint, offset));
}
public void UpdateCentroidRelative(Vector3D offset)
{
this.SetCentroid(Point3D.Add(this.centroid, offset));
}
}
}