# Wrong manual in level Bombing

[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)

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

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

degree=degree*180/Math.PI

# Say the angle!

hero.say(degree)

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)``````

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

This is trigonometry. Learn it )))

like this?

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

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

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

so this is for negative angles?

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

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

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

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

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?

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