Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Aim angle
#1
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 Big Grin, 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!
#2
For basics of trigonometry, all you need is these three definitions:
[Image: TrigonometryMnemonic_1000.gif]

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.
#3
Thx! Now i know the basics of trigonometry!)☺ I finally i understood meaning of Sin,and other unknown things ☺
Your post is fantastic.
#4
Colobot - entertains and teaches
"Deep within all of us lives an idiot, and if you let that idiot dictate your decisions your live is going to be rough."
~ Ryan Letourneau, 2k15


Forum Jump:


Users browsing this thread: 2 Guest(s)