AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Boundries (https://forums.alliedmods.net/showthread.php?t=14127)

v3x 06-10-2005 23:22

Boundries
 
Say I had four points like so:

*-----------------*
|//////////////////|
|\\\\\\\\\\\\\\\\\\|
|//////////////////|
|\\\\\\\\\\\\\\\\\\|
*-----------------*

How could I tell if something was inside of those four points (the slashes)?

I know I could prolly look @ xero's OOB plugin, but I'm too lazy for that.

PS: You can compliment on my beloved artwork later.. ;)

xeroblood 06-11-2005 17:04

Theoretically:
If you have a 2D box and a 2D point, you can test if the point is inside the box like by comparing the X,Y coordinates:

The Box:

Code:

// (bx,by)
//    *-------------*
//    |            |
//    |  (px,py)    | bh
//    |    *      |
//    *-------------*
//            bw

(Point X, Y == px and py)
(Box X, Y == bx, by)
(Box Width == bw)
(Box Height == bh)

Just imagine those are your variables, you could do:

Code:
if( px >= bx && px <= (bx + bw) && py >= by && py <= (by + bh) ) {     // Inside box }else {     // Outside box }

The same theory applies to 3D Boxes/Points, just add the extra coordinate checks for Z!

This is basically what I've done in OOB..

v3x 06-11-2005 20:20

Ah.. I knew you'd be the one to reply! :)

Hmm... I'll have to figure this out.. It's still kinda confusing for me.


All times are GMT -4. The time now is 16:49.

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