Wrong manual in level Bombing


#1

[QUOTE]
Use your maths know-how to solve this riddle! Remember the mythical phrase S(O/H) C(A/H) T(O/H).
[/QUOTE]
where
S – is sinus(angle)
C – is cosinus(angle)
T - is tangent(angle)
A is the adjacent side, O – the opposing side
Is not right!

So, right “mythical phrase” is that:
S(A/H), C(A,H), T(O/A)


#2

May you help me with my code?I can’t say the angle.
while True:
enemy = hero.findNearestEnemy()
if enemy:

Find the vector of attack

G=Vector(enemy.pos.x,enemy.pos.y)

Use trigonometry to find the the angle in Radians!

A=Vector.subtract(hero.pos, enemy.pos)
if enemy.pos.x>hero.pos.x:
B=enemy.pos.x-hero.pos.x
else:
B=hero.pos.x-enemy.pos.x
degree=B/A

The answer must be in Degrees!

To convert Radians to Degrees multiply by (180 / Math.PI)

degree=degree*180/Math.PI

Say the angle!

hero.say(degree)


#3

I not use vectors, only function atan2.
That my code:

    O=Math.abs(enemy.pos.y -self.pos.y) 
    A=Math.abs(enemy.pos.x-self.pos.x)
    angle=Math.atan2(O,A)
    angle=angle*180/Math.PI
    if enemy.pos.x<self.pos.x:
        angle=180-angle
    hero.say(angle)

#4

I pass it. Thank you so much. But i still don’t understand it


#5

This is trigonometry. Learn it )))


#6

like this?


#7

Yah. One moment. Function ATAN2 return value [-PI/2;PI/2], so if angle>90 degree, need calculate revers angle: 180-angle


#8

So angle=Math.atan2(O,A) means angle=O/A?


#9

yes. Only if angle <90 deg (or PI/2 in radians)


#10

so this is for negative angles?


#11

m? I dont know, what do you mean? If ogres are UNDER the hero?


#12

like enemy.pos.x<hero.pos.x,so A will negative. To prevent this, we have if enemy.pos.x<self.pos.x:
angle=180-angle


#13

like enemy.pos.x<hero.pos.x


#14

like enemy.pos.x>hero.pos.x


#15

If ogr is to left from hero, then angle will >90 deg. Then:


Fuction atan2 return angle Ф (Theta). We need to calculate (?). It is equal to 180- atan2()

Understand?


#16

I double checked and fixed the ‘mythical’ phrase with the correct one:
s(o/h), c(a/h), t(o/a).