PhysicsUnits

class PhysicsUnits(val pxPerMeter: PxPerMeter)

Converts values between UI space (px/degrees) and physics space (meters/radians).

Coordinate system contract (same for UI and physics):

  • +X points right.

  • +Y points down.

This keeps conversion logic straightforward and allows using gravity as (+0, +9.8).

Scale contract:

  • meters = px / pxPerMeter

  • px = meters * pxPerMeter

Constructors

Link copied to clipboard
constructor(pxPerMeter: PxPerMeter)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard

Converts impulse from physics-scaled length domain to UI-scaled length domain.

Link copied to clipboard

Converts impulse from UI-scaled length domain to physics-scaled length domain.

Link copied to clipboard
fun metersToIntPx(meters: Float): Int
Link copied to clipboard
fun metersToPx(meters: Float): Float
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Converts transform fields from meters + radians into px + degrees.

Link copied to clipboard

Converts transform fields from px + degrees into meters + radians.

Link copied to clipboard
fun velocityMetersToPxPerSecond(metersPerSecond: Float): Float
Link copied to clipboard