Archived

This topic is now archived and is closed to further replies.

code

This topic is 5900 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I got this code for computing a Oriented Bounding Box from www.magic-software.com. Can someone explain to me whats happening and how to use this function.
void Box2::ComputeVertices (Vector2 akVertex[4]) const
{
    Vector2 akEAxis[2] =
    {
        m_afExtent[0]*m_akAxis[0],
        m_afExtent[1]*m_akAxis[1]
    };

    akVertex[0] = m_kCenter - akEAxis[0] - akEAxis[1];
    akVertex[1] = m_kCenter + akEAxis[0] - akEAxis[1];
    akVertex[2] = m_kCenter + akEAxis[0] + akEAxis[1];
    akVertex[3] = m_kCenter - akEAxis[0] + akEAxis[1];
}
 
The code is called MgcBox2.cpp under 2d core.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ok i''ll try... It was two years since i last touched c++ though.

You give the function an array of four vertices "Vector2 akVertex[4]", then the function takes these vertices and arranges them a set distance from the objects (Box2) center.

You MUST pass an array to the function.

Share this post


Link to post
Share on other sites