# Colobot Forum - International Colobot Community

Full Version: Aim angle
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My bad, i absolutely don't know a math and geometry.
Can someone advise me about how to determine an angle between a bot and a target.
Of course it's for Flying objects.
I will really appreciate your help if you can explain it step by step, cos i don't know what COS and SIN means. (i know words , but don't know how it works)

And additional one - is there anyway to knowing is there a water or an another obstacle in front of you?
I am making manual driving bot (without using - goto, and even try don't use a move functions, only using motor())

BTW - it's such a cool game! Thx everyone for your work!
For basics of trigonometry, all you need is these three definitions:

To calculate the angle, we'll use sin(). For our purposes:
h is the distance in 3D between objects. h = distance(this.position, other.position)
o is difference in height between objects. o = other.position.z - this.position.z

Additionally you need to know that while sin takes an angle as parameter and returns a proportion, there is an inverse function that takes a proportion and returns an angle, called arcus sinus (asin()).

So the basic targetting code is:
Code:
```float h = distance(this.position, other.position); float o = other.position.z - this.position.z; float angle = asin(o/h); aim(angle);```

(be aware that I wrote this without checking in game so there may be an error somewhere)

For detecting obstacles in front, you can use radar() with the extended syntax (see SatCom for more info). To detect water you need topo() function and some more trigonometry.
Thx! Now i know the basics of trigonometry!)☺ I finally i understood meaning of Sin,and other unknown things ☺