# Angular Velocity by Vector - 2D [duplicate]

This is originally a problem in programming, but since almost no one on Stackoverflow know how to solve this I went here instead; https://stackoverflow.com/questions/23003612/javascript-angular-velocity-by-vector-2d

I want to convert X and Y velocities to angular velocity, this is the formula I am currently using to calculate the initial velocity by the x and y values and then turn it into angular velocity for my circle object:

Av = Sqrt(Vx^2 + Vy^2) / R

Angularvelocity = Squareroot of (Velocity x^2 + Velocity y^2) / Circle's radius

This is how it simulates in my programming: http://jsfiddle.net/yzb9P/2/ (Click to change the balls position)

Now since a square root can't be negative, this won't work when the ball is supposed to rotate anti-clockwise. So, I need a signed version of the initial velocity that also can be negative, how do I calculate that?

• If no one here can answer you, you may want to try SciComp.StackExchange.com Apr 11 '14 at 15:28
• Would Computational Science be a better home for this question?
– Qmechanic
Apr 11 '14 at 15:37
• Can the ball slip?
– Kvothe
Apr 11 '14 at 15:37
• What you can try is to project (e.g. with linear algebra) the velocity vector along the plane the ball is rolling on. If the ball can't slip, that should be proportional to spin; if it slips, their derivatives may be proportional. that kind of depends on whether you're making a really accurate demo or a game.
– Kvothe
Apr 11 '14 at 15:44

The angular velocity vector can be computed via the cross product of the position and velocity vectors: $$\boldsymbol\omega=\frac{\mathbf r\times\mathbf v}{|\mathbf r|^2}\tag{1}$$ In two dimensions, this is really $$\mathbf a\times\mathbf b=\det(\mathbf{a\,b})=a_xb_y - a_yb_x$$

I don't really know Java well at all, but it looks like your code is already equipped with computing the cross product (wedge: function(v)). But note that your line

ball.av = ball.v.wedge(ball.v.length())/ball.r


Seems to be the problem area. Given the definition of wedge, this should have a negative sign in front as $\mathbf r\times\mathbf v=-\mathbf v\times\mathbf r$. It is also unclear to me how ball.v.length() and ball.r are related..

• "ball.av = ball.v.wedge(ball.v.length())/ball.r" Is totally wrong actually is returns Error, I just forgot it there, yes you are right, a vector is supposed to be the input, not a number. I mean if for eg: Vx = -3 and Vy = 2, the pythagoras theorem won't work. It's not really the computation of the angular velocity, it's more about getting the initial velocity by the Vx and Vy, and also if they're negative. Apr 11 '14 at 15:50
• Also I don't understand what a and b means Apr 11 '14 at 15:52
• $\mathbf a$ and $\mathbf b$ are generic vectors Apr 11 '14 at 15:52
• If you want your work to be wrong, go ahead and do that. Reversing the order of ball.v and ball.c is inherently wrong due to the order of the cross product. Dividing by an extra position term means that your units are $m^{-1}s^{-1}$. Apr 11 '14 at 16:21
• @Murplyx I'm not sure what your physics background is, but it would certainly help you right now to study some basic vector algebra. It sounds like you aren't very familiar with vectors and the cross product, and until you learn those basics, we can't do much to help you. Apr 11 '14 at 17:19