2010/5/25 fk <[email protected]>:
> Am 24.05.2010 13:43, schrieb luper rouch:
>> Yes I certainly missed that in the docs, sorry. So, arithmetic
>> operators are some kind of static methods, is the following the right
>> way to implement them ?
>>
>>    def __mul__(op1, op2):
>>        if isinstance(op1, Quaternion):
>>            return from_c_obj((<Quaternion>op1).wrapped[0] * <float>op2)
>>        else:
>>            return from_c_obj((<Quaternion>op2).wrapped[0] * <float>op1)
>>
>> And for intransitive operations like __div__ return NotImplemted in
>> the reversed case :
>>
>>    def __div__(op1, op2):
>>        if isinstance(op1, Quaternion):
>>            return from_c_obj((<Quaternion>op1).wrapped[0] / <float>op2)
>>        else:
>>            return NotImplemented
>>
>
> Slightly-or-not-so-slightly off-topic, but are you by any chance
> wrapping Bullet? I also started with that [1] (unfortunately, my
> dedication has already begun to decline). D'you have any code or site
> online somewhere?
>

Yes I just started a wrapper for Bullet : http://github.com/flupke/ballistics

It looks very similar to yours, except that I try to closely stick to
the C++ API (names, modules organisation, etc...), so I can avoid
rewriting the whole documentation :) (I will eventually add helpers to
ease setting up objects)

For now, I ported the Hello World example from the tutorial (see
ballistics/tests/dynamics/world/test_discrete.py) and got a ball
bouncing... There is still a long way before wrapping the whole API !

Cheers,
--
Lup
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to