Skip to main content

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: Random lines

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: Sphere reflection

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyganja-0.0.14.tar.gz (43.0 kB view details)

Uploaded Source

Built Distribution

pyganja-0.0.14-py3-none-any.whl (43.8 kB view details)

Uploaded Python 3

File details

Details for the file pyganja-0.0.14.tar.gz.

File metadata

  • Download URL: pyganja-0.0.14.tar.gz
  • Upload date:
  • Size: 43.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for pyganja-0.0.14.tar.gz
Algorithm Hash digest
SHA256 1d724a1f61eda2216499ebcdc3e65e6f80d9a0bf2339c5b3ed3ee0afb2066f66
MD5 b48f2f6fd1c9735bb07e9117822a4fc1
BLAKE2b-256 d45f7df9e93b302cc2c4918bd8d05737259f877ed9b9568157e4d850a767f1da

See more details on using hashes here.

File details

Details for the file pyganja-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: pyganja-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 43.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for pyganja-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 6a97bd53f9cb05d44d81720582b6b91e2cd504e6e1377434edd2e0877971e940
MD5 f9637dd674159a930556d9003a12fbad
BLAKE2b-256 3492d67b6a578762d88376e30a57d80cb4a427e680b8496f245f10acb575d0b1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page