Problem with the generated example code

Hi everybody,

I tried the python example code ‘pga3d.py’ from the /tools section and got a problem at the first step. It seems like the product does not work as expected in the line

ROT = rotor(math.pi/2.0,E1*E2)

returning

ZeroDivisionError Traceback (most recent call last)
~/Downloads/pga3d.py in
415
416 # Elements of the even subalgebra (scalar + bivector + pss) of unit length are motors
→ 417 ROT = rotor(math.pi/2.0,E1*E2)
418
419 # The outer product ^ is the MEET. Here we intersect the yz (x=0) and xz (y=0) planes.

~/Downloads/pga3d.py in rotor(angle, line)
374 # A rotor (Euclidean line) and translator (Ideal line)
375 def rotor(angle,line):
→ 376 return math.cos(angle/2.0) + math.sin(angle/2.0)*line.normalized()
377
378 def translator(dist,line):

~/Downloads/pga3d.py in normalized(a)
370
371 def normalized(a):
→ 372 return a*(1/a.norm())
373
374 # A rotor (Euclidean line) and translator (Ideal line)

ZeroDivisionError: float division by zero

Whenever I multiply a basis element by itself it returns 0.
Is there a problem with my python setup?

1 Like

Apparently, the website section /tools contains old example code.
The working version is here https://github.com/enkimute/ganja.js/tree/master/codegen/python

There also appears to be a problem with the generated code examples in the /tools section for the PGA2D. For example, the inner (Dot) and outer (Wedge) products appear to be missing a single line of code which sets the first element of the multi-vector result. So does the full geometric product. For the geometric product I had to work out what the missing line should have been. The same mistake(?) appears in all the different languages provided (cpp, cs, py, rs). I could not find these 2D examples code on the github site to see if it had corrected. Am I missing something?

The generator online at the tools section of bivector.net, has been updated to the latest generator. These issues should be fixed.

Cheers,

Steven.

1 Like