'Calculate what forces cancel out Velocity and Angular most efficient
Given a set of (thrusters) forces applied to a rigid body at a given point. What will be the best way to cancel out current forces that are applied to this rigid body.
To simplify center of mass calculations, different forces at the different positions I have precomputed how a given thruster affects the rigid body, for a single (time) frame.
Example Input:
| Thruster name | Linear Force Cancelled | Angular Force Cancelled |
|---|---|---|
| A | (0, 0.5) | 0.08 |
| B | (0, -0.5) | -0.08 |
| C | (0, 0.5) | -0.08 |
| D | (0, -0.5) | 0.08 |
| E | (0.5, 0) | 0 |
| F | (-0.5, 0) | 0 |
Current Rigidbody Force:
- Velocity: (0.25, 12)
- Angular Velocity: 17
Example Output
(A * 100%, C * 100%, F * 50%, B * 100%)
The issue I'm facing is code performance since my best algorithms are (O)n^n (that are still not accurate). Because in order to take only thrusters needed for force cancellation I need to take into account how a given thruster affects other variables.
So If I want to cancel out Velocity in X-axis and have no Angular Velocity, in the end, I need to cancel out the Angular Velocity I created in order to cancel X-axis.
Thank you,
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
