We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I am having an issue with comparing points, current and previous. In my current sketch the angles compared are updated so frequently that the difference is minimal.
if ((closestX>320)&&(closestY<240)) { //Square 4
tempX = closestX-320;
tempY = closestY;
currentAngle = degrees (atan(tempY/tempX));
tempAngle = currentAngle - previousAngle;
println("current angle is :" + currentAngle);
println("previous angle is:" + previousAngle);
println("difference is:" + tempAngle);
previousAngle = (currentAngle);
}
}
}
Is there a way to compare angle of half a second ago to the current angle?
Answers
full sketch:
If you need to keep track of angles over a period of time, store them in an array.
Use millis() to keep track of time.
Sorry I am really new to processing and I am struggling to understand how to use array, I understand that array will create a list of my previous angles and these can be accessed according to a millis() condition. Could you give me an example?
Thanks.
If you know how many angles you're gonna need, use a float[]:
http://processing.org/reference/Array.html
Otherwise, use a FloatList:
http://processing.org/reference/FloatList.html
I know that I want to compare the current angle with the angle that was like 0.5 seconds ago