# Calculating intercept time?

**URL:** <https://forum.kirupa.com/t/calculating-intercept-time/278872>\
**Category:** programming\
**Created:** [January 6, 2009, 10:02pm UTC](https://forum.kirupa.com/t/calculating-intercept-time/278872 "2009-01-06T22:02:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![justkevin](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@justkevin](https://forum.kirupa.com/u/justkevin)\
**Post date:** [January 6, 2009, 10:02pm UTC](https://forum.kirupa.com/t/calculating-intercept-time/278872/1 "2009-01-06T22:02:13Z")

</div>

I use the following algorithm to calculate the angle to intercept between two objects (not my own algorithm, but I found it works well):

```auto

var tx:int = targetPos.x;
var ty:int = targetPos.y;
var dx:int = tx - this._x;
var dy:int = ty - this._y;
var sta:Number = Math.atan2(dy, dx);
var angle:Number = Math.asin(Math.sin(-(target.angle + Math.PI - sta)) * (target.speed / interceptSpeed)) + sta;

```

This returns the angle (in radians) for this object to intercept the target object, assuming their velocities remain constant and a solution exists (i.e., the target isn’t going to outrun us).

I’m looking for a formula to calculate when (or where) the intercept will occur. Any trig gurus know the answer?
