<?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: Help with Maxscript to find where a segment would intersect another if exten in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024445#M7749</link>
    <description>&lt;P&gt;the intersection of segments is a planar task in general... it is difficult for me to add something else to this&lt;/P&gt;</description>
    <pubDate>Fri, 13 Sep 2019 18:35:27 GMT</pubDate>
    <dc:creator>denisT.MaxDoctor</dc:creator>
    <dc:date>2019-09-13T18:35:27Z</dc:date>
    <item>
      <title>Help with Maxscript to find where a segment would intersect another if extended</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9022118#M7742</link>
      <description>&lt;DIV class="topic-meta-data"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="regular contents"&gt;&lt;DIV class="cooked"&gt;&lt;P&gt;Please refer to the following image when reading the description of the problem:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="ray-connect.jpg" style="width: 484px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/676724i6C6F93884C365DB6/image-size/large?v=v2&amp;amp;px=999" role="button" title="ray-connect.jpg" alt="ray-connect.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given two hypothetical line segments:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; a&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;from point3&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;A1&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to point3&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;A2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; b&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;from point3&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;B1&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to point3&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;B2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we were to create a new segment,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;c&lt;/STRONG&gt;, which extends from point3&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;A2&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to point3&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;B3&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;where it intersects segment&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;b&lt;/STRONG&gt;, making&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;c&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;an extension of segment&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;a&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;from its end point&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;A2&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to the new point&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;B3&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(i.e., segment&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;c&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;should be collinear with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;a&lt;/STRONG&gt;), how would we go about doing this using Maxscript and let’s assume all coordinates are in World space to make life simpler?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that the angle of intersection,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;𝛂&lt;/STRONG&gt;, could be acute, right, or obtuse, depending on the direction of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;a&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;b&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;To make things simpler, I am most interested in a function that returns the new intersection point3&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;B3&lt;/STRONG&gt;, given point3s&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;A1&lt;/STRONG&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;A2&lt;/STRONG&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;B1&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;B2&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as parameters, assuming of course that segment&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;a&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;would intersect segment&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;b&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if projected as indicated by&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;c&lt;/STRONG&gt;. I suppose the function could return undefined if&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;a&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;b&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;are parallel or skew (i.e., not co-planar) with respect to each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;fn findIntersectionPoint A1 A2 B1 B2
