<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Detect whether there is an obstacle between objects in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528167#M37503</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;A rel="user" href="https://answers.flexsim.com/users/461/joerg.v.html" nodeid="461"&gt;@Joerg Vogel&lt;/A&gt; , 
 &lt;A rel="user" href="https://answers.flexsim.com/users/206/phil.b.html" nodeid="206"&gt;@Phil BoBo&lt;/A&gt; Thank you for the interesting idea! But I am not used to using SDK. I will write a function in FlexScript.
&lt;/DIV&gt;</description>
    <pubDate>Tue, 05 Jul 2022 14:36:12 GMT</pubDate>
    <dc:creator>yokota_t</dc:creator>
    <dc:date>2022-07-05T14:36:12Z</dc:date>
    <item>
      <title>Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528156#M37492</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 22.0.4 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hello all,&lt;/P&gt;
 &lt;P&gt;I'm trying to simulate radio communication in FlexSim.&lt;/P&gt;
 &lt;P&gt;I need to detect whether there is an obstacle between objects.&lt;/P&gt;
 &lt;P&gt;Specifically, I want to detect whether there is an object that overlaps the line connecting the centers of the wireless terminal objects. The CAD shape of the object can be ignored and assumed to be &lt;S&gt;rectangular&lt;/S&gt; a cuboid.&lt;/P&gt;
 &lt;P&gt;What would be the best way to do this?&lt;/P&gt;
 &lt;P&gt;Thank you.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Jun 2022 08:02:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528156#M37492</guid>
      <dc:creator>yokota_t</dc:creator>
      <dc:date>2022-06-28T08:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528157#M37493</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;In 3D?  Line intersecting cuboid?&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Jun 2022 08:49:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528157#M37493</guid>
      <dc:creator>jason_lightfoot_adsk</dc:creator>
      <dc:date>2022-06-28T08:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528158#M37494</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 Yes, in 3D. I'll fix my post.
&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Jun 2022 08:51:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528158#M37494</guid>
      <dc:creator>yokota_t</dc:creator>
      <dc:date>2022-06-28T08:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528159#M37495</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;The line goes through the coboid if it intersects with any of its faces. Each face defines a plane in 3D space. The intersection point of the line with that plane (if not parallel) can be calculated relatively easily. You then have to check whether that point is part of the surface.&lt;/P&gt;&lt;P&gt;The math is summarized pretty well under the following link:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.wikiwand.com/en/Line%E2%80%93plane_intersection"&gt;https://www.wikiwand.com/en/Line%E2%80%93plane_intersection&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you take the vectors that define the plane to be equal to the edges of the object (vectors between corner points) then the line intersects the face if 0 &amp;lt;= u &amp;lt;= 1 and 0 &amp;lt;= v &amp;lt;= 1, as mentioned on the linked page.&lt;SPAN style="font-size: 10px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1656416156877.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1511158iF3B0DF6E79B716B6/image-size/large?v=v2&amp;amp;px=999" role="button" title="1656416156877.png" alt="1656416156877.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1656416212328.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1511159i3D2C0A2657DDD986/image-size/large?v=v2&amp;amp;px=999" role="button" title="1656416212328.png" alt="1656416212328.png" /&gt;&lt;/span&gt;p&lt;SPAN style="font-size: 10px;"&gt;nm&lt;/SPAN&gt; is the vector between the points p&lt;SPAN style="font-size: 10px;"&gt;m&lt;/SPAN&gt; and p&lt;SPAN style="font-size: 10px;"&gt;n, &lt;/SPAN&gt;&lt;SPAN style="font-size: 14px;"&gt;same goes for l&lt;/SPAN&gt;&lt;SPAN style="font-size: 10px;"&gt;ab.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px;"&gt;In the Flexsim the &lt;A href="https://docs.flexsim.com/en/22.1/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/Vec3.html"&gt;Vec3 Class&lt;/A&gt; offers all necessary methods for these calculations. The 'getLocation()' method can be used to get the corner points of the object, serving as p&lt;/SPAN&gt;&lt;SPAN style="font-size: 10px;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: 14px;"&gt;, p&lt;/SPAN&gt;&lt;SPAN style="font-size: 10px;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 14px;"&gt; and p&lt;/SPAN&gt;&lt;SPAN style="font-size: 10px;"&gt;2&lt;/SPAN&gt;&lt;SPAN style="font-size: 14px;"&gt;.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Jun 2022 11:41:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528159#M37495</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-06-28T11:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528160#M37496</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thank you for your response.&lt;/P&gt;
 &lt;P&gt;I understood the mathematical theory.&lt;/P&gt;
 &lt;P&gt;So, should I use this decision method to all objects that can intersect the radio communication path?&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 29 Jun 2022 00:21:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528160#M37496</guid>
      <dc:creator>yokota_t</dc:creator>
      <dc:date>2022-06-29T00:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528161#M37497</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Depends on how many objects there are. In general, I would recommend to first to a rough check (distance from object center to line) to see if an intersection is possible. Only then do the check above to improve performance.&lt;/P&gt;&lt;P&gt;The distance can be gotten quite easily:&lt;/P&gt;&lt;P&gt;|pxp0| = |p1p0| * sin(α), where p1 and p2 define the line and p0 ist the objects center&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1656484639945.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1511163iD60A36DE39218DD3/image-size/large?v=v2&amp;amp;px=999" role="button" title="1656484639945.png" alt="1656484639945.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 29 Jun 2022 06:37:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528161#M37497</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-06-29T06:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528162#M37498</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;I see. That's a smart way.&lt;/P&gt;
 &lt;P&gt;Thank you for your great answer!&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 29 Jun 2022 06:47:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528162#M37498</guid>
      <dc:creator>yokota_t</dc:creator>
      <dc:date>2022-06-29T06:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528163#M37499</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;In the attached model is the approach listed above as a user command called &lt;EM&gt;findIntersectionsBetweenPoints()&lt;/EM&gt; that takes two points in model space and returns a list of objects it crosses and a list of intersection points. It's called in the onDraw of the cylinder, which then draws the intersection points as green spheres on a line between two flow items that are circulating on the conveyors.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1656806931850.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1511165i80C0797E83443A14/image-size/large?v=v2&amp;amp;px=999" role="button" title="1656806931850.png" alt="1656806931850.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;/**Custom Code*/
