|
@@ -4,62 +4,30 @@ using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using bbiwarg.Detectors.Fingers;
|
|
|
+using bbiwarg.Utility;
|
|
|
|
|
|
namespace bbiwarg.Detectors.Touch
|
|
|
{
|
|
|
class TouchEvent
|
|
|
{
|
|
|
- private int absoluteX;
|
|
|
- private int absoluteY;
|
|
|
- private float relativeX;
|
|
|
- private float relativeY;
|
|
|
- private float floodValue;
|
|
|
- private Finger finger;
|
|
|
+ private Vector2D _position;
|
|
|
+ public Vector2D Position { get { return _position; } private set { _position = value; } }
|
|
|
|
|
|
- public TouchEvent(int absoluteX, int absoluteY, float relativeX, float relativeY, float floodValue, Finger finger) {
|
|
|
- this.absoluteX = absoluteX;
|
|
|
- this.absoluteY = absoluteY;
|
|
|
+ private float _floodValue;
|
|
|
+ public float FloodValue { get { return _floodValue; } private set { _floodValue = value; } }
|
|
|
|
|
|
- this.relativeX = relativeX;
|
|
|
- this.relativeY = relativeY;
|
|
|
+ private Finger _finger;
|
|
|
+ public Finger Finger { get { return _finger; } private set { _finger = value; } }
|
|
|
|
|
|
- this.floodValue = floodValue;
|
|
|
- this.finger = finger;
|
|
|
- }
|
|
|
-
|
|
|
- public int getAbsoluteX() {
|
|
|
- return absoluteX;
|
|
|
- }
|
|
|
-
|
|
|
- public int getAbsoluteY() {
|
|
|
- return absoluteY;
|
|
|
- }
|
|
|
-
|
|
|
- public float getRelativeX()
|
|
|
- {
|
|
|
- return relativeX;
|
|
|
- }
|
|
|
-
|
|
|
- public float getRelativeY()
|
|
|
- {
|
|
|
- return relativeY;
|
|
|
- }
|
|
|
-
|
|
|
- public float getFloodValue() {
|
|
|
- return floodValue;
|
|
|
- }
|
|
|
-
|
|
|
- public float getDistanceTo(TouchEvent te) {
|
|
|
- int xDiff = absoluteX - te.getAbsoluteX();
|
|
|
- int yDiff = absoluteY - te.getAbsoluteY();
|
|
|
-
|
|
|
- float distance = (float)Math.Sqrt(xDiff * xDiff + yDiff * yDiff);
|
|
|
- return distance;
|
|
|
+ public TouchEvent(Vector2D position, float floodValue, Finger finger) {
|
|
|
+ Position = position;
|
|
|
+ FloodValue = floodValue;
|
|
|
+ Finger = finger;
|
|
|
}
|
|
|
|
|
|
public bool isSimilarTo(TouchEvent compareTouchEvent) {
|
|
|
float maxDistance = 20;
|
|
|
- float distance = getDistanceTo(compareTouchEvent);
|
|
|
+ float distance = Position.getDistanceTo(compareTouchEvent.Position);
|
|
|
return (distance < maxDistance);
|
|
|
}
|
|
|
}
|