(
  B3=[0,0,0] -- Point of intersection, to be calculated
  /* Calculation code
  ...
  */
  B3
)&lt;/PRE&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 Sep 2019 18:14:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9022118#M7742</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-12T18:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Maxscript to find where a segment would intersect another if exten</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9022141#M7743</link>
      <description>&lt;P&gt;The answer is here: &lt;A href="https://forums.cgsociety.org/t/geometrical-calculations-points-lines-planes-intersections-distances-angles/906269" target="_blank"&gt;https://forums.cgsociety.org/t/geometrical-calculations-points-lines-planes-intersections-distances-angles/906269&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 18:26:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9022141#M7743</guid>
      <dc:creator>miauuuu</dc:creator>
      <dc:date>2019-09-12T18:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Maxscript to find where a segment would intersect another if exten</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9022236#M7744</link>
      <description>&lt;P&gt;or there:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.geometrictools.com/Source/Mathematics.html" target="_blank" rel="noopener"&gt;https://www.geometrictools.com/Source/Mathematics.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I generally also suggest this one:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.amazon.com/Geometric-Computer-Graphics-Morgan-Kaufmann/dp/1558605940" target="_blank" rel="noopener"&gt;https://www.amazon.com/Geometric-Computer-Graphics-Morgan-Kaufmann/dp/1558605940&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 19:13:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9022236#M7744</guid>
      <dc:creator>istan</dc:creator>
      <dc:date>2019-09-12T19:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Maxscript to find where a segment would intersect another if exten</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024335#M7745</link>
      <description>&lt;P&gt;Actually, this specific problem is not addressed at any of the links mentioned above with the possible exception of the "Geometric Tools for Computer Graphics" book, which I own but it is a very hard to understand technical book with uncommented C source code, for the simple reason that the line segment being discussed, namely&amp;nbsp;&lt;STRONG&gt;a&lt;/STRONG&gt;, does not (yet) intersect the other line-segment, &lt;STRONG&gt;b&lt;/STRONG&gt;&lt;STRONG&gt;.&amp;nbsp;&lt;/STRONG&gt;&lt;U&gt;That is the problem here - to make it intersect via extension&lt;/U&gt;.&amp;nbsp;If I knew the (minimal) length of segment&amp;nbsp;&lt;STRONG&gt;c&lt;/STRONG&gt; to make it intersect, the problem would be trivial to solve!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All of the discussions/examples/solutions at the links posted above assume either an existing intersection or a non-intersection due to the lines, rays, or line segments being skewed/parallel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This particular problem involves a logical&amp;nbsp;&lt;U&gt;extension&lt;/U&gt; of a line segment (i.e., &lt;STRONG&gt;a&lt;/STRONG&gt;)&amp;nbsp;in a particular direction (i.e., along one of its two potential co-linear direction vectors, since the line can be extended in either direction and it may not be clear which is the right one) where &lt;U&gt;said extension is of unknown length&lt;/U&gt; to a &lt;U&gt;potential intersection point&lt;/U&gt; with another line segment (i.e., &lt;STRONG&gt;b&lt;/STRONG&gt;)&amp;nbsp;at an unknown and to be determined intersection point, &lt;STRONG&gt;B3&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 18:01:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024335#M7745</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-13T18:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Maxscript to find where a segment would intersect another if exten</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024360#M7746</link>
      <description>&lt;P&gt;i posted the answer on the CGTalk forum.. but can it repeat here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the pure math for 2d intersection. it also tells if intersection was happened&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;IN&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;OUT&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of bounds (what was the point for me).&lt;/P&gt;&lt;P&gt;it’s a c++ code (i don’t remember where i found the algorithm. so sorry for not giving someone a credit)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-keyword"&gt;int&lt;/SPAN&gt; &lt;SPAN class="hljs-title"&gt;RayIntersect2D&lt;/SPAN&gt;(&lt;SPAN class="hljs-params"&gt;Point3 p11, Point3 p12, Point3 p21, Point3 p22, Point3&amp;amp; pt&lt;/SPAN&gt;) &lt;/SPAN&gt;{
	&lt;SPAN class="hljs-keyword"&gt;float&lt;/SPAN&gt; z  = (p12.y-p11.y)*(p21.x-p22.x)-(p21.y-p22.y)*(p12.x-p11.x);
	&lt;SPAN class="hljs-keyword"&gt;float&lt;/SPAN&gt; ca = (p12.y-p11.y)*(p21.x-p11.x)-(p21.y-p11.y)*(p12.x-p11.x);
	&lt;SPAN class="hljs-keyword"&gt;float&lt;/SPAN&gt; cb = (p21.y-p11.y)*(p21.x-p22.x)-(p21.y-p22.y)*(p21.x-p11.x);
	
	&lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; ((z == &lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;) &amp;amp;&amp;amp; (ca == &lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;) &amp;amp;&amp;amp; (cb == &lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;))
	{
		&lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;; &lt;SPAN class="hljs-comment"&gt;// same line&lt;/SPAN&gt;
	}
	&lt;SPAN class="hljs-keyword"&gt;else&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; (z == &lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;) &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;; &lt;SPAN class="hljs-comment"&gt;// parallel&lt;/SPAN&gt;
	&lt;SPAN class="hljs-keyword"&gt;else&lt;/SPAN&gt;
	{
		&lt;SPAN class="hljs-keyword"&gt;float&lt;/SPAN&gt; ua = ca/z;
		&lt;SPAN class="hljs-keyword"&gt;float&lt;/SPAN&gt; ub = cb/z;
		
		pt.x = p11.x + (p12.x - p11.x)*ub;
		pt.y = p11.y + (p12.y - p11.y)*ub;
		pt.z = &lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;;

		&lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; (ua &amp;gt;=&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt; &amp;amp;&amp;amp; ua &amp;lt;= &lt;SPAN class="hljs-number"&gt;1&lt;/SPAN&gt; &amp;amp;&amp;amp; ub &amp;gt;=&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt; &amp;amp;&amp;amp; ub &amp;lt;= &lt;SPAN class="hljs-number"&gt;1&lt;/SPAN&gt;) 
		{
			&lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="hljs-number"&gt;1&lt;/SPAN&gt;; &lt;SPAN class="hljs-comment"&gt;// in bounds&lt;/SPAN&gt;
		}
		&lt;SPAN class="hljs-keyword"&gt;else&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="hljs-number"&gt;-1&lt;/SPAN&gt;;
	}
}&lt;/PRE&gt;&lt;P&gt;i hope someone will help you to translate it on MXS (if you can’t do it yourself).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 17:50:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024360#M7746</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2019-09-13T17:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Maxscript to find where a segment would intersect another if exten</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024373#M7747</link>
      <description>&lt;P&gt;I am not sure what you mean by in and out of bounds, but it appears to me that you are always setting the &lt;STRONG&gt;z&lt;/STRONG&gt; coordinate of the (potential) point of intersection to zero, which cannot possibly be right, unless you are working in a reference coordinate system that is not World as mentioned in my problem statement or are assuming that the two line-segments in question lie on the plane defined by the equation &lt;STRONG&gt;z=0&lt;/STRONG&gt;, which is not always the case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 18:18:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024373#M7747</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-13T18:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Maxscript to find where a segment would intersect another if exten</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024404#M7748</link>
      <description>&lt;P&gt;IT'S 2D solution. as I said at the top of the post and the name of the function says the same.&lt;/P&gt;&lt;P&gt;you can project the 3D vectors on any plane (which makes it 2D where Z is zero).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you need additional details on algebra?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 18:23:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024404#M7748</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2019-09-13T18:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Maxscript to find where a segment would intersect another if exten</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024445#M7749</link>
      <description>&lt;P&gt;the intersection of segments is a planar task in general... it is difficult for me to add something else to this&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 18:35:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024445#M7749</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2019-09-13T18:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Maxscript to find where a segment would intersect another if exten</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024522#M7750</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1634609"&gt;@denisT.MaxDoctor&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;IT'S 2D solution. as I said at the top of the post and the name of the function says the same.&lt;/P&gt;&lt;P&gt;you can project the 3D vectors on any plane (which makes it 2D where Z is zero).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you need additional details on algebra?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Well, I did state in my original problem, &lt;EM&gt;"... and let’s assume all coordinates are in World space,"&lt;/EM&gt; so yes apparently my "algebra details" are lacking, since I am looking for the intersection point in absolute&amp;nbsp;&lt;STRONG&gt;Rᶾ&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp;space.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 19:19:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024522#M7750</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-13T19:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Maxscript to find where a segment would intersect another if exten</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024604#M7751</link>
      <description>&lt;P&gt;get a toy, play ...&lt;/P&gt;&lt;PRE&gt;try(destroydialog InterTest) catch()
