Modding MI

Trigonometry
          Basics of Trigonometry
          Trigonometry in Actionscript
          Trigonometry in Madness Interactive



Basics of Trigonometry
Pythagoras made a formula to work out the hypotenuse of any triangle with one corner of 90°.
      a = Side A
b = Side B
c = Hypotenuse
a2 + b2 = c2
√(a2+b2) = c



Trigonometry in Actionscript
It works the same way in Actionscript, but has to be written differently as Actionscript doesn't support Powers or the Square Root symbol (√).
      a = Side A
b = Side B
c = Hypotenuse
(a*a)+(b*b) = c*c
Math.sqrt((a*a)+(b*b)) = c
However, commonly in Actionscript, you need to know the difference between two points both vertically and horizontally - as you do not know the length of Side A or Side B.

      p1 = Point 1
p2 = Point 2
p1x = p1._x
p1y = p1._y
p2x = p2._x
p2y = p2._y
a = p2x-p1x
b = p2y-p1y
c = Hypotenuse
(a*a)+(b*b) = c*c
Math.sqrt((a*a)+(b*b)) = c



Trigonometry in Madness Interactive
Trigonometry is used in Madness Interactive to find the distance between two objects (the hypotenuse). For example, an explosion works out the distance between it and any people, so it can damage the different people appropriately.

     This shows an explosion occuring near a person. The explosion tests whether it is near anyone using trigonometry.
      p1 = Explosion
p2 = Person
p1x = p1._x
p1y = p1._y
p2x = p2._x
p2y = p2._y
a = p2x-p1x
b = p2y-p1y
c = Hypotenuse
(a*a)+(b*b) = c*c
Math.sqrt((a*a)+(b*b)) = c

Frame 3
Line 209
xd=t._x-x;
yd=t._y-y;
d=Math.sqrt(xd*xd+yd*yd);

This is exactly what I showed above.

      t = Person
x = Explosion _x
y = Explosion _y
xd = t._x-x
yd = t._y-y
d = Hypotenuse
d = Math.sqrt(xd*xd+yd*yd)