开单纯形n维梯度噪声函数。

opensimplex的Python项目详细描述


build-statuscoverage-status

OpenSimplex noise is an n-dimensional gradient noise function that was developed in order to overcome the patent-related issues surrounding Simplex noise, while continuing to also avoid the visually-significant directional artifacts characteristic of Perlin noise.

这只是kurt spencer原始代码的一个python端口,发布给 公共领域,并整齐地包装在一个包里。

用法

初始化:

>>> from opensimplex import OpenSimplex
>>> tmp = OpenSimplex()
>>> print (tmp.noise2d(x=10, y=10))
0.732051569572

可选地,类接受种子值:

>>> tmp = OpenSimplex(seed=1)
>>> print (tmp.noise2d(x=10, y=10))
-0.4790979022623557

种子必须是有效的python编号。它在内部用来产生一些 排列阵列,用于产生噪声。

如果没有提供,则类将默认使用0作为种子

可用的类方法:

opensimplex.noise2d(x,y)
从x,y坐标生成2d opensimplex噪声。
opensimplex.noise3d(x,y,z)
从x、y、z坐标生成3d opensimplex噪声。
opensimplex.noise4d(x,y,z,w)
从x、y、z、w坐标生成4d opensimplex噪声。

运行测试和基准:

首先制作一个virtualenv并安装开发要求:

virtualenv venv source venv/bin/activate pip install -r requirements.txt

然后简单地运行测试:

make test
或基本基准:
制定基准

常见问题解答

  • 这与原始专利的区别是否足以避免任何真正的麻烦?

    If you read the patent claims:

    Claim #1 talks about the hardware-implementation-optimized gradient generator. Most software implementations of Simplex Noise don’t use this anyway, and OpenSimplex Noise certainly doesn’t.

    Claim #2(&3&4) talk about using (x’,y’,z’)=(x+s,y+s,z+s) where s=(x+y+z)/3 to transform the input (render space) coordinate onto a simplical grid, with the intention to make all of the “scissor-simplices” approximately regular. OpenSimplex Noise (in 3D) uses s=-(x+y+z)/6 to transform the input point to a point on the Simplectic honeycomb lattice so that the simplices bounding the (hyper)cubes at (0,0,..,0) and (1,1,…,1) work out to be regular. It then mathematically works out that s=(x+y+z)/3 is needed for the inverse transform, but that’s performing a different (and opposite) function.

    Claim #5(&6) are specific to the scissor-simplex lattice. Simplex Noise divides the (squashed) n-dimensional (hyper)cube into n! simplices based on ordered edge traversals, whereas OpenSimplex Noise divides the (stretched) n-dimensional (hyper)cube into n polytopes (simplices, rectified simplices, birectified simplices, etc.) based on the separation (hyper)planes at integer values of (x’+y’+z’+…).

    Another interesting point is that, if you read all of the claims, none of them appear to apply to the 2D analogue of Simplex noise so long as it uses a gradient generator separate from the one described in claim #1. The skew function in Claim #2 only applies to 3D, and #5 explicitly refers to n>=3.

    And none of the patent claims speak about using surflets / “spherically symmetric kernels” to generate the “images with texture that do not have visible grid artifacts,” which is probably the biggest similarity between the two algorithms.

学分

  • Kurt Spencer-原创作品
  • 一个svensson-python端口和包作者
  • creamycookie-清理和优化

许可证

当库尔特将原著公之于众时 正在使用麻省理工学院的许可证。详情请参阅文件许可证。

预期产量

二维噪声(带默认种子):

images/noise2d.png

3D噪音:

images/noise3d.png

4D噪音:

images/noise4d.png

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java数组。按字符串排序   如何使用Netbeans设置Java打印的页面大小   java有没有一种方法可以获取sparkjava/嵌入式jetty服务器的主线程执行器?   正则表达式Java正则表达式:需要更简单的解决方案   无法使用java解析XML   MySQL Java JDBC:如何获取自动递增列的名称?   java错误:“限定符必须是表达式”Android Studio   Spring+java。lang.NoClassDefFoundError:weblogic/logging/LogEntryFormatter   java将JList插入GridLayout   listview中的java Get selected复选框   使用CriteriaBuilder的java JPA左外部联接会导致错误:不允许部分对象查询维护缓存或进行编辑   java循环双链接列表addToHead和print   java更好地检测三角形按钮(libgdx)   java ConcurrentHashMap迭代保证人   java如何获取控制台。通过webdriver记录信息?   java Javafx阶段为空   java如何使用apachetika从excel文件中访问空白单元格   java使用SQlite数据库列填充AutoCompleteTextView   java如何在不使用idea构建整个maven项目的情况下运行主方法?