rollout InterTest "Ray Segment Intersect" width:191
(
	checkbox flat_cb "Flat (Z = 0)"
	
	button create_test_bt "Create 4 Points" width:180 offset:[0,4]
	button intersect_bt "Intersect" width:180 offset:[0,6]
	
	label info_lb "" align:#center offset:[0,4]
	
	local a0, a1, b0, b1, c0

	fn _raySegmentIntersect p dir A B &amp;amp;bounds: =  
	(
		pb = B - A
		pc = A - p
		c1 = cross dir pb
		c2 = cross pc pb
		pt = p + dir * (dot c2 c1)/(dot c1 c1) 
		_sign = dot dir (pt - p)
		
		len = length pb
		bounds = if (length (pt - A) &amp;gt; len or length (pt - B) &amp;gt; len) then 0 else (if _sign &amp;lt; 0 then -1 else 1)
			
		pt
	)	

	on create_test_bt pressed do undo "Create" on 
	(
		delete objects
		
		z = if flat_cb.checked then 0 else 200
		
		a0 = point name:#a0 pos:(random -[200,200,z] [200,200,z]) size:40 wirecolor:yellow
		a1 = point name:#a1 pos:(random -[200,200,z] [200,200,z]) size:40 wirecolor:(yellow * 0.8)

		b0 = point name:#b0 pos:(random -[200,200,z] [200,200,z]) size:40 wirecolor:green
		b1 = point name:#b1 pos:(random -[200,200,z] [200,200,z]) size:40 wirecolor:(green * 0.8)
	)

	on intersect_bt pressed do undo "Intersect" on try 
	(
		p0 = _raySegmentIntersect a1.pos (normalize (a0.pos - a1.pos)) b0.pos b1.pos bounds:&amp;amp;b
		
		bounds = (if b == 0 then #out else if b == 1 then #in else #off)	
		info_lb.text = bounds as string
			
		format "pos:% bounds:%\n" p0 bounds	
		c0 = point pos:p0 size:80 wirecolor:(random red orange)
	)
	catch()

)
createdialog InterTest&lt;/PRE&gt;&lt;P&gt;... and find a time to learn Algebra&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 20:06:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/help-with-maxscript-to-find-where-a-segment-would-intersect/m-p/9024604#M7751</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2019-09-13T20:06:38Z</dc:date>
    </item>
  </channel>
</rss>

