Raised This Month: $ Target: $400
 0% 

wierd results from get_distance


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-20-2007 , 01:21   Re: wierd results from get_distance
Reply With Quote #1

sqroot( ( x1 - x2 )^2 + sqroot( ( y1 - y2 )^2 + ( z1 - z2 )^2 )^2 )

This only works if: x1 >= x2 && y1 >= y2 && z1 >= z2

I believe this would be the correct useage, made this just to test some weeks ago.

Code:
stock cust_get_distance(const Origin1[3], const Origin2[3]) {         new Differences[3]         if ( Origin2[0] > Origin1[0] )         Differences[0] = Origin2[0] - Origin1[0]     else         Differences[0] = Origin1[0] - Origin2[0]         if ( Origin2[1] > Origin1[1] )         Differences[1] = Origin2[1] - Origin1[1]     else         Differences[1] = Origin1[1] - Origin2[1]         if ( Origin2[2] > Origin1[2] )         Differences[2] = Origin2[2] - Origin1[2]     else         Differences[2] = Origin1[2] - Origin2[2]         return sqroot(power_by_2(Differences[2]) + power_by_2(sqroot(power_by_2(Differences[0]) + power_by_2(Differences[1])))) } stock Float:cust_get_distance_f(const Float:Origin1[3], const Float:Origin2[3]) {         new Float:Differences[3]         if ( Origin2[0] > Origin1[0] )         Differences[0] = Origin2[0] - Origin1[0]     else         Differences[0] = Origin1[0] - Origin2[0]         if ( Origin2[1] > Origin1[1] )         Differences[1] = Origin2[1] - Origin1[1]     else         Differences[1] = Origin1[1] - Origin2[1]         if ( Origin2[2] > Origin1[2] )         Differences[2] = Origin2[2] - Origin1[2]     else         Differences[2] = Origin1[2] - Origin2[2]         return floatsqroot(power_by_2_f(Differences[2], 2) + power_by_2_f(floatsqroot(power_by_2_f(Differences[0]) + power_by_2_f(Differences[1])))) } stock Float:power_by_2_f(Float:num)     return num * num     stock power_by_2(num)     return num * num

Last edited by [ --<-@ ] Black Rose; 02-20-2007 at 01:27.
[ --<-@ ] Black Rose is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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