Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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