Specifying force and angle in ApplyImpulse in box2d
- by Deepak Mahalingam
I need to apply an impulse on a object with a particular force and at a particular angle in Box2d. If I am right the syntax would be the following:
body.GetBody().ApplyImpulse(new b2Vec2(direction,
power),body.GetBody().GetWorldCenter());
The problem is my direction is in angles. I found a discussion where it was said that the way we can convert an angle into a vector would be as:
new b2Vec2(Math.cos(angle*Math.PI/180),Math.sin(angle*Math.PI/180));
Now I am not sure how to combine these two. In other words, if I wish to apply a force of 30 units at an angle of 30 degrees at the center of the object, how should I do it?