question

Nicolas Mbz avatar image
0 Likes"
Nicolas Mbz asked Nicolas Mbz commented

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


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

FlexSim 22.2.0
codeobjectfunctionssurface
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Nicolas Mbz commented

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);
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Nicolas Mbz avatar image Nicolas Mbz commented ·
Hi, thanks a lot. Finally, I did something similar. But your method seems more clean. I will implemented. Thanks a lot
0 Likes 0 ·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered

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.
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.