Vector/Point maths in Python

Hi all,

I’m currently implementing a FABRIK inverse kinematics solver, and I’m running into a small problem with the vector/point maths. Sadly my vector maths isn’t 100% anyway, so I may be in over my head already, but I’m trying to muddle through regardless. Any ideas why I can’t do this? The C++ docs appear to say I can, but there seems to be no mention of exposed C++ functionality in the Python docs (as far as I can see).

TypeError: unsupported operand type(s) for *: ‘float’ and ‘panda3d.core.LPoint3f’

Thanks.

Ah, I believe that I’ve run into this before: the problem is the order in which you’re multiplying them. Simply put, and operator exists for “vector * float”, but not for “float * vector”–I imagine that this is because the latter would presumably involve defining a new method for floats, while the former is just a method defined in Panda’s vector class.

In short, this should fail:

myVec = Point(5, 5, 5)
myFloat = 0.5

result = myFloat*myVec

While this should succeed:

myVec = Point(5, 5, 5)
myFloat = 0.5

result = myVec*myFloat

Bingo. Thanks a lot. I feel kind of stupid since this possibility actually came to mind, but I dismissed it right away. Lesson learned.