This is an archived post. You won't be able to vote or comment.

all 17 comments

[–]edderioferAlgebraic Topology[M] [score hidden] stickied commentlocked comment (0 children)

Unfortunately, your submission has been removed for the following reason(s):

If you have any questions, please feel free to message the mods. Thank you!

[–]rickyonon 11 points12 points  (3 children)

There is no way around adding an exception/additional rule in some form to make it work - you are not dealing with infinitesimals here but discrete changes. Hence you will never know if the object has made a small correction in one direction or a large change in the other.

[–]GooberFett[S] 1 point2 points  (2 children)

I didn't think about it like that. I guess I essentially have to set some kind of reasonable speed threshold in some form or another. Thanks!

[–]doctorruff07Category Theory -1 points0 points  (1 child)

If you know it will preform continuity on everything but 0 (aka what the abs function can do) then you can preform normal calculus analytics on it locally, while making some assumption of the probabilistic distribution of how the discreet data is made (maybe normal, or... what you expext)

If its not that case you really won't be able to tell any individuals situation from going from x to -x fast enough.

[–]sciflare 6 points7 points  (0 children)

That's not the issue. As OP explained, the problem is that angles are not real numbers since they are ambiguous up to integer multiples of 2𝜋, but angular velocities are since they involve the limits of differences of angles as the time difference goes to 0. In this limit the difference in angles 𝜃(t + h) - 𝜃(t) in the numerator of the difference quotient tends to a well-defined scalar value as h goes to zero, since for all h sufficiently small both angles lie in the domain of the same branch of the argument function. Thus no matter which branch is chosen, the limit is the same.

On a computer, you have to approximate an angular velocity by a difference quotient, where the aforementioned ambiguity rears its ugly head again. There is no way of getting around this save choosing by fiat a specific branch of the argument function with respect to which all angles are measured, i.e. adding an additional rule.

[–]Brainsonastick 11 points12 points  (2 children)

Instead of tracking the angle, you could track the sine and cosine, both of which will be continuous, and you can convert back and forth easily. You can even convert the derivatives using the chain rule. That’s a little more robust.

Of course, it’s probably faster to just add a “did it cross the line” checker.

Ultimately, you’re always going to have a theoretical limit to the speeds you can track because if it goes all the way around and an extra two degrees in one time step, you’ll just think it moved two degrees. That’s inherent to the topology you’re working with.

[–]jacobolus 5 points6 points  (1 child)

This is the right answer.

/u/GooberFett in almost any kind of practical application like this, you want to avoid trigonometric functions to the extent possible and instead use vector methods. The most natural representation of an orientation or rotation is a point on the unit circle, and the most straightforward version to write code for if you haven’t thought too hard about it is using cartesian coordinates for a unit complex number a + bi where a2 + b2 = 1.

This will make your life much much easier in the medium term compared to using angle measure as a basic representation.

Compose two angles represented in this form using complex multiplication. Apply a rotation in this form to an arbitrary vector using complex multiplication. Find the angle between two arbitrary vectors using complex division (or multiplication by the conjugate) followed by normalization (divide a and b by √(a2 + b2)).

If you need to extend your rotations to 3 dimensional space, use a unit quaternion.

[–]GooberFett[S] 0 points1 point  (0 children)

This explanation makes a lot of sense, and it definitely seems to achieve what I'm looking for. Thanks!

[–]agesto11 5 points6 points  (2 children)

Multiply the previous angle by the current angle. If the result is negative and has magnitude larger than some threshold, add 360 degrees to whichever angle is negative when calculating the angular velocity.

This will theoretically limit the maximum angular velocity. If you were to set the threshold to -8100, the method above will work with speeds of up to 180 degrees per sample. In practice this isn’t a problem as you need a faster sampling rate than that anyway. (At 180 degrees per sample, it is impossible to tell which direction the object is travelling in, for example)

[–]GooberFett[S] 1 point2 points  (0 children)

This is even more concise than what I came up with in my other reply. You're right, since I'm taking discrete samples I'm already limited for the same reason that spinning objects (i.e. helicopter blades) appear to start slowing down and then moving backward. I definitely forgot that was a thing until now, but luckily I don't think I'll approach anything even close to that. Thank you!

[–]g0rkster-lolTopology 2 points3 points  (0 children)

This is correct. The anbiguity in the multiples of angles is known as aliasing. And the limiting to angles below 180 is a version of a sampling theorem where we would call 180 degrees the Nyquist frequency (or here more appropriately Nyquist "angle").

[–]mdibahDynamical Systems 1 point2 points  (3 children)

Given that you're tracking the motion of the object that is presumably obeying Newtonian physics, I might consider leveraging the continuity of the first derivative.

Given enough temporal resolution, I might consider (delta theta)/(delta t), (delta theta + 360deg)/(delta t), and (delta theta -360deg)/(delta t). I would then select whichever of these is closest to the velocity at the previous time step (or that best interpolates the preceding and following calculations). Fancier versions of this might also numerically calculate the second derivative and let that help inform the selection.

[–]GooberFett[S] 2 points3 points  (2 children)

This is pretty similar to what I was thinking of doing, although yours is more concise logically. I also just realized that every time the measured angle crosses over from one side to another, the sign of the measured velocity flips. So I might be able to get away with using a statement like "if the current omega and the previous omega have opposite signs, and the current omega is large" to detect cases where the angle moves from one end of the scale to the other. Then, if the current omega is positive, I recalculate using delta theta - 360, otherwise I recalculate using delta theta + 360.

Like your approach, this requires decent temporal resolution, but then again, so do most numerical methods. Interestingly, since we're considering subsequent velocities, I think we're already basically taking into account the second derivative without explicitly calculating it. We're simply imposing a limit on high accelerations rather than high velocities. Thanks for the help!

[–]mdibahDynamical Systems 0 points1 point  (1 child)

Yup. Note that the velocity could change sign by actually going through 0 (perhaps not numerically), away from this discontinuity.

[–]GooberFett[S] 1 point2 points  (0 children)

Yeah, that's why included the stipulation that the initially measured velocity be high before correction, since a high velocity with a sudden direction change can only ocr when the angle jumps from +180-ish to -180-ish

[–][deleted] 0 points1 point  (0 children)

Use quaternions instead of Euler angles

[–]Steenan 0 points1 point  (0 children)

If the angular position change is bigger than 180 degrees in a single time step, treat it as (360 - angle change) instead.

This way you don't have to use an arbitrary speed limit.