Skip to content
Snippets Groups Projects
Commit c95e3237 authored by florian.hassler's avatar florian.hassler
Browse files

try to improve full circle detection failed

parent 3cb58b18
No related branches found
No related tags found
No related merge requests found
...@@ -674,6 +674,10 @@ PrefabInstance: ...@@ -674,6 +674,10 @@ PrefabInstance:
propertyPath: ShowFirstPerson propertyPath: ShowFirstPerson
value: 1 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11437430, guid: 84c8b8609f9bb434eaf5248f17ff1293, type: 3}
propertyPath: UseTransparentRenderQueue
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 84c8b8609f9bb434eaf5248f17ff1293, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 84c8b8609f9bb434eaf5248f17ff1293, type: 3}
--- !u!1 &930841954 --- !u!1 &930841954
......
...@@ -108,24 +108,8 @@ public class HandController : MonoBehaviour ...@@ -108,24 +108,8 @@ public class HandController : MonoBehaviour
} }
bool checkFullRotation(Vector2 currentPosition)
{
int minPoint = 10;
if (rightHandGesture.Count > minPoint)
{
Vector2 firstPoint = rightHandGesture[0];
float dist = Vector2.Distance(currentPosition.normalized, firstPoint.normalized);
if (Vector2.Distance(currentPosition.normalized, firstPoint.normalized) <=0.001)
return true;
}
return false;
}
void displayPoint(bool left,Vector3 pos) void displayPoint(bool left,Vector3 pos)
{ {
...@@ -268,12 +252,21 @@ public class HandController : MonoBehaviour ...@@ -268,12 +252,21 @@ public class HandController : MonoBehaviour
else else
{ {
EndTracking(); EndTracking();
SpeedText.text = GetAngle(rightHandGesture[rightHandGesture.Count - 1], rightHandGesture[0]).ToString();
//checkFullRotation(rightHandGesture[rightHandGesture.Count - 1]);
} }
} }
} }
public float GetAngle(Vector2 point, Vector2 center)
{
Vector2 relPoint = point - center;
return (Mathf.Atan2(relPoint.y, relPoint.x)*Mathf.Rad2Deg + 450f) % 360f;
}
/// <summary> /// <summary>
/// This return the direction of a vector /// This return the direction of a vector
/// </summary> /// </summary>
...@@ -289,6 +282,24 @@ public class HandController : MonoBehaviour ...@@ -289,6 +282,24 @@ public class HandController : MonoBehaviour
return ((a.x - center.x) * (b.y - center.y) - (a.y - center.y) * (b.x - center.x)) > 0; return ((a.x - center.x) * (b.y - center.y) - (a.y - center.y) * (b.x - center.x)) > 0;
} }
bool checkFullRotation(Vector2 currentPosition)
{
int minPoint = 10;
if (rightHandGesture.Count > minPoint)
{
Vector2 firstPoint = rightHandGesture[0];
float dist = Vector2.Distance(currentPosition, firstPoint);
float angle = Vector2.Angle(firstPoint.normalized, currentPosition.normalized);
angle = Quaternion.FromToRotation(Vector2.up, currentPosition - firstPoint).eulerAngles.z;
float FullAngle= Mathf.Sign(Vector3.Cross(firstPoint.normalized, currentPosition.normalized).z) < 0 ? (360 - angle) % 360 : angle;
if (FullAngle >=358)
return true;
}
return false;
}
void DetermineCircleDirection() void DetermineCircleDirection()
{ {
Vector2 center = CenterOfPoints(rightHandGesture); Vector2 center = CenterOfPoints(rightHandGesture);
......
...@@ -12,6 +12,7 @@ public class ReferencePoint : MonoBehaviour ...@@ -12,6 +12,7 @@ public class ReferencePoint : MonoBehaviour
if (!TouchedOnce && other.gameObject.tag == "gesture") if (!TouchedOnce && other.gameObject.tag == "gesture")
{ {
HandController.instance.IncrementCorrectPoint(); HandController.instance.IncrementCorrectPoint();
TouchedOnce = true; TouchedOnce = true;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment