Coordinates
In order to easily build certain types of animations, it can be extremely useful to switch from one coordinate system to another.
For instance, to convert a x
and x
coordinate from the React Native canvas to a polar coordinate system centered at 100, 100
:
const x = 0;const y = 100;const center = { x: 100, y: 100 };const {theta, radius} = cartesian2Polart(canvas2Cartesian({ x, y }, center));// theta is π, radius: 100
canvas2Cartesian({ x, y }, center)
canvasToPolar({ theta, radius }, center)
cartesian2Canvas({ x, y }, center)
cartesianToPolar({ x, y })
polarToCartesian({ theta, radius })
polarToCanvas({ theta, radius })