biVector forum

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?

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