# "Inverted" Coordinate Conversions (mpxi, pxmi)?

## Recommended Posts

What is the point of the "inverted" (in the sense of negated) coordinate conversion methods in the P2 subsystem? Isn't the direction of coordinate system essentially arbitrary, such that multiplying by -1 for conversions in both directions is equivalent to not doing so at all? For example, a sprite with position (100, 200) and velocity (60, -20) in Phaser is to the right of and below the origin and moving to the right and up. Don't you get the same physics whether P2 represents than internally as (5,10) and (3,-1) or as (-5,-10) and (-3,1)? As long as the mirroring is done (or not done) consistently, why does it matter?

##### Share on other sites

the mpxi/pxmi conversions are precisely what allows you to work that way.

##### Share on other sites

the mpxi/pxmi conversions are precisely what allows you to work that way.

I don't really follow. There are inverted (mpxi/pxmi) and non-inverted (mpx/pxm) versions of these functions. Phaser appears to use the inverted versions internally. Why? And doesn't that force any code that interacts with the Phaser P2 subsystem to use the inverted subsystem as well?

##### Share on other sites

Yes it does, and the reason is that internally, p2 uses different units than Phaser. The non-inverted versions are used for stuff like circle radii, where the orientation really doesn't matter. But every time you interact with p2 from Phaser you need to apply the mpxi/pxmi unit conversion.

##### Share on other sites

Yes it does, and the reason is that internally, p2 uses different units than Phaser. The non-inverted versions are used for stuff like circle radii, where the orientation really doesn't matter. But every time you interact with p2 from Phaser you need to apply the mpxi/pxmi unit conversion.

Ok, using the non-inverted versions for non-signed values make sense. But I still don't understand why the negative factor is necessary for position/velocity coordinates. What does it matter if Phaser and P2's notions of up/down and left/right are reversed as long as that reversal is consistent?