1
$\begingroup$

I'm a new user of blender. I'm trying to control an object move and rotate using python script. Require the object limited on a plane each move or rotate.

As the picture showned, an object can only move inside the boundaries in X,Y coordinates, but not limited in Z axis.

enter image description here

just let object only move in the box

$\endgroup$
2
  • $\begingroup$ Welcome to Blender's Stack Exchange! Could you please add what you have tried to implement so far? Is there a particular part you're having trouble with? $\endgroup$ Commented Apr 11, 2022 at 14:50
  • $\begingroup$ @RobertGützkow I selected the plane and read its vertices into a list $\endgroup$
    – P. Scotty
    Commented Apr 12, 2022 at 4:33

1 Answer 1

0
$\begingroup$

You need to check, if the new position is in the boundaries of your plane and thus allowed.

Given, that your plane is in X, Y, you may reduce this to a 2 dimensional task: You need to check, if the position of the object (a point) is in the polygon, that is described by the boundaries.

Thus, you may use the ray casting algorithm or the winding number algorithm, as described here: Wikipedia - Point in polygon

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .