pinocchio
pinocchio copied to clipboard
[spatial.2] operator internal naming
Change the name of operators. C++ operators are only trivial inline methods, while the code is in methods with an ad-hoc name. The name was yet taken from Python standards (for example plus for operator+, eq for operator==). They are now renamed following Eigen standards (add for operator+, isEqual for operator==).
Whatever the choice, we should document the exhaustive list of internal operator naming for reference.
We need: Addition a+b Substraction a-b Multiplication a*b Equality test a==b In place addition a+=b In place substraction a-=b Allocation a=b Cross product a^b Dot product dot(a,b) Action a.se3action(b) Action inverse a.se3actionInv(b)
For future reference Python operators are here: https://docs.python.org/2/library/operator
For in-place operators, the internal operator typically should be implemented with an opposite structure (sorry this is not very clear), i.e.
Template <D2>
D& operator+= ( const D2 & d2 )
Would typically be implemented in D2 as
D& D2::__peq__( D& d ) { ... return D; }
This is the opposite convention used e.g in Python with __iadd__
which then makes Python convention directly suitable.
We will use a mix: the same convention as in Eigen, but with XXX in prefix and suffix, and ending with impl when needed. For example: setTo __setTo__impl
Recall that there is possibly a problem with += (and other in-place operators). A+=B can be implemented as A.iadd(B) or as B.addTo(A). B.addTo(A) should be used first when possible. We may need to discuss the convention is A.iadd(B) is necessary.