lethexa-motionpredict.js
function(myPos, myVelo, targetPos, targetVelo) {
    var posDiff = mf.sub(targetPos, myPos);
    var veloDiff = mf.sub(targetVelo, myVelo);
    var approachSpeed = mf.dot(posDiff, veloDiff);
    var posDiffLength = Math.sqrt(mf.lengthSquared(posDiff));
    if( posDiffLength <= 0.0 )
      return 0.0;
    return -approachSpeed / posDiffLength;
  }
function(myPos, myVelo, targetPos, targetVelo) {
    var posDiff = mf.sub(targetPos, myPos);
    var veloDiff = mf.sub(targetVelo, myVelo);
    var approachSpeed = mf.dot(posDiff, veloDiff);
    var posDiffLength = Math.sqrt(mf.lengthSquared(posDiff));
    if( posDiffLength <= 0.0 )
      return 0.0;
    return -approachSpeed / posDiffLength;
  }
function ( myPos , myVelo , targetPos , targetVelo ) { var posDiff = mf . sub ( targetPos , myPos ) ; var veloDiff = mf . sub ( targetVelo , myVelo ) ; var approachSpeed = mf . dot ( posDiff , veloDiff ) ; var posDiffLength = Math . sqrt ( mf . lengthSquared ( posDiff ) ) ; if ( posDiffLength <= 0.0 ) return 0.0 ; return - approachSpeed / posDiffLength ; }
Calculates the approachspeed of the target to my position.
@method calcApproachSpeed
@param myPos {Vector3d} The position of me.
@param myVelo {Vector3d} The velocity of me.
@param targetPos {Vector3d} The position of the target.
@param targetVelo {Vector3d} The velocity and direction in which the target is moving.
@return {Number} The speed at which the target is approaching.
@for motionpredict
Calculates the approachspeed of the target to my position .