floatadd - error
#1

pawn Код:
stock GetDistanceBetweenPoints(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) //By Gabriel "Larcius" Cordes
{
        return floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2)));
}
when I complile I get the following error:
pawn Код:
./assets/functions.pwn(5443) : warning 213: tag mismatch
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase

Header size:          18780 bytes
Code size:          1308364 bytes
Data size:         110316400 bytes
Stack/heap size:      16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:111659928 bytes

1 Warning.
Line 5443
pawn Код:
floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2)));
This used to work before..
Reply
#2

https://sampwiki.blast.hk/wiki/VectorSize
Reply
#3

PHP код:
#define GetDistanceBetweenPoints(%1,%2,%3,%4,%5,%6)    VectorSize((%1)-(%4),(%2)-(%5),(%3)-(%6)) 
Reply
#4

Quote:
Originally Posted by skaTim
Посмотреть сообщение
pawn Код:
floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2)));
Everyone keeps copying this, but apparently no-one seems to question why the original author bothered using the functions instead of the normal operators. You can't really get around floatsqroot because there isn't an operator for that, but that line is essentially this:

Код:
floatsqroot((x1 - x2) * (x1 - x2)) + floatsqroot((y1 - y2) * (y1 - y2)) + floatsqroot((z1 - z2) * (z1 - z2))
Which, IMO, makes it much more obvious what is going on. VectorSize is currently the fastest, though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)