coordinate-systems
convert between common 2d and 3d coordinate systems:
- cartesian (2d)
- cartesian (3d)
- polar (2d)
- cylindrical (3d)
- spherical (3d)
install
npm install --save coordinate-systems
usage
construct a Coordinate
using one of the provided static constructor functions.
Run the conversion member function to convert to an array of values in [x, y, z?]/[r, t, p?/z?]
format.
// static, short-hand contructors// @note, radians assumed by default for polar-esque systemsCoordinate.polarCoordinate.cartesianCoordinate.cylindricalCoordinate.spherical // classic constructornew Coordinatenew Coordinatenew Coordinate xy.polar // [ 5, 1.5707963267948966 ] (i.e. radius 5, theta π/2 radians)xyz.spherical // [ 3.74..., 1.10..., 0.64... ] (radius, theta, phi)
because this is a typescript package, the interfaces are fully documented and can be seen in src/index.d.ts. this is usually not a tracked file, but tracked here strictly for documentation purposes.