Python interface to ganja.js
Project description
pyganja
Visualisation library for geometric algebra with cefpython and ganja.js
This is a module for visualing Geometric Algebra from scripts and also from jupyter notebooks, it relies on ganja.js to render Geometric Algebra objects. If you are calling its api from a script it will render them in a cefpython window or if you are in a notebook it can simply render in the notebook itself.
Use
This library is not specifically tied to the clifford library but is designed to work well with it. An example of the syntax that you would use combining these two libraries:
from clifford.tools.g3c import random_line
from pyganja import *
draw([random_line() for i in range(10)])
Produces:
Mulitple grades of object can be drawn in the same scene with different colors and transparencies
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)
Produces:
Installation
git clone git@github.com:hugohadfield/pyganja.git
cd pyganja
python3 setup.py install
TODO
This is still very much a work in progress, currently it only handles PGA and CGA
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyganja-0.0.13.tar.gz
.
File metadata
- Download URL: pyganja-0.0.13.tar.gz
- Upload date:
- Size: 40.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f1ead6559a375739568321a596dd784d274918c8c1ffe66ee70d82e38c8d782 |
|
MD5 | 713a206961e357456b0e343a4a994b18 |
|
BLAKE2b-256 | f65d2be356b66e1fc42c50d29f101bd247049871230647b5a31a39918563f08a |
File details
Details for the file pyganja-0.0.13-py3-none-any.whl
.
File metadata
- Download URL: pyganja-0.0.13-py3-none-any.whl
- Upload date:
- Size: 40.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 743ededf15265286c8bf70892609918062a10eb31020f2557b70ab6e8099bcfe |
|
MD5 | 773722f0df054b513195dc12f5ab4972 |
|
BLAKE2b-256 | ce57fe0b8eecfe3e8bb6b0706706131431e291e4b16eecce3e50ad8e33ee6fa3 |