Glad I could help out.
I built an example as well, though it only shows the process of calculating the unwrapped angle.
I'm afraid it doesn't apply it to a gloriously cucumber rotating cause.
I checked out the cucumber example. Very cool, as one might expect a cucumber to be. Using System > Wait to time travel
One way to compare the current unwrapedAngle
against the 2 seconds old unwrapedAngle
- Create a custom variable "unwrapedAngleOld".
- Every tick: System > Wait 2 seconds; and Set unwrapedAngleOld to the current unwrapedAngl value,
That should make unwrapedAngleOld
continuously play back the unwrapedAngle
values from 2 seconds ago.
I have no idea how optimal this is, but I've never seen a performance hit. Granted I'm using a desktop, and it might be a different story on a mobile device.Angle delta math
As for the mathematics behind the angle_delta
formula from my previous post, I can hopefully simplify it a bit.
In my prior post I wrote it out as:angle_delta
= ( ( ( a
) + 180 ) - floor( ( ( a
) + 180 ) / 360 ) * 360 ) - 180
The reason it looks so awful is that the formula contains a mod() function, which I've written out long hand.
Here is the formula as it appears if you have an appropriate mod() function available:mod(
( a , b
) + 180 ,
Unfortunatly you don't have the appropriate mod() function in C2 by default, and that's why I wrote it out in expanded ugly form. (Further explained in "C2's modulus" section below.)
That mod formula I'm using above has the following behavior:mod( val , div ) ...
= ... val
- ( floor( val
) * div
)This is a "floored division" style mod.
Terrible as it might sound, there are a few different versions of the mod formula, all called the same thing, but all slightly
There's a nice chart showing mod variations on the modulus wiki page
number is positive or negative.
Granted the formula does look a lot nicer with the mod(), and it would be nice to be able to use it in C2.
There is a way, and I show it in the example capx I attached.
You can use C2's Function object to create a custom "floored division" style mod function.
- Create an "On function" event with the function name "mod".
- Add the action "Set return value", and in the expression, use the "floored division" mod formula I described above.
- Within the expression you'll need to use Function.Param(0) and Function.Param(1) to get the arguments.
(Or you'll need to do what I did in the example capx: Store the args in local variables, and use those in the expression, which may be easier to read.)
- You can then call this custom mod function from another C2 expression.
Again, you can see this setup in the example capx if you're interested. It does make the angle_delta
function much nicer to look at.
Note that I renamed the Function object from "Function" to "oF", which just makes it easier for me to read expressions that involve the function object.
I hope that helps clarify some of the stuff I explained a bit hastily in my prior post.
You do not have the required permissions to view the files attached to this post.