Raised This Month: $ Target: $400
 0% 

is user in between


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 05-23-2009 , 04:26   Re: is user in between
Reply With Quote #1

Quote:
Originally Posted by stupok View Post
Code:
distance = abs( origin1[1] - orgin2[1] )
thats what i was lookin for thanks alot it works perfectly now
whosyourdaddy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-23-2009 , 07:44   Re: is user in between
Reply With Quote #2

LoL, all of that code and he ends up using:

distance = abs( origin1[1] - orgin2[1] )

So in reality, you were looking for the distance between 2 origins?
__________________
Bugsy is offline
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 05-23-2009 , 10:03   Re: is user in between
Reply With Quote #3

well this is what im using
Code:
public IsBetween( player[3] , iOrigin1[3] , iOrigin2[3] )
{

    if( abs( iOrigin1[0] - player[0] ) < 40 && abs( iOrigin1[1] - player[1] ) < 40  && iOrigin2[2] <= player[2] <= iOrigin1[2] )
        return 1

    return 0
}
and it works great this is what it is looking for

point 1
x
x
x
x
x
| player
x
x
x
x
x point 2
whosyourdaddy is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 05-23-2009 , 11:37   Re: is user in between
Reply With Quote #4

Quote:
Originally Posted by whosyourdaddy View Post
well this is what im using
Code:
public IsBetween( player[3] , iOrigin1[3] , iOrigin2[3] )
{

    if( abs( iOrigin1[0] - player[0] ) < 40 && abs( iOrigin1[1] - player[1] ) < 40  && iOrigin2[2] <= player[2] <= iOrigin1[2] )
        return 1

    return 0
}
You're checking if a player is:

1. Horizontally, within a square 40x40 units in size with center at point 1.
2. Above point 2 and below point 1.

Is that what you were looking for? I would never say "user in between two origins" if that were my desired result.

Quote:
Originally Posted by whosyourdaddy View Post
this is what it is looking for

point 1
x
x
x
x
x
| player
x
x
x
x
x point 2
This is meangingless to me, so I have to open MSPaint. (In Windows 7 )

Again, I think you're clueless, unless you're confused about the meaning of being between two origins. Maybe you've just confused me.

- Which situation do you want to detect? (in two dimensions, for my sanity)
    1. Bugsy's double cone (not exactly like this, but close enough <_<)

      [img]http://img36.**************/img36/3800/bugsy1.png[/img]

    2. Bugsy's traceline

      [img]http://img34.**************/img34/5483/traceline.png[/img]

    3. Your bounding box

      [img]http://img34.**************/img34/7733/whos1.png[/img]

    4. Your square + z limit

      [img]http://img198.**************/img198/3413/whos2.png[/img]

    5. My understanding of "between two points", (between two parallel planes, each plane defined by a point)

      [img]http://img38.**************/img38/6237/stupok.png[/img]

__________________

Last edited by stupok; 05-23-2009 at 12:35.
stupok is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-23-2009 , 10:10   Re: is user in between
Reply With Quote #5

Have you checked that this method works consistently? Basic calculations with individual X,Y,Z coordinates are usually not that simple to work with accurately.

You can also shorten that function into a macro:

PHP Code:
#define IsBetween(%1,%2,%3) ( (abs( %2[0] - %1[0] ) < 40) && (abs( %2[1] - %1[1] ) < 40)  && (%3[2] <= %1[2] <= %2[2]) ) 
__________________

Last edited by Bugsy; 05-23-2009 at 10:14.
Bugsy is offline
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 05-23-2009 , 18:10   Re: is user in between
Reply With Quote #6

i want number 2 but with what im doing which u did it on number 3, its not as big as u made it but a small radius which pretty much makes its a line
whosyourdaddy is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 05-24-2009 , 11:54   Re: is user in between
Reply With Quote #7

I don't know what you're talking about. Your latest code is the square + z method.
__________________

Last edited by stupok; 05-24-2009 at 11:56.
stupok is offline
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 05-24-2009 , 14:22   Re: is user in between
Reply With Quote #8

Quote:
Originally Posted by stupok View Post
I don't know what you're talking about. Your latest code is the square + z method.
ya but if your square isnt big it will pretty much make a line
whosyourdaddy is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-24-2009 , 14:35   Re: is user in between
Reply With Quote #9

If you want the line method, you can do this:
Code:
IsInBetween(const Float:vStart[3], const Float:vEnd[3], const Float:vPoint[3], const Float:fAllowance=1.0) {     new Float:vNormalVector[3];     xs_vec_sub(vEnd, vStart, vNormalVector);         new Float:vTestVector[3];     xs_vec_sub(vPoint, vStart, vTestVector);         xs_vec_normalize(vNormalVector, vNormalVector);     xs_vec_mul_scalar(vNormalVector, vector_length(vTestVector), vNormalVector);         xs_vec_add(vNormalVector, vStart, vNormalVector);     xs_vec_add(vTestVector, vStart, vTestVector);         return (vector_distance(vNormalVector, vTestVector) <= fAllowance); }
vStart - end point 1
vEnd - end point 2
vPoint - point to check
fAllowance - the maximum distance away from the line to still be considered on the line
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 05-24-2009 , 15:28   Re: is user in between
Reply With Quote #10

Exolent, here's what you're doing

It's close, but "distance" is not exactly the distance from the point to the line.

[IMG]http://img198.**************/img198/7283/exolent.png[/IMG]
__________________

Last edited by stupok; 05-24-2009 at 16:01.
stupok 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 01:33.


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