Skip to content
/ array-polar Public

Convert cartesian coordinates to polar and back

Notifications You must be signed in to change notification settings

dy/array-polar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

array-polar experimental Build Status

Convert array with cartesian coordinates to polar or back.

npm install array-polar

const polar = require('array-polar')

let polarCoords = polar([0,1, 1,0]) // [1,0, 1,Math.PI/2]
let cartesianCoords = polar.cartesian(coords)

API

polar(array, center=[0, 0])

Convert 2-dimensional array with [x, y, x, y, ...] layout to polar coordinates based on center point, so that result is [r, θ, r, θ, ...] array. You may want to calculate center as average or median of data. array is modified in-place, so do slice if you need immutable behaviour.

polar.cartesian(array, center=[0, 0])

Convert polar coordinates back to cartesian.

See also

About

Convert cartesian coordinates to polar and back

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published