You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
#ifndef SoSimplifyIncluded
|
|
#define SoSimplifyIncluded
|
|
|
|
library SoSimplify needs SoBase initializer SimplifySetup
|
|
|
|
// 坐标间距
|
|
/*
|
|
求 (x1, y1) 到 (x2, y2) 的距离
|
|
*/
|
|
function SoSpacing takes real x1, real y1, real x2, real y2 returns real
|
|
local real fx = x2 - x1
|
|
local real fy = y2 - y1
|
|
return SquareRoot(fx * fx + fy * fy)
|
|
endfunction
|
|
|
|
// 坐标间方向
|
|
/* 参数: x1, y1, x2, y2
|
|
求 (x1, y1) 到 (x2, y2) 的方向
|
|
*/
|
|
function SoC2A takes real x1, real y1, real x2, real y2 returns real
|
|
return bj_RADTODEG * Atan2(y2 - y1, x2 - x1)
|
|
endfunction
|
|
|
|
/* 取绝对值 */
|
|
private function SRabs takes real a returns real
|
|
if (a<0) then
|
|
return -a
|
|
else
|
|
return a
|
|
endif
|
|
endfunction
|
|
|
|
//三点所在的矩形面积
|
|
function SoGetRectAera takes real xa,real ya,real xb,real yb,real xc,real yc returns real
|
|
return SRabs( xa*yb - xa*yc + xb*yc - xb*ya + xc*ya - xc*yb )
|
|
endfunction
|
|
|
|
function SoSimplifySetup takes nothing returns nothing
|
|
// 初始化一些设置
|
|
endfunction
|
|
|
|
endlibrary
|
|
|
|
#endif //SoSimplifyIncluded |