0

I am trying to figure out how to use correctly body.applytorque(float torque, boolean wake) method on a body with a center of mass, to accelerate it's angular velocity. I want to apply an angular acceleration, in degrees per square second.
According to the libGDX doc, torque parameter uses Newton-meters. To set it, i'll use the formula :

 = I α
where :torque[N-m], I:mass moment of inertia, α:acceleration

on the body :

// java
float acceleration = 120f; // deg/s²
float inertia = body.getInertia();
body.applyTorque(inertia * (float)Math.toRadians(acceleration), true);

but this leads to wrong acceleration, same thing with the mass.

What is the proper use of that method, in deg/s²?

Dima Chubarov
  • 16,199
  • 6
  • 40
  • 76
Dave
  • 1
  • 2
  • degrees per second is an angular velocity, not an angular force (torque). Are you trying to make the mass rotate at a constant angular velocity? How quickly do you want to accelerate it to that angular velocity? – David Jeske Apr 15 '17 at 06:39
  • @DavidJeske [edited : "in degrees per square seconds"] The mass should rotate at a constant acceleration. The rate is 120deg/s². (No final constant angular velocity is needed). – Dave Apr 15 '17 at 12:19
  • Please clarify what you're trying to solve. Are you trying to rotate the body, as in turning it to have a new angular position? Or are you trying to change the rotational velocity of the body? Your title suggests the latter to me while your first sentence suggests the former. – Louis Langholtz Apr 16 '17 at 00:58
  • @LouisLangholtz [edited 1st sentence] I'm trying to change the rotational velocity, constantly. I would use setTransform for a precise angle else. – Dave Apr 16 '17 at 01:02
  • @Dave Thanks for the clarification. So what's the angular velocity that you're starting with and what's the angular velocity you are ending with and how does that differ from what you're expecting? Are you accounting for the behavior of the world `e_clearForces` flag? – Louis Langholtz Apr 16 '17 at 01:36
  • I think I found where i'm struggling, i come back tomorrow to complete the answer. Thanks for your support until there. – Dave Apr 16 '17 at 03:14
  • Thanks for the clarification. I think this question is very clear and well written now. This discussion seems relevant... http://www.box2d.org/forum/viewtopic.php?t=7059 – David Jeske Apr 16 '17 at 15:50

1 Answers1

0

Resolution : the problem came from the world editor UI i was using - Overlap2D.

How to correct : multiply the torque by 2 in applytorque(...) .

The method i mentionned was used correctly in my example above, and so was the formula.
With Overlap2D software, I'm able to place all the bodies i want into a scene. When I then load the bodies and assets in my program, i load directly the world with. I use some convenience classes provided by ashley, e.g IteratingSystem, to compute directly every entity's behaviour at each rendering. This processing is affecting the forces, or at least torques. However i had no problems with angular impulses.

Thank to David Jeske and Louis Langholtz for having guided me.

Dave
  • 1
  • 2