This is code from Transform.h in ROS (link) in the Transform class.
/**@brief Return the transform of the vector */
TFSIMD_FORCE_INLINE Vector3 operator*(const Vector3& x) const
{
return (*this)(x);
}
Can someone explain what this piece of code is doing? Here is what I think (for context, I have a few years experience as a C programmer, first time developing in C++.)
The function is called when the following is invoked
object_of_type_Transform * object_of_type_Vector3
It then casts the Vector3 object into a Transform object and returns that as a result (I am quite unclear about how this can be possible as the two types do not seem compatible).
But the result being returned is a Vector3... and this is where my mental model breaks down.
Additionally, the function is supposed to be transforming a Vector3 point based on the Transform class... so my understanding is definitely flawed somewhere.
I would appreciate any insights.
Thanks
EDIT
Thanks for the reply! The function right above is:
/**@brief Return the transform of the vector */
TFSIMD_FORCE_INLINE Vector3 operator()(const Vector3& x) const
{
return Vector3(m_basis[0].dot(x) + m_origin.x(),
m_basis[1].dot(x) + m_origin.y(),
m_basis[2].dot(x) + m_origin.z());
}
/**@brief Return the transform of the vector */
TFSIMD_FORCE_INLINE Vector3 operator*(const Vector3& x) const
{
return (*this)(x);
}
I understand, now, whats going on. Thanks again.