2
\$\begingroup\$

I'm using ASSIMP's built in aiVector3t class but I can't find any mention of dot product or cross product in the class documentation.

Are these operations defined? If so what is the syntax?

\$\endgroup\$
3
\$\begingroup\$

These operations are defined, but not documented correctly by the auto documenting tool (doxygen) because they are not members of the aiVector3t class.

You can find them by looking through the ASSIMP source file "vector3.inl"

// cross product
template <typename TReal>
AI_FORCE_INLINE  aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2)   {
    return aiVector3t<TReal>( v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x);
}

The dot product is also in there, although it took me longer to find it as it was mislabelled "scalar product" in the comment

// scalar product
template <typename TReal>
AI_FORCE_INLINE TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
    return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}

Also useful, not in the docs is a typedef for a vector of floats ;

typedef aiVector3t<float> aiVector3D;

So you can all of these them as follows;

    aiVector3D up(0.0f,1.0f,0.0f);
    aiVector3D forward(0.0f,0.0f,1.0f);

    aiVector3D right=forward^up; //get cross product

    float d=forward*up; //get dot product
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.