The brain doesn't do trig at all for this problem. It uses a lot of tricks to estimate the solution.
First we should be careful, though. Your example isn't an example of calculating the trig, it's an example of assuming or completing an image. This is in line with gestalt psychology, where the brain takes less information than necessary to truly know an answer and guesses the best solution based on several rules.
Now if our example is an actual moving object, such as a ball, we come to the aforementioned tricks.
One trick is constant re-estimation. Imagine you had a computer with a very naive way to calculate the movement of our ball - it looks at where the ball has come from and assumes a linear path. This path is probably wrong, but let's say we do this ~50 times a second. Each path is wrong, but they will be increasingly accurate, and each one may be sufficient to have a general idea of where the ball is headed, until it is accurate enough that we can catch the ball. Our brain probably does a lot better than a linear estimation, but it still takes some form of this shortcut, trading accuracy for a less difficult computation because we can redo and correct our calculations as we go.
Another trick is our short term knowledge of the path an object has taken and the fact that most objects take very simple paths. If I gave you a graph of the ball's movement from 0-10 seconds, chances are you can draw 10-20 seconds pretty accurately. This helps us with objects that are moving slowly or are far away, where we get to see them for long enough time to see an overall pattern.
These first two aren't so successful for predicting living organisms, which often move too fast and complexly for them. In this case, we largely rely on previous knowledge. We know few things leave the ground, and if they do they usually come down again very soon (often in an arc). We know most things accelerate downhill, decelerate uphill, and follow the curves of the surface they are on. For the things that are even less predictable, we learn to see the subtle preparatory movements involved: we see the slight turn of the leg before a runner changes direction, the crouch before a jump, the raising of wings before flying. Indeed when things don't follow these rules, or optical illusions make things appear to not follow these rules (rooms that look normal but are weirdly shaped), it amuses or confuses us.
Depending on the type of programming you do/your formal education, you may be very aware that when the optimal solution takes more resources to find than it is actually worth, programmers opt for estimations of near-optimal solutions. In a living creature, the priority is coming up with a solution that is near-optimal in enough time to react to potential danger (something flying towards you). In this way, the brain's sensory problem is an extreme version of the programming problem of coming 'close enough' in the time allotted. Specifically this is most similar to online problems where solutions must be optimal for an unknown amount of inputs as each input comes in.