科恩-萨瑟兰
pylineclip的Python项目详细描述
线剪裁
lineClipping.jl
用于julia的cohen-sutherland线裁剪算法。 输入标量,输出交集长度,如果没有交集,则为None
。lineclipping.f90
cohen-sutherland直线裁剪算法 大规模并行的coarray现代fortran。输入标量或数组, 如果没有交集,则输出交集或NaN
。lineClipping.py
python的cohen-sutherland线裁剪算法。 输入标量,输出交集长度,如果没有交集,则为None
。
安装
Python
python -m pip install -e .
fortran
如果要使用Fortran Cohen-Sutherland线裁剪模块 直接(可选):
cd bin
cmake ..
make
用法
与教科书实现的主要区别在于 如果没有线的交点,则哨兵值(NaN,None,Nothing) 带盒子。
Python
importpylineclip.lineclippingaslcx3,y3,x4,y4=lc.cohensutherland((xmin,ymax,xmax,ymin,x1,y1,x2,y2)
如果没有交集,则返回(None, None, None, None)
。
fortran
lineclipping.f90有两个子例程。 Pick Ccohensutherland,如果你从C/C++/Python调用,它不能容忍相加的形状数组。 它是cohensutherland的一个很薄的包装器,它是元素(可以处理标量或任何秩数组)。
Fortran程序只需使用
use lineclippingcall cohensutherland(xmin,ymax,xmax,ymin,x1,y1,x2,y2)
参数是:
INPUTS
------
xmin,ymax,xmax,ymin: upper left and lower right corners of box (pixel coordinates)
INOUT
-----
x1,y1,x2,y2:
in - endpoints of line
out - intersection points with box. If no intersection, all NaN
朱莉娅
simliar到python,除非nothing
在没有交集的情况下返回
找到了。
cohensutherland(xmin,ymax,xmax,ymin,x1,y1,x2,y2)