Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to activate an action if a vector is within a set range

Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
10-24-2008 02:02
Imagine this - I have a square area - I have the vector for the top lefthand corner and the vector for the bottom right hand corner. How can I check if a third vector is within the square.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
10-24-2008 03:04
From: Tarak Voss
Imagine this - I have a square area - I have the vector for the top lefthand corner and the vector for the bottom right hand corner. How can I check if a third vector is within the square.
Compare x and y coordinates of the third vector separately, making sure each is between the corresponding coordinates of the first and second vectors.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
10-24-2008 03:29
CODE

// inside rectangle test
vector upper_left;
vector bottom_right;
vector target;

default
state_entry()
{
if ( target.y<bottom_right.y || target.y>upper_left.y || target.x>bottom_right.x || target.x<upper_left.x )
llOwnerSay("Outside");
else llOwnerSay("Inside");
}
}
_____________________
From Studio Dora
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
10-24-2008 03:40
Thanks for that people