跳转到主要内容

Python接口到ganja.js

项目描述

pyganja

PyPI

基于cefpython和ganja.js的几何代数可视化库

这是一个从脚本和jupyter笔记本中可视化几何代数的模块,它依赖于ganja.js来渲染几何代数对象。如果您从脚本中调用其API,它将在cefpython窗口中渲染它们;如果您在笔记本中,它可以直接在笔记本本身中渲染。

用法

此库并非专门与clifford库相关联,但设计得与其良好配合。结合这两个库时使用的语法示例

from clifford.tools.g3c import random_line
from pyganja import *

draw([random_line() for i in range(10)])

产生: 随机线

可以在同一场景中用不同的颜色和透明度绘制多个对象等级

from clifford.g3c import *
from clifford.tools.g3c import *
from pyganja import *

P1 = up(random_euc_mv()*0.1)
P2 = up(random_euc_mv()*0.1)
P3 = up(random_euc_mv()*0.1)
P4 = up(random_euc_mv()*0.1)

# The sphere is the outer product of all 4
S = (P1^P2^P3^P4).normal()

# A line is the outer product of 2 with ninf
L = P1^P2^einf

# The inversion of a line in a sphere is a circle
C = S*L*S

# The tangent to the circle at the intersection point is the reflected line
Ldash = (P1|C)^einf

# The tangent plane to the sphere at the intersection point can be easily found
Ppi = (P1|S)^einf

sc = GanjaScene()
sc.add_objects([P1,P2,P3,P4], color=Color.BLACK)
sc.add_objects([L], color=Color.BLUE)
sc.add_objects([Ldash], color=Color.RED)
sc.add_objects([C], color=Color.RED)
sc.add_objects([S*einf*S], color=Color.BLACK)
sc.add_objects([S])
sc.add_objects([Ppi], color=rgb2hex((0,100,0))+int('70000000',16))
draw(sc,scale=0.5)

产生: 球面反射

安装

git clone git@github.com:hugohadfield/pyganja.git
cd pyganja
python3 setup.py install

待办事项

这仍然是一个非常正在进行中的项目,目前它只处理PGA和CGA

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息

源代码分发

pyganja-0.0.15.tar.gz (45.0 kB 查看哈希值)

上传于 源代码

构建分发

pyganja-0.0.15-py3-none-any.whl (45.0 kB 查看哈希值)

上传于 Python 3

由以下组织支持