Navigation Menu

Skip to content

Commit

Permalink
fix projection algorithm to ensure smooth dragon motion
Browse files Browse the repository at this point in the history
  • Loading branch information
rsaxvc committed Apr 7, 2012
1 parent 437176b commit a158100
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dragon_practice/position.cpp
Expand Up @@ -17,10 +17,11 @@ float position::distanceTo( const position & rhs)const
return sqrt( square( x - rhs.x ) + square( y - rhs.y ) + square( z - rhs.z ) );
}

position position::projectTo( const position & rhs, float distance )const
position position::projectTo( const position & rhs, float projection_dist )const
{
//fixme - make this a projection instead of an averager
position retn(*this,rhs);
float true_dist = distanceTo( rhs );
float ratio = projection_dist / true_dist;
position retn( x + (rhs.x - x) * ratio, y + (rhs.y - y) * ratio, z + (rhs.z - z) * ratio);

return retn;
}

0 comments on commit a158100

Please sign in to comment.