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 conformal GA
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.12.tar.gz
.
File metadata
- Download URL: pyganja-0.0.12.tar.gz
- Upload date:
- Size: 36.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40f01e528f74ced063380af4e3ec27b3ad022ec05254a8d0bb108ac5d626bf2d |
|
MD5 | 1a5638ee0637f784e4740ce561b3eab9 |
|
BLAKE2b-256 | 5c086e71491319740a4a6641c71c2a2c0437bfc3852e98d1b3f416530ac15229 |
File details
Details for the file pyganja-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: pyganja-0.0.12-py3-none-any.whl
- Upload date:
- Size: 36.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa997c9aaf09e9346c7ece5d999afb75fa80e20d8fa2edfa3cf1e5993ab04ac5 |
|
MD5 | c8d98fd9c6219e5c615cb92ae56dd0ee |
|
BLAKE2b-256 | 283fae29fbfdf630eeab0fe90227c13aabbf700fa9e28fcd74e397717a7abd12 |