Jump to content
Sign in to follow this  
roguetrooper

To math freaks: objects on border of irregular rectangle?

Recommended Posts

I have a rectangle (trigger) with known position, length x, width y and angle z (not 0) and need a script that places objects on the border of that rectangle with a distance "d" (maybe 3 metres) to each other.

Could one of you imagine that to be possible?

Sure, I could place those objects manually in the editor, but according to variable settings that rectangle can have a variable position, x,y and angle.

PS. For placing objects on the border on a CIRCLE I have script, which works fine.

Share this post


Link to post
Share on other sites

Try this mate.... this works with a marker. I'm sure you can figure it out from here.

//rotate it
_newx = 2 * ((_xdis * cos(_mkrdir)) - (_ydis * sin(_mkrdir)));
_newy = 2 * ((_xdis * sin(_mkrdir)) + (_ydis * cos(_mkrdir)));

//add it to center coords
_newx = (_mkrpos select 0) + (_newx);
_newy = (_mkrpos select 1) + (_newy);

Share this post


Link to post
Share on other sites

Sounds very interesting, may I ask what it is needed for? Just curious..

Share this post


Link to post
Share on other sites

The purpose is to rotate (x,y) points around an origin.

For instance if you had a marker and a bunch of (x,y) points in the area covered by the marker. Where would these points end up if you rotated the marker and the points by 20 degrees.

Can't explain much better than that. Google "geometric rotation".

Share this post


Link to post
Share on other sites

Okay I see. Sounds like an advanced mission you are making.

Share this post


Link to post
Share on other sites

Have gotten use to doing this all the time, its basically called vector rotations. A position has a vector from the center of the object, and if the object is rotated, the position is rotated with the object. The vector has the same magnitude, just a different direction (a direction that obviously results from the degree rotation). So rotating the vector the degree amount is the same as rotating the entire object that degree amount. Then you can find out if its inside the borders or not just based on the height width values.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×