mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Rearrange math for worldToLocal.
This commit is contained in:
parent
b3fd4515e9
commit
e6672a763f
@ -539,10 +539,10 @@ public class Bone implements Updatable {
|
||||
/** Transforms a point from world coordinates to the bone's local coordinates. */
|
||||
public Vector2 worldToLocal (Vector2 world) {
|
||||
if (world == null) throw new IllegalArgumentException("world cannot be null.");
|
||||
float invDet = 1 / (a * d - b * c);
|
||||
float det = a * d - b * c;
|
||||
float x = world.x - worldX, y = world.y - worldY;
|
||||
world.x = x * d * invDet - y * b * invDet;
|
||||
world.y = y * a * invDet - x * c * invDet;
|
||||
world.x = (x * d - y * b) / det;
|
||||
world.y = (y * a - x * c) / det;
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user