Module: geometry

提供一些封装过的二维几何功能
Source:

Methods


degree(_radians)

从弧度获取角度
Parameters:
Name Type Description
_radians Number
Source:
Returns:
Type
Number
Example
geometry.degree( 3.14 ) 

distanceAngleToPoint(_distance, _angle)

从长度和角度求坐标点
Parameters:
Name Type Description
_distance Number
_angle Number
Source:
Returns:
Point
Example
geometry.distanceAngleToPoint( 100, 90  ) 

intersectRect(r1, r2)

判断两个矩形是否有交集
Parameters:
Name Type Description
r1 rect_Object
r2 rect_Object
Source:
Returns:
Type
Boolean
Example
geometry.intersectRect( { x:0, x2: 200, y:0, y2: 200 }, { x:0, x2: 200, y:100, y2: 200 } ) 

lineAngle(p1, p2, offsetAngle)

判断两个矩形是否有交集
Parameters:
Name Type Description
p1 point
p2 point
offsetAngle Number
Source:
Returns:
Type
Number
Example
geometry.lineAngle( { x:0, y:0 }, { x:200, y:100 } ) 

pointDistance(_p1, _p2)

计算两个坐标点之间的距离
Parameters:
Name Type Description
_p1 point
_p2 point
Source:
Returns:
number
Example
geometry.pointDistance( {x:100, y:100}, { x:400, y:400 } ) 

pointRectangleIntersection(_p, _r)

判断一个点是否在矩形里面
Parameters:
Name Type Description
_p point
_r rect
Source:
Returns:
Boolean
Example
geometry.pointRectangleIntersection( {x:100, y:100}, { x:0, x2: 200, y:0, y2: 200 } ) 

radians(_angle)

从角度获取弧度
Parameters:
Name Type Description
_angle Number
Source:
Returns:
Type
Number
Example
geometry.radians( 180 )