AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_distance_f and vector_distance difference? (https://forums.alliedmods.net/showthread.php?t=162607)

alexx109 07-20-2011 23:58

get_distance_f and vector_distance difference?
 
Sup guys.
I was wondering, is there any difference between the vector_distance and the get_distance_f natives? both them included in the vector.inc file...

same parameters, both with Float output promising to do absolutely the same...

shouldn't one of them be removed from the API so?

meTaLiCroSS 07-21-2011 02:41

Re: get_distance_f and vector_distance difference?
 
PHP Code:

static cell AMX_NATIVE_CALL get_distance_f(AMX *amxcell *params)
{
    
cell *cpVec1 get_amxaddr(amxparams[1]);
    
cell *cpVec2 get_amxaddr(amxparams[2]);

    
Vector vec1 Vector((float)amx_ctof(cpVec1[0]), (float)amx_ctof(cpVec1[1]), (float)amx_ctof(cpVec1[2]));
    
Vector vec2 Vector((float)amx_ctof(cpVec2[0]), (float)amx_ctof(cpVec2[1]), (float)amx_ctof(cpVec2[2]));

    
REAL fDist = (REAL) (vec1 vec2).Length();

    return 
amx_ftoc(fDist);


PHP Code:

static cell AMX_NATIVE_CALL vector_distance(AMX *amxcell *params)
{
    
cell *cAddr get_amxaddr(amxparams[1]);
    
cell *cAddr2 get_amxaddr(amxparams[2]);

    
REAL fX amx_ctof(cAddr[0]);
    
REAL fY amx_ctof(cAddr[1]);
    
REAL fZ amx_ctof(cAddr[2]);
    
REAL fX2 amx_ctof(cAddr2[0]);
    
REAL fY2 amx_ctof(cAddr2[1]);
    
REAL fZ2 amx_ctof(cAddr2[2]);

    
Vector vVector Vector(fXfYfZ);
    
Vector vVector2 Vector(fX2fY2fZ2);

    
REAL fLength = (vVector vVector2).Length();

    return 
amx_ftoc(fLength);


:crab:

jim_yang 07-21-2011 03:19

Re: get_distance_f and vector_distance difference?
 
no differences.


All times are GMT -4. The time now is 00:45.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.