How to detect if an object is on a surface of another object ?

How to detect if an object is on a surface of another object ?

NicolasMembrez
Not applicable
11 Views
3 Replies
Message 1 of 4

How to detect if an object is on a surface of another object ?

NicolasMembrez
Not applicable

[ FlexSim 22.2.0 ]


I need a function that determine if an object (operator) is on a surface of another object (box). For the red operator, the function must return 1, 0 for the other operators. The function must work on all places of the plan. How can I do it ? Thanks in advance

1683021233053.png



EstSurSurfaceObject.fsm

0 Likes
Accepted solutions (1)
12 Views
3 Replies
Replies (3)
Message 2 of 4

joerg_vogel_HsH
Mentor
Mentor

Typically there aren't any sensors or triggers that checks physical attributes.

  • You can try it with a Proximity Agent System. It is a Tool of Toolbox.
  • You can rasterize a plane into small areas and compare them with location values of objects. You would check this in time intervals. For example the pattern of small areas could be pushed to a list. You pull from this list a value that fitts into the location of your operator.
0 Likes
Message 3 of 4

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

You can test if a point is coplanar and within a projected rectangle using vector maths. The Vec3 type has all the vector operations needed for this.

Here's an example of how you might set up the needed variables for comparing a cuboid shape and network node (point) location (without solving it for you).

Object o=Model.find("Shape1");
Object n=Model.find("NN1");
Vec3 Aloc=o.getLocation(0,0,1).project(o.up,model());
Vec3 Bloc=o.getLocation(0,1,1).project(o.up,model());
Vec3 Cloc=o.getLocation(0,0,0).project(o.up,model());
Vec3 Dloc=o.getLocation(1,0,1).project(o.up,model());
Vec3 Nloc=n.getLocation(0,0,0).project(n.up,model());
Vec3 AN=Nloc-Aloc;
Vec3 AB=Bloc-Aloc;
Vec3 AD=Dloc-Aloc;
Vec3 AC=Cloc-Aloc;
double ANdotAC=AN.dot(AC);
double ANdotAB=AN.dot(AB);
double ANdotAD=AN.dot(AD);
0 Likes
Message 4 of 4

NicolasMembrez
Not applicable
Hi, thanks a lot. Finally, I did something similar. But your method seems more clean. I will implemented. Thanks a lot
0 Likes