介绍
传统的坐标表示方法(x,y)需要手动一个个输入坐标,不便于编程,特别是在画规则图形的时候,有规则的点(x, y), (-x, -y), (nx, ny)明明可以使用程序控制,却还需要手工收入,特麻烦。
因此我发明了一种可编程的坐标表示方法--单位圆坐标。
理论
任何坐标都能用N * 单位圆与其外切矩形的切点及外切矩形顶点来表示,这些点包括:
![](http://hi.csdn.net/attachment/201203/18/0_13320882233V1l.gif)
( 0, 1 ) -- up
( 1, 1 ) -- upRight
( 1, 0 ) -- right
( 1, -1 ) -- downRight
( 0, -1 ) -- down
( -1, -1 ) -- downLeft
( -1, 0 ) -- left
( -1, 1 ) -- upLeft
因此在程序中,我只要给定值(N)和方向(单位圆坐标)就能制作一个二维坐标。
实现
/**
* Create a point in paperJS by using
the tangent points of an unit circle's enclosing rectangle,
* and the vertexes of this enclosing rectangle(directions) multiplied by two any given numbers,
* for example,
(4, 2) is (1*4, 1*2), and (23.5, -23.5) is (1, -1) * 23.5 …
*