這是Transform類中ROS(link)中的Transform.h中的代碼。混淆(* this)指針的轉換
/**@brief Return the transform of the vector */
TFSIMD_FORCE_INLINE Vector3 operator*(const Vector3& x) const
{
return (*this)(x);
}
有人可以解釋這段代碼在做什麼嗎?以下是我認爲(上下文,我有幾年經驗的C程序員,在C首次開發++)
以下調用
object_of_type_Transform * object_of_type_Vector3
它然後當函數被調用鑄件將Vector3對象轉換爲Transform對象,並返回結果(由於這兩種類型似乎不兼容,所以我很不清楚這是如何可能的)。
但是,返回的結果是一個Vector3 ...這是我的心智模型崩潰的地方。
此外,該函數應該是基於Transform類轉換Vector3點...所以我的理解肯定是有缺陷的地方。
我將不勝感激。
感謝
編輯
感謝您的答覆!上面的功能是:
/**@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);
}
我明白,現在發生了什麼事。再次感謝。
沒有演員。 0/10不好的巨魔。 – 2013-03-15 00:41:16