# How can I detect whether a point is moving in a circle?

I want to detect if my GameObject (Vector3 Point) being dragged by the player's finger is moving in a circular fashion.

I thought I could save the last 5 points every 10 frames and join them by lines. Then I'd project them into a "defined" plane. From there, I can form the perpendicular bisectors of those line segments - to check where they are intersecting.

If every intersection point is very nearby - the finger is swiping in a circle! Now I only need to check if the intersection point is close.

How can I check if they intersect? Or is there a better way to solve this?

Here's my code so far:

public LinkedList<Vector3> FingertipPoints;
public Transform Fingertip;

private void Start()
{

}

[Range(1,60)]
public int FramesPerCheck = 10; // 6checks per sec
private int Frame;
// Update is called once per frame
void LateUpdate()
{
Frame++;
if (FramesPerCheck == Frame)
{
Frame = 0;
FingertipPoints.RemoveLast();
}

//Get the Direction Vectors
Vector3 V1 = FingertipPoints.First.Value - FingertipPoints.First.Next.Value;
Vector3 V2 = FingertipPoints.First.Next.Value - FingertipPoints.First.Next.Next.Value;
Vector3 V3 = FingertipPoints.First.Next.Next.Value - FingertipPoints.First.Next.Next.Next.Value;
Vector3 V4 = FingertipPoints.First.Next.Next.Next.Value - FingertipPoints.Last.Value;

//Project them on a plane
V1 = Vector3.ProjectOnPlane(V1, Fingertip.forward);
V2 = Vector3.ProjectOnPlane(V2, Fingertip.forward);
V3 = Vector3.ProjectOnPlane(V3, Fingertip.forward);
V4 = Vector3.ProjectOnPlane(V4, Fingertip.forward);

//Get the Perpendicular Vectors (is this even right?)
Vector3 C1 = Vector3.Cross(V1, Fingertip.forward);
Vector3 C2 = Vector3.Cross(V1, Fingertip.forward);
Vector3 C3 = Vector3.Cross(V1, Fingertip.forward);
Vector3 C4 = Vector3.Cross(V1, Fingertip.forward);

//???
//How to check if they intersect nearby??
//

}

• Why not just check wether the movement direction changes 360 degrees? – Bálint Aug 9 '18 at 16:05