2D angular velocity

Please don't post Bullet support questions here, use the above forums instead.
jodersky
Posts: 1
Joined: Wed Jun 16, 2010 3:00 pm

2D angular velocity

Post by jodersky »

Hi everyone,
I've implemented a basic 2D physics engine for a project about a year ago. Recently though, I figured I got the part with the constraints all wrong, well I had something that worked out but the theory behind it was all ugly and unconsistent.
After having learnt quite a bit about linear algebra, I wanted to modify the code dealing with constraints to have something uniform and theoretically correct, something more elegant.
But I already stumbled upon a first problem when determining a simple constraint function and it's jacobian. Consider a point of a body constrained to have a distance L to the origin at all times. Then,
C=||xp||-L
where xp is the constrained point on the body in world coordinates.
The derivative of C is
Cdot=u(v+w cross r)
Cdot=uv-u*skew(r)*w = JV
where u = transpose(xp)/||xp|| and J = (u, -u*skew(r))
Now you will probably have noticed that there is no such thing as a crossproduct in 2D and that is precisely my problem.
How can I handle crossproducts and pseudovectors such as angular velocity in 2D in a uniform way that doesn't need any special treatment in constraints?

thanks in advance,
Jakob
h4tt3n
Posts: 25
Joined: Wed Mar 12, 2008 9:08 am

Re: 2D angular velocity

Post by h4tt3n »

Well, let me google it for you :-)

http://lmgtfy.com/?q=2d+cross+product

the 2d cross product between vectors a and b is defined as:

ax*by - ay*bx

where x and y are the vector components. Notice that the result is a scalar, not a vector. If you normalize the vectors first, it gives you sine to the angle between them (whereas the dot product gives you cosine to the angle). I've implemented it in my 2d vector library long ago, and it works just fine.

Cheers,
Mike