Skip to content
Advertisement

Tag: cartesian-coordinates

Generate and sort cartesian coordinates around (0,0) in all quadrants using Javascript’s nested array loops

I have an variable obj that has the element count that needs a cartesian coordinate. So I want to generate the following matrix. obj = 9, Square root of obj = 3, 3×3 matrix (-1,1) (0,1) (1,1) (-1,0) (0,0) (1,0) (-1,-1) (0,-1) (1,-1) obj = 25, Square root of obj = 5, 5×5 matrix (-2,2) (-1,2) (0,2) (1,2) (2,2) (-2,1)

Advertisement