Raised This Month: $ Target: $400
 0% 

Other Type of 'get_distance()'


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
atomen
Veteran Member
Join Date: Oct 2006
Location: Stockholm, Sweden
Old 08-27-2008 , 13:38   Other Type of 'get_distance()'
Reply With Quote #1

Hi!

As you know get_distance calculates the distance(units) between 2 X, Y and Z.
It returns the units between them. But let's say you only want to calculate the origins which is the furthest from each other.

In this example, let's say the 2 X origins are furthest from each other.
How to calculate the distance in units between them and don't include the 2 Y and Z origins??

This is just how It could look(illustration), but I want it in small language of course, not C#.
PHP Code:
static cell AMX_NATIVE_CALL get_distance_x(AMX *amxcell *params)
{
    
cell *cpVec1 get_amxaddr(amxparams[1]);
    
cell *cpVec2 get_amxaddr(amxparams[2]);

    
Vector vec1 Vector((float)cpVec1[X]);
    
Vector vec2 Vector((float)cpVec2[X]);

    
int iDist = (int)((vec1 vec2).Length());

    return 
iDist;

__________________
atomen is offline
Send a message via MSN to atomen
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-27-2008 , 15:33   Re: Other Type of 'get_distance()'
Reply With Quote #2

Dunno, but a origin is a dot with 3 coordinates XYZ, so distance between 2 origins will be equal with distance between only an axe of origin.
Alka is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-27-2008 , 20:26   Re: Other Type of 'get_distance()'
Reply With Quote #3

Code:
abs(origin1[0] - origin2[0]);
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-27-2008 , 21:03   Re: Other Type of 'get_distance()'
Reply With Quote #4

Quote:
Originally Posted by Alka View Post
Dunno, but a origin is a dot with 3 coordinates XYZ, so distance between 2 origins will be equal with distance between only an axe of origin.
Not true.

Let's say our origins are points E and D.

Code:
         A______B
         |\    |\
	  | \   | \ 
	  |  \C_|__\D
	  |  |  |  |
	  |  |  |  |
	 E|__|__|F |
	   \ |   \ |
	    \|____\|
	    G      H
The distance from point E to point D is greater than the distance of point E to point A, which is the 1 axis. It is also greater than point B, which is the 2 axis. To get the full distance of our 3-dimensional box, we need to use all 3 dimensions.

You can try yourself:

Code:
public test(id) {     for( new i = 1; i <= g_max_players; i++ )     {         if( i == id || !is_user_connected(i) ) continue;                 new Float:distance[3];         GetPlayerDistance3D(id, i);                 console_print(id, "Distance of all 3 dimensions");         console_print(id, "X Axis: %f", distance[0]);         console_print(id, "X & Y Axis: %f", distance[1]);         console_print(id, "X & Y & Z Axis: %f", distance[2]);                 break;     } } GetPlayerDistance3D(id1, id2, Float:distance[3]) {     new Float:origin1[3], Float:origin2[3];     pev(id1, pev_origin, origin1);     pev(id2, pev_origin, origin2);         new Float:temp1[3], Float:temp2[3];     for( new i = 0; i < 3; i++ )     {         temp1[i] = origin1[i];         temp2[i] = origin2[i];                 distance[i] = get_distance_f(temp1, temp2);     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 03:04.


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