This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
/
InteractionPoints.cs
86 lines (68 loc) · 2.55 KB
/
InteractionPoints.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace SampleApp
{
public class InteractionPoints
{
public Rectangle head;
public Rectangle headUp;
public Rectangle headDown;
public Rectangle headLeft;
public Rectangle headRight;
public Rectangle neutral;
public Rectangle shoulderRight;
public Rectangle shoulderLeft;
public Rectangle left;
public Rectangle right;
public InteractionPoints()
{
}
public Rectangle[] GetRects()
{
return new Rectangle[]
{
head, headUp, headDown, headLeft, headRight,
shoulderLeft, shoulderRight,
left, neutral, right
};
}
public void setHead(Rectangle head)
{
this.head = head;
headLeft = new Rectangle(head.X - head.Height, head.Y, head.Height, head.Height);
headRight = new Rectangle(head.X + head.Width, head.Y, head.Height, head.Height);
headUp = new Rectangle(head.X - head.Width / 2, head.Y - head.Height / 2, head.Width * 2, head.Height);
headDown = new Rectangle(head.X - head.Width / 2, head.Y + head.Height / 2, head.Width * 2, head.Width);
shoulderLeft = new Rectangle(head.X - head.Width, headLeft.Y + headLeft.Height, head.Width, head.Width);
shoulderRight = new Rectangle(headRight.X, headLeft.Y + headRight.Height, head.Width, head.Width);
left = new Rectangle(headDown.X - head.Height, headDown.Y + headDown.Height / 2, head.Height, 2 * head.Height);
right = new Rectangle(headDown.X + headDown.Width, headDown.Y + headDown.Height / 2, head.Height, 2 * head.Height);
neutral = new Rectangle(headDown.X, headDown.Y, headDown.Width, 2 * head.Height);
}
public int classify(Point p)
{
if (shoulderLeft.Contains(p))
return 4;
if (shoulderRight.Contains(p))
return 5;
if (left.Contains(p))
return 2;
if (right.Contains(p))
return 3;
if (neutral.Contains(p))
return 1;
if (headLeft.Contains(p))
return 6;
if (headRight.Contains(p))
return 7;
if (headUp.Contains(p))
return 8;
if (headDown.Contains(p))
return 9;
return 0;
}
}
}