Quote:
Originally Posted by Lorenc_
NEW FUNCTION
pawn Код:
stock Float: Pythagoras2(Float: val1, Float: val2, bool: shortside = false) return shortside == true ? (floatsqroot(floatsub(floatmul(val1, val1), floatmul(val2, val2)))) : (floatsqroot(floatadd(floatmul(val1, val1), floatmul(val2, val2))));
OLD FUNCTION
pawn Код:
stock Pythagoras(Float: val1, Float: val2, bool: shortside = false) { new Float: cal ; if(shortside) cal = ((val1 * val1) - (val2 * val2)); else cal = ((val1 * val1) + (val2 * val2)); cal = floatsqroot(cal); return cal; }
Example 1
pawn Код:
new Float: X = Pythagoras(90, 20, false); printf("The hypotenuse of this is %f", X);
Untested this little example though should work!
Example 1
pawn Код:
new Float: X = Pythagoras(56, 20, true); printf("The height of this is %f", X);
Untested this little example though should work!
If I did something wrong, tell me
PS.
We're on

|
hmm,
Pytahoras says:
if we put in some numbers:
a = 6
b = 3
------
c=?

c=15 cm
now your formula:
cal = ((val1 * val1) - (val2 * val2));
val1 = 6
val2 = 3
--------
cal=?
cal=((val1 * val1) - (val2 * val2))
cal=27 cm
we get difreent result, something is wrong :S