Vec3 L1=param(1);   //The first point of the line in model space
Vec3 L2=param(2);    // The second point of the line in model space
Array omit=param(3);   //The array of objects to omit from tests.
Vec3 L12 =L2-L1;       // The vector between the two points on the line
double lineMag=L12.magnitude;   //length of the line
Vec3 L21=L12*-1;       // The reverse vector of the line
Vec3 mid=Vec3(0.5,0.5,0.5);
Object o=model().last;
Vec3 oCen;
Vec3 L1toCen;
double dist=0;
string pathstr;
double objDiagLen;
Array objects=[];
Array intersections=[];
forobjecttreeunder(model()){
  if (getdatatype(a)==DATATYPE_OBJECT&amp;amp;&amp;amp; omit.indexOf(a)==-1){
    pathstr=nodetopath(a,1);
    if (not(pathstr.startsWith("MODEL:/Tools"))){
      o=a;
      oCen=o.getLocation(mid);  //get the centre point of the object's oriented bounding box (OBB)
      L1toCen=oCen-L1;          // the vector from the start of our line to the object centre
      dist=L1toCen.cross(L12).magnitude/lineMag;   // distance of the centre to out line at the shortest point
      objDiagLen=sqrt(sqr(o.size.x)+sqr(o.size.y)+sqr(o.size.z));  // the length of the OBB diagnonal.
      int possIntersect=dist&amp;lt;objDiagLen/2;   //  could it intersect the line  1/0
      if (possIntersect){  
        int intersected=0;
        Vec3 pa0=o.getLocation(0,0,0).project(o.up,model());
        Vec3 pa1=o.getLocation(1,0,0).project(o.up,model());
        Vec3 pa2=o.getLocation(0,1,0).project(o.up,model());
        Vec3 pa3=o.getLocation(0,0,1).project(o.up,model());
        Vec3 pb0=o.getLocation(1,1,1).project(o.up,model());
        Vec3 pb1=o.getLocation(0,1,1).project(o.up,model());
        Vec3 pb2=o.getLocation(1,0,1).project(o.up,model());
        Vec3 pb3=o.getLocation(1,1,0).project(o.up,model());
        Array planes=   [[pa0,pa1-pa0,pa2-pa0] 
                        ,[pa0,pa1-pa0,pa3-pa0] 
                        ,[pa0,pa2-pa0,pa3-pa0] 
                        ,[pb0,pb1-pb0,pb2-pb0] 
                        ,[pb0,pb1-pb0,pb3-pb0] 
                        ,[pb0,pb2-pb0,pb3-pb0]];
        for (int n=6;n&amp;gt;0;n--){   //  Use  n&amp;gt;0&amp;amp;&amp;amp;!intersected  if you don't want all the intersection points
          Vec3 p0=planes&lt;N&gt;[1];   //common corner point in model space
          Vec3 p01=planes&lt;N&gt;[2];   //vector along edge1
          Vec3 p02=planes&lt;N&gt;[3];    //vector along edge2
          double denom=L21.dot(p01.cross(p02));
          if (denom==0) //no solution
            continue;
          double t=p01.cross(p02).dot(L1-p0)/denom;
          double u=p02.cross(L21).dot(L1-p0)/denom;
          double v=L21.cross(p01).dot(L1-p0)/denom;
          if (u&amp;gt;=0&amp;amp;&amp;amp;u&amp;lt;=1&amp;amp;&amp;amp;v&amp;gt;=0&amp;amp;&amp;amp;v&amp;lt;=1&amp;amp;&amp;amp;t&amp;gt;=0&amp;amp;&amp;amp;t&amp;lt;=1) {    //solution is in this plane of the OBB
            intersected=1;
            objects.push(o);
            intersections.push(L1+L12*t);
          }
        }
      }
    }
  }
}
return [objects, intersections];&lt;/N&gt;&lt;/N&gt;&lt;/N&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/54574-objectsbetweentwopoints.fsm" target="_blank"&gt;ObjectsBetweenTwoPoints.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 03 Jul 2022 00:14:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528163#M37499</guid>
      <dc:creator>jason_lightfoot_adsk</dc:creator>
      <dc:date>2022-07-03T00:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528164#M37500</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/29555/yokotat.html" nodeid="29555"&gt;@Yokota T&lt;/A&gt; , &lt;A rel="user" href="https://answers.flexsim.com/users/226/jason.l.html" nodeid="226"&gt;@Jason Lightfoot&lt;/A&gt; , &lt;A rel="user" href="https://answers.flexsim.com/users/19365/felixmh.html" nodeid="19365"&gt;@Felix Möhlmann&lt;/A&gt; I thought I share an idea to this subject to you. If think it is matter of raytracing of a light source. If I am not totally wrong, the math is already part of raytracing property. &lt;BR /&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/206/phil.b.html" nodeid="206"&gt;@Phil BoBo&lt;/A&gt;, is there a possibility to get access to results of raytracing graphic engine to identify surface result coordinates? &lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 03 Jul 2022 09:15:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528164#M37500</guid>
      <dc:creator>joerg_vogel_HsH</dc:creator>
      <dc:date>2022-07-03T09:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528165#M37501</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;The OptiX ray tracing engine that is used by RTX Mode is specifically implemented in the Engine to render the 3D view. It isn't accessible generally to a modeler to use for arbitrary calculations.&lt;/P&gt;&lt;P&gt;You could use the Module SDK or DLL Maker to implement a ray tracer to do arbitrary calculations if you wanted, but it's probably simpler to just write a mathematical function to calculate what you want.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 05 Jul 2022 14:04:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528165#M37501</guid>
      <dc:creator>philboboADSK</dc:creator>
      <dc:date>2022-07-05T14:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528166#M37502</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;A rel="user" href="https://answers.flexsim.com/users/226/jason.l.html" nodeid="226"&gt;@Jason Lightfoot&lt;/A&gt; , Thank you for your very interesting model! It will definitely be helpful.
&lt;/DIV&gt;</description>
      <pubDate>Tue, 05 Jul 2022 14:32:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528166#M37502</guid>
      <dc:creator>yokota_t</dc:creator>
      <dc:date>2022-07-05T14:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Detect whether there is an obstacle between objects</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528167#M37503</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;A rel="user" href="https://answers.flexsim.com/users/461/joerg.v.html" nodeid="461"&gt;@Joerg Vogel&lt;/A&gt; , 
 &lt;A rel="user" href="https://answers.flexsim.com/users/206/phil.b.html" nodeid="206"&gt;@Phil BoBo&lt;/A&gt; Thank you for the interesting idea! But I am not used to using SDK. I will write a function in FlexScript.
&lt;/DIV&gt;</description>
      <pubDate>Tue, 05 Jul 2022 14:36:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/detect-whether-there-is-an-obstacle-between-objects/m-p/13528167#M37503</guid>
      <dc:creator>yokota_t</dc:creator>
      <dc:date>2022-07-05T14:36:12Z</dc:date>
    </item>
  </channel>
</rss>

