{"id":663,"date":"2020-03-31T21:31:53","date_gmt":"2020-03-31T21:31:53","guid":{"rendered":"https:\/\/www.parametriczoo.com\/?p=663"},"modified":"2020-03-31T21:31:58","modified_gmt":"2020-03-31T21:31:58","slug":"plane-and-curve-intersection","status":"publish","type":"post","link":"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/","title":{"rendered":"Plane and Curve intersection"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;3.22.7&#8243;][et_pb_row _builder_version=&#8221;3.22.7&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;3.22.7&#8243;][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Plane-Curve intersection from algebraic point of view is quiet similar to <a href=\"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/07\/plane-line-intersection-in-revit-api\/\"><strong>Plane-Line intersection<\/strong><\/a> which we discussed in previous post. In this post I would like to take the same approach in finding the Plane-Curve intersection which involves root finding techniques, and in the next post we will also look at <strong>Face-Curve intersection<\/strong> method and we will use to implement a method for Plane-Curve intersection. If you are looking for a robust and fast solution , then feel free to jump to my next post . If by any chance you are interested&nbsp;in differential geometry and mathematics like me \ud83d\ude09 then please continue reading&#8230;&nbsp;<\/p>\n<p>Let&#8217;s have a look again at the plane and curve parameterization:<span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image001-2.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;83%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Equation <em><strong>(1)<\/strong><\/em> represent a plane with normal vector n which passes through point <em><strong>p\u2080<\/strong><\/em> and Equation <em><strong>(2)<\/strong><\/em> is the parametric formulation of curve <em><strong>C<\/strong><\/em> with parameter <em><strong>t<\/strong><\/em>. <em><strong>C<\/strong><\/em> is a function which maps a real number to a position vector in 3d space. In this form <strong><em>t<\/em> <\/strong>is called natural parameter of curve <strong><em>C<\/em><\/strong>.&nbsp; <em><strong>P<\/strong> <\/em>represents the point on plane and the point on the curve in both equations, just like the Plane-Line intersection we replace the point <em><strong>p<\/strong><\/em> in&nbsp; equation <em><strong>(1)<\/strong><\/em> by its value from equation <em><strong>(2)<\/strong><\/em> and we solve the new equation for <em><strong>t<\/strong><\/em>.&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image003-2.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;40%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>In order to solve above equation we need to know about the function <em><strong>C<\/strong><\/em> in Revit API. There are two methods which can be used to evaluate the curve with given natural or normal parameter which are listed below&nbsp;&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; background_color=&#8221;#f2f2f2&#8243; border_width_all=&#8221;1px&#8221; border_color_all=&#8221;#d3d3d3&#8243; custom_margin=&#8221;-2px|||||&#8221; custom_padding=&#8221;11px|15px|0px|15px|false|true&#8221; saved_tabs=&#8221;all&#8221;]<\/p>\n<pre><code><span class=\"keyword\">public<\/span> <a href=\"c2fd995c-95c0-58fb-f5de-f3246cbc5600.htm\">XYZ<\/a> <span class=\"identifier\">Evaluate<\/span>(\n\t<a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/643eft0t\" target=\"_blank\" rel=\"noopener noreferrer\">double<\/a> <span class=\"parameter\">parameter<\/span>,\n\t<a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/a28wyd50\" target=\"_blank\" rel=\"noopener noreferrer\">bool<\/a> <span class=\"parameter\">normalized<\/span>\n)\n<\/code><\/pre>\n<pre><code><span class=\"keyword\">public<\/span> <a href=\"58dd01c8-b3fc-7142-e4f3-c524079a282d.htm\">Transform<\/a> <span class=\"identifier\">ComputeDerivatives<\/span>(\n\t<a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/643eft0t\" target=\"_blank\" rel=\"noopener noreferrer\">double<\/a> <span class=\"parameter\">parameter<\/span>,\n\t<a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/a28wyd50\" target=\"_blank\" rel=\"noopener noreferrer\">bool<\/a> <span class=\"parameter\">normalized<\/span>\n)<\/code><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>The first method simply evaluate the curve at given parameter and return the point on the curve. The second method is far more better, since it returns the potion of the point along with its derivatives which are useful in root finding technique which we will discuss later. Please read documentation for&nbsp;<code><span class=\"identifier\"><a href=\"https:\/\/www.revitapidocs.com\/2020\/93092a44-85f1-15be-a618-817c763f8994.htm\">ComputeDerivatives()<\/a>&nbsp;<\/span><\/code>as I&#8217;m not going to cover all details here.<\/p>\n<p>The equation <em><strong>(3)<\/strong><\/em> has one unknown <em><strong>(t)<\/strong><\/em> and if the curve is smooth and differentiable then the equation is also differentiable which means we can use <a href=\"https:\/\/en.wikipedia.org\/wiki\/Newton%27s_method\">newton method<\/a> for root finding . Although there are several <a href=\"https:\/\/en.wikipedia.org\/wiki\/Root-finding_algorithm\">roof finding algorithms<\/a> which can be used in this case, but I have selected the newton method as it is easy to implement and has quadratic convergence rate. As I mentioned above you may not use this algorithm for your code where the Plane-Curve intersection is used expensively and instead, please refer my next post on this topic.&nbsp;<\/p>\n<p>The newton method requires to have the first derivative of equation <em><strong>(3)<\/strong><\/em> with respect to the unknown <em><strong>(t)<\/strong><\/em>. Here we shall write:&nbsp;&nbsp;&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image005-2.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;40%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Expanding above we get :&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image007-1.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;40%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>The second part is constant with respect to the <strong><em>t<\/em><\/strong> , therefore it is eliminated<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image009-1.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;40%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Expanding the <em><strong>(4-2)<\/strong><\/em> using the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Dot_product\">derivative of the dot-product<\/a> we obtain:&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image009-2.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;60%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Again the right expression is constant with respect to the (t) therefore we can eliminate and write :<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image011-1.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;40%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>In equation <strong><em>(4-3)<\/em><\/strong> we only need to the derivative of the function <em><strong>C<\/strong><\/em> with respect to the parameter <em><strong>t<\/strong><\/em> and then compute the dot product of it with plane normal. As already mentioned above the <code><span class=\"identifier\"><a href=\"https:\/\/www.revitapidocs.com\/2020\/93092a44-85f1-15be-a618-817c763f8994.htm\">ComputeDerivatives()<\/a><\/span><\/code>method returns the first derivative of the function <em><strong>C<\/strong><\/em> in the BasisX vector of the resulted transformation matrix. This derivative can be also interpreted as the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Tangent_vector\">tangent vector<\/a> to the curve at parameter <em><strong>t<\/strong><\/em>. Now we have both requirements for Newton method, first the evaluation of the equation <strong><em>(3)<\/em><\/strong>&nbsp;which we call it function <strong><em>f(t)<\/em><\/strong> from now on and the first derivative of the function <em><strong>f<\/strong> <\/em>at parameter<strong><em> t <\/em><\/strong>which is written as<strong><em> df&nbsp;<\/em><\/strong>:<span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; background_color=&#8221;#f2f2f2&#8243; border_width_all=&#8221;1px&#8221; border_color_all=&#8221;#d3d3d3&#8243; custom_margin=&#8221;-2px|||||&#8221; custom_padding=&#8221;11px|15px|0px|15px|false|true&#8221; saved_tabs=&#8221;all&#8221;]<\/p>\n<pre style=\"font-family:Consolas;font-size:13px;color:black;\"><span class=\"comment\" style=\"color:green;\">\/\/ compute C(t) and C'(t) <\/span>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">tr<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">ComputeDerivatives<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color:blue;\">false<\/span><span class=\"punctuation\">);<\/span>\n<span class=\"comment\" style=\"color:green;\">\/\/compute the objective function f(t)<\/span>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">f<\/span> <span class=\"operator\">=<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">tr<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Origin<\/span> <span class=\"operator - operator - overloaded - (TRANSIENT)\" style=\"color:#74531f;\">-<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">q<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Origin<\/span><span class=\"punctuation\">)<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">DotProduct<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">q<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Normal<\/span><span class=\"punctuation\">);<\/span>\n<span class=\"comment\" style=\"color:green;\">\/\/ compute the derivative of function f(t)<\/span>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">df<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">tr<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">BasisX<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">DotProduct<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">q<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Normal<\/span><span class=\"punctuation\">);<\/span><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; custom_margin=&#8221;||2px|||&#8221;]<\/p>\n<p>I&#8217;m not going to discuss the<a href=\"https:\/\/en.wikipedia.org\/wiki\/Newton%27s_method\"> newton method<\/a> in full detail ,&nbsp;<span>The most basic version starts with a single-variable function <strong><span class=\"texhtml\"><i>f<\/i><\/span><\/strong><\/span><span>&nbsp;defined for a&nbsp;<\/span><a href=\"https:\/\/en.wikipedia.org\/wiki\/Real_number\" title=\"Real number\">real variable<\/a><span>&nbsp;<\/span><strong><span class=\"texhtml\"><i>x<\/i><\/span><\/strong><span>, the function&#8217;s&nbsp;<\/span><a href=\"https:\/\/en.wikipedia.org\/wiki\/Derivative\" title=\"Derivative\">derivative<\/a><span>&nbsp;<\/span><span class=\"texhtml\"><i><strong>f\u2009<\/strong>\u2032<\/i><\/span><span>, and an initial guess&nbsp;<\/span><strong><span class=\"texhtml\"><i>x<\/i><\/span><em><span class=\"texhtml\">\u2080<\/span><\/em><\/strong><span>&nbsp;for a&nbsp;<\/span><a href=\"https:\/\/en.wikipedia.org\/wiki\/Zero_of_a_function\" title=\"Zero of a function\">root<\/a><span>&nbsp;of&nbsp;<\/span><strong><span class=\"texhtml\"><i>f<\/i><\/span><\/strong><span>. If the function satisfies sufficient assumptions and the initial guess is close, then:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image002.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;28%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243; custom_margin=&#8221;-4px|||||&#8221;]<\/p>\n<p>The algorithm is pretty simple, we start with initial guess <em><strong>t<\/strong> <\/em>and in each iteration we compute the step size <em><strong>dx =<\/strong><\/em>&nbsp;<em><strong>-f(t)\/f'(t) . <\/strong><\/em>The<em><strong>&nbsp;<\/strong><\/em>parameter <strong><\/strong><em><strong>t <\/strong><\/em>is moved to the new position and the function<em><strong> f <\/strong><\/em>is evaluated again. This loop continues till either the value of function<em><strong> f <\/strong><\/em>is close to zero or the number of iteration exceeds a maximum value (here 100 iterations) . Below shows the implementation assuming the interval <em><strong>[t<span>\u2081<\/span>,t<span>\u2082<\/span>]<\/strong> <\/em>is the curve domain.&nbsp;<span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; background_color=&#8221;#f2f2f2&#8243; border_width_all=&#8221;1px&#8221; border_color_all=&#8221;#d3d3d3&#8243; custom_margin=&#8221;-2px|||||&#8221; custom_padding=&#8221;11px|15px|0px|15px|false|true&#8221; saved_tabs=&#8221;all&#8221;]<\/p>\n<pre style=\"font-family:Consolas;font-size:13px;color:black;\"><span class=\"comment\" style=\"color:green;\">\/\/Newton method for finding the root of the function f(t)<\/span>\n<span class=\"keyword\" style=\"color:blue;\">double<\/span> <span class=\"local name\" style=\"color:#1f377f;\">f<\/span><span class=\"punctuation\">;<\/span><span class=\"comment\" style=\"color:green;\">\/\/ the value of the function in each iteration <\/span>\n<span class=\"keyword\" style=\"color:blue;\">double<\/span> <span class=\"local name\" style=\"color:#1f377f;\">df<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color:green;\">\/\/ the first derivative of the function f at each iteration<\/span>\n<span class=\"keyword\" style=\"color:blue;\">double<\/span> <span class=\"local name\" style=\"color:#1f377f;\">dx<\/span> <span class=\"operator\">=<\/span> <span class=\"number\">0<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color:green;\">\/\/ step size (delta x)<\/span>\n<span class=\"keyword\" style=\"color:blue;\">int<\/span> <span class=\"local name\" style=\"color:#1f377f;\">I<\/span> <span class=\"operator\">=<\/span> <span class=\"number\">0<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color:green;\">\/\/ number of iterations <\/span>\n<span class=\"class name - identifier - (TRANSIENT)\" style=\"color:#2b91af;\">Transform<\/span> <span class=\"local name\" style=\"color:#1f377f;\">tr<\/span><span class=\"punctuation\">;<\/span><span class=\"comment\" style=\"color:green;\">\/\/= Transform.Identity;<\/span>\n \n<span class=\"keyword - control\" style=\"color:#8f08c4;\">do<\/span>\n<span class=\"punctuation\">{<\/span>\n    <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t<\/span> <span class=\"operator\">+=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">dx<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color:green;\">\/\/ move t to the new position  <\/span>\n    <span class=\"comment\" style=\"color:green;\">\/\/ ensure the parameter is within the limits<\/span>\n    <span class=\"keyword - control\" style=\"color:#8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">t1<\/span><span class=\"punctuation\">)<\/span> \n    <span class=\"punctuation\">{<\/span>\n        <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">t1<\/span><span class=\"punctuation\">;<\/span> \n    <span class=\"punctuation\">}<\/span>\n    <span class=\"keyword - control\" style=\"color:#8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t<\/span> <span class=\"operator\">&gt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">t2<\/span><span class=\"punctuation\">)<\/span>\n    <span class=\"punctuation\">{<\/span>\n        <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">t2<\/span><span class=\"punctuation\">;<\/span>\n    <span class=\"punctuation\">}<\/span>\n \n    <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">I<\/span><span class=\"operator\">++<\/span><span class=\"punctuation\">;<\/span>\n    <span class=\"comment\" style=\"color:green;\">\/\/ compute C(t) and C'(t) <\/span>\n    <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">tr<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">ComputeDerivatives<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color:blue;\">false<\/span><span class=\"punctuation\">);<\/span>\n    <span class=\"comment\" style=\"color:green;\">\/\/compute the objective function f(t)<\/span>\n    <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">f<\/span> <span class=\"operator\">=<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">tr<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Origin<\/span> <span class=\"operator - operator - overloaded - (TRANSIENT)\" style=\"color:#74531f;\">-<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">q<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Origin<\/span><span class=\"punctuation\">)<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">DotProduct<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">q<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Normal<\/span><span class=\"punctuation\">);<\/span>\n    <span class=\"comment\" style=\"color:green;\">\/\/ compute the derivative of function f(t)<\/span>\n    <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">df<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">tr<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">BasisX<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">DotProduct<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">q<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Normal<\/span><span class=\"punctuation\">);<\/span>\n    <span class=\"comment\" style=\"color:green;\">\/\/ find the step <\/span>\n    <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">dx<\/span> <span class=\"operator\">=<\/span> <span class=\"operator\">-<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">f<\/span> <span class=\"operator\">\/<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">df<\/span><span class=\"punctuation\">;<\/span>\n    <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">rootFound<\/span> <span class=\"operator\">=<\/span> <span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color:#2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color:#74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">f<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">epsilon<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color:green;\">\/\/ check if f is small enough<\/span>\n<span class=\"punctuation\">}<\/span> <span class=\"keyword - control\" style=\"color:#8f08c4;\">while<\/span> <span class=\"punctuation\">(<\/span>\n   <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">I<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"number\">100<\/span> <span class=\"comment\" style=\"color:green;\">\/\/ stop if more than 100 iterations is done<\/span>\n    <span class=\"operator\">&amp;&amp;<\/span>\n    <span class=\"operator\">!<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">rootFound<\/span> <span class=\"comment\" style=\"color:green;\">\/\/ stop if root is found <\/span>\n<span class=\"punctuation\">);<\/span><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; custom_margin=&#8221;-4px|||||&#8221;]<\/p>\n<p>To implement the method we need a guess point, a point which grantees that algorithm finds a root. This depends on choice of <strong><em>t<\/em><\/strong> and number of solution of equation <strong><em>(3)<\/em><\/strong>.&nbsp; It is possible for a curve that intersect the plane in more than one point, this means we need to run the root finding algorithm in the intervals which we know one local solution is available. Almost all root finding algorithms finds only one solution near the guess point , therefore another algorithm must be implemented to find the intervals with only one root. This is generally called <a href=\"https:\/\/en.wikipedia.org\/wiki\/Real-root_isolation\">root isolating algorithm<\/a> where in most cases require the original polynomial of the function<em><strong> f(t)<\/strong><\/em>. Unfortunately we are not able to retrieve the polynomial function via Revit API. However there are methods in Revit API which allows to split an divide curves.<span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; background_color=&#8221;#f2f2f2&#8243; border_width_all=&#8221;1px&#8221; border_color_all=&#8221;#d3d3d3&#8243; custom_margin=&#8221;-2px|||||&#8221; custom_padding=&#8221;11px|15px|0px|15px|false|true&#8221; saved_tabs=&#8221;all&#8221;]<\/p>\n<pre><code><span class=\"keyword\">public<\/span> <span class=\"keyword\">void<\/span> <span class=\"identifier\">MakeBound<\/span>(\n\t<a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/643eft0t\" target=\"_blank\" rel=\"noopener noreferrer\">double<\/a> <span class=\"parameter\">startParameter<\/span>,\n\t<a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/643eft0t\" target=\"_blank\" rel=\"noopener noreferrer\">double<\/a> <span class=\"parameter\">endParameter<\/span>\n)<\/code><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Using <a href=\"https:\/\/www.revitapidocs.com\/2020\/f9bc51b4-50a3-de79-4d7e-401ab2dbebb2.htm\">MakeBound()<\/a> we can create a curve from a sub-domain of the bigger curve <em><strong>C<\/strong><\/em>. Since we are using the curve parameter <em><strong>t<\/strong><\/em> in function <em><strong>f(x)<\/strong><\/em> dividing the curve <em><strong>C<\/strong> <\/em>at parameter<em><strong> t<\/strong> <\/em>is the same as splitting the function<em><strong> f(x)<\/strong><\/em> using line<em><strong> x=t<\/strong><\/em> .<span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; background_color=&#8221;#f2f2f2&#8243; border_width_all=&#8221;1px&#8221; border_color_all=&#8221;#d3d3d3&#8243; custom_margin=&#8221;-2px|||||&#8221; custom_padding=&#8221;11px|15px|0px|15px|false|true&#8221; saved_tabs=&#8221;all&#8221;]<\/p>\n<pre style=\"font-family:Consolas;font-size:13px;color:black;\"><span class=\"comment\" style=\"color:green;\">\/\/Divide curve c with start and end parameter t1 &amp; t2 at parameter t <\/span>\n<span class=\"comment\" style=\"color:green;\">\/\/into two segments <\/span>\n<span class=\"keyword - control\" style=\"color:#8f08c4;\">try<\/span>\n<span class=\"punctuation\">{<\/span>\n    <span class=\"class name - identifier - (TRANSIENT)\" style=\"color:#2b91af;\">Curve<\/span> <span class=\"local name\" style=\"color:#1f377f;\">segment1<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">c<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">Clone<\/span><span class=\"punctuation\">();<\/span>\n    <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">segment1<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">MakeBound<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t1<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t<\/span><span class=\"punctuation\">);<\/span>\n<span class=\"punctuation\">}<\/span>\n<span class=\"keyword - control\" style=\"color:#8f08c4;\">catch<\/span> <span class=\"punctuation\">{<\/span> <span class=\"punctuation\">}<\/span>\n<span class=\"keyword - control\" style=\"color:#8f08c4;\">try<\/span>\n<span class=\"punctuation\">{<\/span>\n    <span class=\"class name - identifier - (TRANSIENT)\" style=\"color:#2b91af;\">Curve<\/span> <span class=\"local name\" style=\"color:#1f377f;\">segment2<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">c<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">Clone<\/span><span class=\"punctuation\">();<\/span>\n    <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">segment2<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">MakeBound<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t2<\/span><span class=\"punctuation\">);<\/span>\n<span class=\"punctuation\">}<\/span>\n<span class=\"keyword - control\" style=\"color:#8f08c4;\">catch<\/span> <span class=\"punctuation\">{<\/span> <span class=\"punctuation\">}<\/span><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; custom_margin=&#8221;||3px|||&#8221;]<\/p>\n<p>Some algorithm suggest to approximate the curve with retentively small segments and then run the root finding algorithm in each segment. Since with Revit API we can compute the curve length in each step, I&#8217;m going to take advantage of this known parameter. We start with subdividing the curves into half till a certain conditions are met.&nbsp;The first condition is that we ensure there is at least one root for function&nbsp; <em><strong>f(t)<\/strong><\/em> . We know that If <em><strong>f(t)=0<\/strong><\/em> has odd number of solutions then<em><strong> f(0)*f(1) &lt;0<\/strong><\/em>&nbsp; (the graphs on the left) and if the number of solution is even or has no solution then&nbsp;<em><strong>f(0)*f(1) &gt;0 <\/strong><\/em>holds (the graphs on the right).<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/number-of-solutions2.png&#8221; _builder_version=&#8221;3.22.7&#8243; custom_margin=&#8221;-5px|||||&#8221;][\/et_pb_image][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/number-of-solutions.png&#8221; _builder_version=&#8221;3.22.7&#8243; custom_margin=&#8221;-3px||2px|||&#8221; custom_padding=&#8221;0px|||||&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243; custom_margin=&#8221;-4px|||||&#8221;]<\/p>\n<p>So the algorithm starts with finding an interval like <em><strong>[a,b]<\/strong><\/em> as such that <strong style=\"font-style: italic;\">f(a)*f(b) &lt;0.&nbsp;<\/strong>We start with the<strong><\/strong><strong style=\"font-style: italic;\">&nbsp;<\/strong>parameter<strong style=\"font-style: italic;\"> t <\/strong>somewhere with this interval (middle is a good choice<strong style=\"font-style: italic;\"> t=(a+b)\/2<\/strong>)<em><strong>&nbsp;<\/strong><\/em>and then verify the stop criteria again for both sub-intervals&nbsp;<em><strong>[a,t] <\/strong><\/em>and <strong><\/strong><em><strong>[t,b] <\/strong><\/em><em><b>.<\/b><\/em> Note that function <em><strong>f(t)<\/strong><\/em> is nothing but the signed distance of the point <em><strong>c(t)<\/strong><\/em> from the plane <em><strong>Q<\/strong><\/em>&nbsp;, hence we can use the extension method <a href=\"https:\/\/www.parametriczoo.com\/index.php\/2020\/02\/29\/signed-distance-of-a-point-from-a-plane\"><em>DistanceTo(Plane q,Point p, out projection)<\/em><\/a>&nbsp;which we discussed earlier.&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; background_color=&#8221;#f2f2f2&#8243; border_width_all=&#8221;1px&#8221; border_color_all=&#8221;#d3d3d3&#8243; custom_margin=&#8221;-2px|||||&#8221; custom_padding=&#8221;11px|15px|0px|15px|false|true&#8221; saved_tabs=&#8221;all&#8221;]<\/p>\n<pre style=\"font-family:Consolas;font-size:13px;color:black;\"><span class=\"keyword\" style=\"color:blue;\">public<\/span> <span class=\"keyword\" style=\"color:blue;\">static<\/span> <span class=\"keyword\" style=\"color:blue;\">void<\/span> <span class=\"method name - static symbol - (TRANSIENT)\" style=\"color:#74531f;\">CurvePlaneIntersection<\/span><span class=\"punctuation\">(<\/span><span class=\"class name - identifier - (TRANSIENT)\" style=\"color:#2b91af;\">Curve<\/span> <span class=\"parameter name\" style=\"color:#1f377f;\">c<\/span><span class=\"punctuation\">,<\/span> <span class=\"class name - identifier - (TRANSIENT)\" style=\"color:#2b91af;\">Plane<\/span> <span class=\"parameter name\" style=\"color:#1f377f;\">q<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color:blue;\">double<\/span> <span class=\"parameter name\" style=\"color:#1f377f;\">t1<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color:blue;\">double<\/span> <span class=\"parameter name\" style=\"color:#1f377f;\">t2<\/span><span class=\"punctuation\">,<\/span>\n    <span class=\"class name - identifier - (TRANSIENT)\" style=\"color:#2b91af;\">List<\/span><span class=\"punctuation\">&lt;<\/span><span class=\"class name - identifier - (TRANSIENT)\" style=\"color:#2b91af;\">XYZ<\/span><span class=\"punctuation\">&gt;<\/span> <span class=\"parameter name\" style=\"color:#1f377f;\">intersectionPoints<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color:blue;\">double<\/span> <span class=\"parameter name\" style=\"color:#1f377f;\">epsilon<\/span><span class=\"punctuation\">)<\/span>\n<span class=\"punctuation\">{<\/span>\n    <span class=\"comment\" style=\"color:green;\">\/\/ create a new curve with in the given interval [t1,t2]<\/span>\n    <span class=\"class name - identifier - (TRANSIENT)\" style=\"color:#2b91af;\">Curve<\/span> <span class=\"local name\" style=\"color:#1f377f;\">cc<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">c<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">Clone<\/span><span class=\"punctuation\">();<\/span>\n    <span class=\"keyword - control\" style=\"color:#8f08c4;\">try<\/span>\n    <span class=\"punctuation\">{<\/span>\n        <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">MakeBound<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">t1<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">t2<\/span><span class=\"punctuation\">);<\/span>\n    <span class=\"punctuation\">}<\/span>\n    <span class=\"keyword - control\" style=\"color:#8f08c4;\">catch<\/span>\n    <span class=\"punctuation\">{<\/span>\n        <span class=\"keyword - control\" style=\"color:#8f08c4;\">return<\/span><span class=\"punctuation\">;<\/span>\n    <span class=\"punctuation\">}<\/span>\n \n    <span class=\"class name - identifier - (TRANSIENT)\" style=\"color:#2b91af;\">XYZ<\/span> <span class=\"local name\" style=\"color:#1f377f;\">pp1<\/span><span class=\"punctuation\">,<\/span> <span class=\"local name\" style=\"color:#1f377f;\">pp2<\/span><span class=\"punctuation\">;<\/span><span class=\"comment\" style=\"color:green;\">\/\/ projection of start and end point of the curve segment on the plane<\/span>\n    <span class=\"class name - identifier - (TRANSIENT)\" style=\"color:#2b91af;\">XYZ<\/span> <span class=\"local name\" style=\"color:#1f377f;\">p1<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">GetEndPoint<\/span><span class=\"punctuation\">(<\/span><span class=\"number\">0<\/span><span class=\"punctuation\">);<\/span><span class=\"comment\" style=\"color:green;\">\/\/ start point<\/span>\n    <span class=\"class name - identifier - (TRANSIENT)\" style=\"color:#2b91af;\">XYZ<\/span> <span class=\"local name\" style=\"color:#1f377f;\">p2<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color:#74531f;\">GetEndPoint<\/span><span class=\"punctuation\">(<\/span><span class=\"number\">1<\/span><span class=\"punctuation\">);<\/span><span class=\"comment\" style=\"color:green;\">\/\/ end point<\/span>\n    <span class=\"keyword\" style=\"color:blue;\">double<\/span> <span class=\"local name\" style=\"color:#1f377f;\">h1<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color:#74531f;\">DistanceTo<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">q<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">p1<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color:blue;\">out<\/span> <span class=\"identifier - local name - unnecessary code - (TRANSIENT)\" style=\"color:#1f377f;\">pp1<\/span><span class=\"punctuation\">);<\/span><span class=\"comment\" style=\"color:green;\">\/\/ signed distance of point p1<\/span>\n    <span class=\"keyword\" style=\"color:blue;\">double<\/span> <span class=\"local name\" style=\"color:#1f377f;\">h2<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color:#74531f;\">DistanceTo<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">q<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">p2<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color:blue;\">out<\/span> <span class=\"identifier - local name - unnecessary code - (TRANSIENT)\" style=\"color:#1f377f;\">pp2<\/span><span class=\"punctuation\">);<\/span><span class=\"comment\" style=\"color:green;\">\/\/ signed distance of point p2<\/span>\n    <span class=\"keyword\" style=\"color:blue;\">double<\/span> <span class=\"local name\" style=\"color:#1f377f;\">t<\/span> <span class=\"operator\">=<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">t1<\/span> <span class=\"operator\">+<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">t2<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">\/<\/span> <span class=\"number\">2.0<\/span><span class=\"punctuation\">;<\/span><span class=\"comment\" style=\"color:green;\">\/\/ Curve parameter at the middle of the interval [t1,t2]<\/span>\n    <span class=\"keyword - control\" style=\"color:#8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">h1<\/span> <span class=\"operator\">*<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">h2<\/span> <span class=\"operator\">&gt;<\/span> <span class=\"number\">0<\/span><span class=\"punctuation\">)<\/span>\n    <span class=\"punctuation\">{<\/span>\n        <span class=\"comment\" style=\"color:green;\">\/\/ do not search for root here  <\/span>\n    <span class=\"punctuation\">}<\/span>\n    <span class=\"ReSharper Dead Code - keyword - control - (TRANSIENT)\" style=\"color:#8f08c4;\">else<\/span>\n    <span class=\"punctuation\">{<\/span>\n        <span class=\"comment\" style=\"color:green;\">\/\/ ------ root finding here -----<\/span>\n    <span class=\"punctuation\">}<\/span>\n    <span class=\"comment\" style=\"color:green;\">\/\/ divide the domain to [t1,t] and [t,t2] and recall the method<\/span>\n    <span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color:#74531f;\">CurvePlaneIntersection<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">cc<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">q<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">t1<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">intersectionPoints<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">epsilon<\/span><span class=\"punctuation\">);<\/span>\n    <span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color:#74531f;\">CurvePlaneIntersection<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">cc<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">q<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">t<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">t2<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">intersectionPoints<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">epsilon<\/span><span class=\"punctuation\">);<\/span>\n<span class=\"punctuation\">}<\/span><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Below graph illustrates an imaginary function <em><strong>f(t)<\/strong><\/em>&nbsp;across the domain <em><strong>[t<span>\u2081<\/span>,t<span>\u2082<\/span>]<\/strong><\/em>&nbsp;and we are interested in finding the roots. From the illustration you can see the function intersect the line <strong><em>y=0<\/em><\/strong> in 6 distinct positions. We first check the sign of<em><strong> f(t<span>\u2081<\/span>)*f(t<span>\u2082<\/span>)<\/strong><\/em>. since the sign is positive then we cannot insure if there is a root in domain <em><strong>[t<span>\u2081<\/span>,t<span>\u2082<\/span>]<\/strong><\/em>&nbsp;despite the fact that is obvious in the image. Therefore algorithm divides the interval <em><strong>[t<span>\u2081<\/span>,t<span>\u2082<\/span>]<\/strong><\/em>&nbsp;into two sub-domains <em><strong>[t<span>\u2081<\/span>,t<span>\u2083<\/span>]<\/strong><\/em> and <em><strong>[t<span>\u2081<\/span>,t<span>\u2082<\/span>]<\/strong><\/em>&nbsp;where <em><strong>t<span>\u2083<\/span> = (t<span>\u2081<\/span>+t<span>\u2082<\/span>) \/2.0<\/strong><\/em>.&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/roof-finding-1.png&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Now algorithm runs again in each sub-domain and check for the sign of function in both ends. Again in the both domains we have&nbsp;<strong><em>f(t<span>\u2081<\/span>)*f(t<span>\u2083<\/span>)&gt;0<\/em><\/strong> &amp; <em><strong>f(t<span>\u2083<\/span>)f(t<span>\u2082<\/span>)&gt;0<\/strong><\/em> . Both domains are divided again and send it back as new inputs to our recursive algorithm.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/roof-finding-2.png&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>In the new domains <em><strong>[t<span>\u2081<\/span>,t<span>\u2084<\/span>]<\/strong><\/em> and <em><strong>[t<span>\u2084<\/span>,t<span>\u2083<\/span>]<\/strong><\/em> we can see the <em><strong>f(t<span>\u2081<\/span>)*f(t<span>\u2084<\/span>)&lt;0<\/strong><\/em> and <em><strong>f(t<span>\u2084<\/span>)*f(t<span>\u2083<\/span>)&lt;0<\/strong><\/em> which means there is at least one root in each sub-domain.&nbsp; Algorithm shall now switch to root finding routine and find the nearest root to the guess point. To be consistent with the main algorithm we also use the mid point for our root finding algorithm and start the search from the point <em><strong>t<span>\u2086<\/span> = (t<span>\u2081<\/span>+t<span>\u2084<\/span>)\/2<\/strong><\/em> and similarly for the interval <em><strong>[t<span>\u2084<\/span>,t<span>\u2083<\/span>] <\/strong><\/em>from the point <em><strong>p<span>\u2087<\/span> <\/strong><\/em>. On the other side the interval <em><strong>[t<span>\u2083<\/span>,t<span>\u2085<\/span>]<\/strong><\/em> and <em><strong>[t<span>\u2085<\/span>,t<span>\u2082<\/span>]<\/strong> <\/em>are yet have positive sign for in both ends so they must be divided further.<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/roof-finding-3.png&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Now that root finding algorithm found the two roots <em><strong>r<span>\u2081<\/span><\/strong>&nbsp;<\/em>and <em><strong>r<span>\u2082<\/span><\/strong>&nbsp;<\/em>should we continue the sub-division process? well , Yes! as it was shown before there could any odd number of roots in the interval and not only one. In this case we cannot sub-divide the domain from the middle as we may end up finding the same root again. One solution is to divide the domain at the position of the root. In this case the sign of <strong><em>f(t<span>\u2081<\/span>)*f(r<span>\u2081<\/span>)<\/em><\/strong>&nbsp;and <strong><em>f(r<span>\u2081<\/span>)*f(t<span>\u2084<\/span>)&nbsp;<\/em><\/strong>is not useful as it is always returns zero (<em><strong>f(r<span>\u2081<\/span> ) = 0<\/strong><\/em>) . In this scenario we need to develop a new criteria to stop the search. looking at the below illustration for we can see a curve starts at point <em><strong>p<\/strong> <\/em>on one side of the plane and ends on point <em><strong>r<\/strong> <\/em>which is in the plane <em><strong>Q<\/strong><\/em>. For this curve to intersect the line plane<b><i> Q&nbsp;<\/i><\/b>in more than one location it is necessary to be longer than the line connecting the point <em><strong>p<\/strong> <\/em>to point <em><strong>r<\/strong><\/em>.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/projection-of-curve-on-a-plane-1.jpg&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>The difference in length of the curve <em><strong>C<\/strong><\/em> and line <em><strong>l<\/strong><\/em> cannot be less than&nbsp;<a href=\"https:\/\/www.revitapidocs.com\/2015\/0717b79e-efa9-e5ad-baed-999782c0e1e4.htm\"><span class=\"identifier - property name - (TRANSIENT)\">Application<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">ShortCurveTolerance&nbsp;<\/span><\/a>since this is the length of the shortest curve that is possible in Revit. Here we can update our criteria where at one side of the domain the function is zero.<span class=\"identifier - property name - (TRANSIENT)\"><\/span><\/p>\n<p><a href=\"https:\/\/www.revitapidocs.com\/2015\/0717b79e-efa9-e5ad-baed-999782c0e1e4.htm\"><\/a><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; background_color=&#8221;#f2f2f2&#8243; border_width_all=&#8221;1px&#8221; border_color_all=&#8221;#d3d3d3&#8243; custom_margin=&#8221;-2px|||||&#8221; custom_padding=&#8221;11px|15px|0px|15px|false|true&#8221; saved_tabs=&#8221;all&#8221;]<\/p>\n<pre style=\"font-family: Consolas; font-size: 13px; color: black;\"><span class=\"comment\" style=\"color: green;\">\/\/ check if at one side of the domain f(t)=0<\/span>\n<span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color: #2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">h1<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">epsilon<\/span> <span class=\"operator\">||<\/span> <span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color: #2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">h2<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">epsilon<\/span><span class=\"punctuation\">)<\/span>\n<span class=\"punctuation\">{<\/span>\n    <span class=\"comment\" style=\"color: green;\">\/\/ compute the length of the line connecting the p1 to p2<\/span>\n    <span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"local name\" style=\"color: #1f377f;\">lineLength<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">p1<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color: #74531f;\">DistanceTo<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">p2<\/span><span class=\"punctuation\">);<\/span>\n    <span class=\"comment\" style=\"color: green;\">\/\/ the difference in length is less than ShortCurveTolerance exit<\/span>\n    <span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color: #2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">lineLength<\/span> <span class=\"operator\">-<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Length<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">app<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">ShortCurveTolerance<\/span><span class=\"punctuation\">)<\/span>\n        <span class=\"keyword - control\" style=\"color: #8f08c4;\">return<\/span><span class=\"punctuation\">;<\/span><\/pre>\n<p><span class=\"punctuation\">}<\/span><br \/>\n<span class=\"keyword - control\" style=\"color: #8f08c4;\">else<\/span> <span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">h1<\/span> <span class=\"operator\">*<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">h2<\/span> <span class=\"operator\">&gt;<\/span> <span class=\"number\">0<\/span><span class=\"punctuation\">)<\/span><br \/>\n<span class=\"punctuation\">{<\/span><br \/>\n<span class=\"comment\" style=\"color: green;\">\/\/ do not search for root here  <\/span><br \/>\n<span class=\"punctuation\">}<\/span><br \/>\n<span class=\"ReSharper Dead Code - keyword - control - (TRANSIENT)\" style=\"color: #8f08c4;\">else<\/span><br \/>\n<span class=\"punctuation\">{<\/span><br \/>\n<span class=\"comment\" style=\"color: green;\">\/\/ &#8212;&#8212; root finding here &#8212;&#8211;<\/span><br \/>\n<span class=\"punctuation\">}<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Still the recursive algorithm can end up in an infinite loop! because the subdivision can go on and on for the portion of curve that is not intersecting the plane as <em><strong>f(a)*f(b)<\/strong><\/em> is always positive. We could stop the recursion with the same condition however with both points <em><strong>f(a)<\/strong><\/em> and <em><strong>f(b<\/strong><\/em>) on one side of <strong><em>y=0<\/em><\/strong> we can do a better job.&nbsp;<\/p>\n<p>In below illustration the plane <em><strong>Q&#8217;<\/strong><\/em> is defined as a plane which contains to end points of the curve<em><strong> C<\/strong><\/em> and perpendicular to the plane <em><strong>Q<\/strong><\/em>. we would like to project the curve <em><strong>C<\/strong> <\/em>on plane <em><strong>Q&#8217;<\/strong><\/em> and proof that length of the projection curve <em><strong>S<\/strong><\/em> is shorter than the length of the original curve <em><strong>C<\/strong><\/em>.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/projection-of-curve-on-a-plane-2.jpg&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Fist we write the length function L(s) and L(c) for both curves:<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image009-4.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;59%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Above is equivalent to below which means all we need to proof is that the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Inner_product_space\">inner product<\/a> of <em><strong>S&#8217;<\/strong> <\/em>is always smaller than inner product of<em><strong> C&#8217;<\/strong><\/em><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image012.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;82%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>To find the projected curve we move all the points of the curve <em><strong>C<\/strong><\/em> along the normal direction of projection plane <em><strong>(Q&#8217;)<\/strong><\/em> by the signed distance <em><strong>(Equation 3)<\/strong> <\/em>. Note that the n is the normal of the projection Plane.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image002-1.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;54%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Below we compute the derivative of <em><strong>S<\/strong><\/em> with respect to curve parameter <em><strong>t<\/strong><\/em> and its <a href=\"https:\/\/en.wikipedia.org\/wiki\/Inner_product_space\">inner product&nbsp;&nbsp;<\/a><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image003-4.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;45%&#8221;][\/et_pb_image][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image005-4.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;45%&#8221;][\/et_pb_image][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image007-3.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;45%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]Now we call inner product of s&#8217;  , remember n is normal vector therefore n.n =1 [\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image013.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;70%&#8221;][\/et_pb_image][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image015.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;70%&#8221;][\/et_pb_image][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image017.png&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; width=&#8221;70%&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>In equation number <em><strong>(9)<\/strong><\/em> it is obvious that inner product of <em><strong>S&#8217;<\/strong><\/em> is less than inner product of <em><strong>C&#8217;<\/strong><\/em> because the <em><strong>(C&#8217;.n)<\/strong><\/em><span><em><strong>\u00b2<\/strong><\/em> is always positive , hence we proofed that <em><strong>L(C) \u2265 L(S)<\/strong><\/em><\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/stop-conditions-1.jpg&#8221; show_in_lightbox=&#8221;on&#8221; align=&#8221;center&#8221; _builder_version=&#8221;3.22.7&#8243; custom_margin=&#8221;||5px|||&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p><span>Now instead of the actual Curve <em><strong>C<\/strong><\/em> we consider its projection on the plane <em><strong>Q&#8217;<\/strong><\/em> and look for a point which curve<em><strong> S<\/strong><\/em> contacts the plane. In below illustration the length of the curve <em><strong>S<\/strong> <\/em>is sum of the the length of Curve <em><strong>S\u2081<\/strong><\/em>&nbsp;and <em><strong>S\u2082<\/strong><\/em>&nbsp;hence we can write&nbsp;<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image align=&#8221;center&#8221; width=&#8221;66%&#8221; src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image001-5.png&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>We know that the shortest path between two points on a plane is always the straight line connecting them. therfore we can re-write equation <em><strong>(10)<\/strong><\/em> as below:<\/p>\n<p>[\/et_pb_text][et_pb_image align=&#8221;center&#8221; width=&#8221;67%&#8221; src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image003-5.png&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Let&#8217;s find the mirrored image of point <em><strong>P\u2081<\/strong><\/em> with respect to the line <em><strong>y=0 <\/strong><\/em>and call it point<strong><\/strong><em><strong> p&#8217;<\/strong><strong>\u2081<\/strong><strong>&nbsp;<\/strong><\/em>and also point<em><strong> q <\/strong><\/em>find the projection of point<strong><\/strong><em><strong> p<span>\u2082<\/span> <\/strong><\/em>on the line connecting<strong><\/strong><em><strong> p\u2081 <\/strong><\/em>to<strong><\/strong><em><strong> p&#8217;\u2081.<\/strong><\/em>&nbsp; We draw a line connecting <em><strong>p<span>\u2082<\/span><\/strong><\/em>&nbsp;and <em><strong>p&#8217;\u2081<\/strong><\/em>&nbsp;with length of <em><strong>l<span>\u2083<\/span><\/strong><\/em>. From the triangle inequality theorem , It is also known that in a triangle the sum of two edges is always greater or equal to the third edge.&nbsp; therefore :&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_image align=&#8221;center&#8221; width=&#8221;61%&#8221; src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image005-5.png&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p><span>Two triangles&nbsp;<em><strong> q,p&#8217;\u2081,p\u2082<\/strong><\/em>&nbsp;and <em><strong>q,p\u2082,p\u2081<\/strong><\/em>&nbsp;are right angle, hence from Pythagorean theorem we can write :<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image align=&#8221;center&#8221; width=&#8221;82%&#8221; src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image007-4.png&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>By substituting the <strong>c<span><em>\u2082<\/em><\/span><\/strong>&nbsp;from the right equation we then achieve :<\/p>\n<p>[\/et_pb_text][et_pb_image align=&#8221;center&#8221; width=&#8221;48%&#8221; src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image009-5.png&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>And finally we find a minimum length for the curve <em><strong>C<\/strong><\/em> , we can use this term as stop criteria&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_image align=&#8221;center&#8221; width=&#8221;68%&#8221; src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/image011-3.png&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Notice that if one of the terms <em><strong>h\u2081<\/strong><\/em> or <em><strong>h\u2082<\/strong><\/em> are zero our condition reduces to simple comparison between the curve length and line length which we used before, therefore it is not a bad idea to replace the previous condition with the new one. In below you can see that condition for both scenarios are combined into one.&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; background_color=&#8221;#f2f2f2&#8243; border_width_all=&#8221;1px&#8221; border_color_all=&#8221;#d3d3d3&#8243; custom_margin=&#8221;-2px|||||&#8221; custom_padding=&#8221;11px|15px|0px|15px|false|true&#8221; saved_tabs=&#8221;all&#8221;]<\/p>\n<pre style=\"font-family:Consolas;font-size:13px;color:black;\"><span class=\"comment\" style=\"color:green;\">\/\/ check if at one side of the domain f(t)=0 ot f(t1)*f(t2)&gt;0<\/span>\n<span class=\"keyword - control\" style=\"color:#8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color:#2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color:#74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">h1<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">epsilon<\/span> <span class=\"operator\">||<\/span> <span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color:#2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color:#74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">h2<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color:#1f377f;\">epsilon<\/span> <span class=\"operator\">||<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">h1<\/span><span class=\"operator\">*<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">h2<\/span><span class=\"operator\">&gt;<\/span><span class=\"number\">0<\/span><span class=\"punctuation\">)<\/span>\n<span class=\"punctuation\">{<\/span>\n    <span class=\"comment\" style=\"color:green;\">\/\/ compute the length of the line connecting the p1 to p2<\/span>\n    <span class=\"keyword\" style=\"color:blue;\">double<\/span> <span class=\"local name\" style=\"color:#1f377f;\">d<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">p1<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">DistanceTo<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">p2<\/span><span class=\"punctuation\">);<\/span>\n    <span class=\"comment\" style=\"color:green;\">\/\/ Check if the curve C is long enought to make an intersection with the plane<\/span>\n    <span class=\"keyword - control\" style=\"color:#8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">Length<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color:#2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color:#74531f;\">Sqrt<\/span><span class=\"punctuation\">(<\/span><span class=\"number\">4<\/span> <span class=\"operator\">*<\/span> <span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color:#2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color:#74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">h1<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">*<\/span> <span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color:#2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color:#74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">h2<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">+<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">d<\/span> <span class=\"operator\">*<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color:#1f377f;\">d<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">+<\/span> <span class=\"identifier\">tolerance<\/span><span class=\"punctuation\">)<\/span>\n        <span class=\"keyword - control\" style=\"color:#8f08c4;\">return<\/span><span class=\"punctuation\">;<\/span>\n \n<span class=\"punctuation\">}<\/span>\n<span class=\"keyword - control\" style=\"color:#8f08c4;\">else<\/span>\n<span class=\"punctuation\">{<\/span>\n    <span class=\"comment\" style=\"color:green;\">\/\/ ------ root finding here -----<\/span>\n<span class=\"punctuation\">}<\/span><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Now the algorithm stops when the sub-curve is not long enough to make an intersection with the plane. For example as shown in below illustration the curve segment between <em><strong>p\u2089<\/strong><\/em> and <em><strong>p\u2081\u2085<\/strong><\/em> will be subdivide till the length of the seghemt reach the treshold given by equation <em><strong>(11)&nbsp;<\/strong><\/em>&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/roof-finding-4.png&#8221; _builder_version=&#8221;3.22.7&#8243;][\/et_pb_image][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>Below you can find the entire implementation of the method. This method works well for less number of intersections. When it comes to massive number of intersections it may suffer in performance, however you can increase the speed by&nbsp; making the search slightly less accurate and using bigger value for the epsilon (maximum distance from the point to the plane). In the next post we discuss a simpler but more robust method which uses some Revit API native methods to compute the intersection.&nbsp; &nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;3.22.7&#8243; background_color=&#8221;#f2f2f2&#8243; border_width_all=&#8221;1px&#8221; border_color_all=&#8221;#d3d3d3&#8243; custom_margin=&#8221;-2px|||||&#8221; custom_padding=&#8221;11px|15px|0px|15px|false|true&#8221; saved_tabs=&#8221;all&#8221;]<\/p>\n<pre style=\"font-family: Consolas; font-size: 13px; color: black;\"><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n<span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> Search in domain[t1,t2] and finds the intersections of Curve c and Plane q within the given tolerance<\/span>\n<span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n<span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">c<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">Input curve<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n<span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">q<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">Input plane<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n<span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t1<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">Curve parameter at the start of domain.<\/span>\n<span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> To start pass c.GetEndParameter(0)<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n<span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t2<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">Curve parameter at the end of domain.<\/span>\n<span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> To start pass c.GetEndParameter(1)<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n<span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">intersectionPoints<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">Empty list to store the intersection points<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n<span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">epsilon<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">Threshold for the distance of the point to the plane<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n<span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">tolerance<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">Use Application.ShortCurveTolerance<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n<span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"keyword\" style=\"color: blue;\">static<\/span> <span class=\"keyword\" style=\"color: blue;\">void<\/span> <span class=\"method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Curve_PlaneIntersection4\n<\/span><span class=\"punctuation\">(<\/span><span class=\"class name - identifier - (TRANSIENT)\" style=\"color: #2b91af;\">Curve<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">c<\/span><span class=\"punctuation\">,<\/span> <span class=\"class name - identifier - (TRANSIENT)\" style=\"color: #2b91af;\">Plane<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">q<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">t1<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">t2<\/span><span class=\"punctuation\">,<\/span> <span class=\"class name - identifier - (TRANSIENT)\" style=\"color: #2b91af;\">List<\/span><span class=\"punctuation\">&lt;<\/span><span class=\"class name - identifier - (TRANSIENT)\" style=\"color: #2b91af;\">XYZ<\/span><span class=\"punctuation\">&gt;<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">intersectionPoints<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">epsilon<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">tolerance<\/span><span class=\"punctuation\">)<\/span>\n<span class=\"punctuation\">{<\/span>\n    <span class=\"comment\" style=\"color: green;\">\/\/ create a new curve with in the given interval [t1,t2]<\/span>\n    <span class=\"class name - identifier - (TRANSIENT)\" style=\"color: #2b91af;\">Curve<\/span> <span class=\"local name\" style=\"color: #1f377f;\">cc<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">c<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color: #74531f;\">Clone<\/span><span class=\"punctuation\">();<\/span>\n    <span class=\"keyword - control\" style=\"color: #8f08c4;\">try<\/span>\n    <span class=\"punctuation\">{<\/span>\n        <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color: #74531f;\">MakeBound<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t1<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t2<\/span><span class=\"punctuation\">);<\/span>\n    <span class=\"punctuation\">}<\/span>\n    <span class=\"keyword - control\" style=\"color: #8f08c4;\">catch<\/span>\n    <span class=\"punctuation\">{<\/span>\n        <span class=\"keyword - control\" style=\"color: #8f08c4;\">return<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color: green;\">\/\/ if the domain is too small do not continue<\/span>\n    <span class=\"punctuation\">}<\/span><\/pre>\n<p><span class=\"class name - identifier - (TRANSIENT)\" style=\"color: #2b91af;\">XYZ<\/span> <span class=\"local name\" style=\"color: #1f377f;\">pp1<\/span><span class=\"punctuation\">,<\/span> <span class=\"local name\" style=\"color: #1f377f;\">pp2<\/span><span class=\"punctuation\">;<\/span><span class=\"comment\" style=\"color: green;\">\/\/ projection of start and end point of the curve segment on the plane<\/span><br \/>\n<span class=\"class name - identifier - (TRANSIENT)\" style=\"color: #2b91af;\">XYZ<\/span> <span class=\"local name\" style=\"color: #1f377f;\">p1<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color: #74531f;\">GetEndPoint<\/span><span class=\"punctuation\">(<\/span><span class=\"number\">0<\/span><span class=\"punctuation\">);<\/span><span class=\"comment\" style=\"color: green;\">\/\/ start point<\/span><br \/>\n<span class=\"class name - identifier - (TRANSIENT)\" style=\"color: #2b91af;\">XYZ<\/span> <span class=\"local name\" style=\"color: #1f377f;\">p2<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color: #74531f;\">GetEndPoint<\/span><span class=\"punctuation\">(<\/span><span class=\"number\">1<\/span><span class=\"punctuation\">);<\/span><span class=\"comment\" style=\"color: green;\">\/\/ end point<\/span><br \/>\n<span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"local name\" style=\"color: #1f377f;\">h1<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">DistanceTo<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">q<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">p1<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">out<\/span> <span class=\"identifier - local name - unnecessary code - (TRANSIENT)\" style=\"color: #1f377f;\">pp1<\/span><span class=\"punctuation\">);<\/span><span class=\"comment\" style=\"color: green;\">\/\/ signed distance of point p1<\/span><br \/>\n<span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"local name\" style=\"color: #1f377f;\">h2<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">DistanceTo<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">q<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">p2<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">out<\/span> <span class=\"identifier - local name - unnecessary code - (TRANSIENT)\" style=\"color: #1f377f;\">pp2<\/span><span class=\"punctuation\">);<\/span><span class=\"comment\" style=\"color: green;\">\/\/ signed distance of point p2<\/span><br \/>\n<span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"local name\" style=\"color: #1f377f;\">t<\/span> <span class=\"operator\">=<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t1<\/span> <span class=\"operator\">+<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t2<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">\/<\/span> <span class=\"number\">2.0<\/span><span class=\"punctuation\">;<\/span><span class=\"comment\" style=\"color: green;\">\/\/ Curve parameter at the middle of the interval [t1,t2]<\/span><br \/>\n<span class=\"comment\" style=\"color: green;\">\/\/ check if at one side of the domain f(t)=0 ot f(t1)*f(t2)&gt;0<\/span><br \/>\n<span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color: #2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">h1<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">epsilon<\/span> <span class=\"operator\">||<\/span> <span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color: #2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">h2<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">epsilon<\/span> <span class=\"operator\">||<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">h1<\/span> <span class=\"operator\">*<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">h2<\/span> <span class=\"operator\">&gt;<\/span> <span class=\"number\">0<\/span><span class=\"punctuation\">)<\/span><br \/>\n<span class=\"punctuation\">{<\/span><br \/>\n<span class=\"comment\" style=\"color: green;\">\/\/ compute the length of the line connecting the p1 to p2<\/span><br \/>\n<span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"local name\" style=\"color: #1f377f;\">d<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">p1<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color: #74531f;\">DistanceTo<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">p2<\/span><span class=\"punctuation\">);<\/span><br \/>\n<span class=\"comment\" style=\"color: green;\">\/\/ Check if the curve C is long enought to make an intersection with the plane<\/span><br \/>\n<span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Length<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color: #2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Sqrt<\/span><span class=\"punctuation\">(<\/span><span class=\"number\">4<\/span> <span class=\"operator\">*<\/span> <span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color: #2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">h1<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">*<\/span> <span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color: #2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">h2<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">+<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">d<\/span> <span class=\"operator\">*<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">d<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">+<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">tolerance<\/span><span class=\"punctuation\">)<\/span><br \/>\n<span class=\"keyword - control\" style=\"color: #8f08c4;\">return<\/span><span class=\"punctuation\">;<\/span><\/p>\n<p><span class=\"punctuation\">}<\/span><br \/>\n<span class=\"keyword - control\" style=\"color: #8f08c4;\">else<\/span><br \/>\n<span class=\"punctuation\">{<\/span><\/p>\n<p><span class=\"comment\" style=\"color: green;\">\/\/Newton method for finding the root of the function f(t)<\/span><br \/>\n<span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"local name\" style=\"color: #1f377f;\">f<\/span><span class=\"punctuation\">;<\/span><span class=\"comment\" style=\"color: green;\">\/\/ the value of the function in each iteration <\/span><br \/>\n<span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"local name\" style=\"color: #1f377f;\">df<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color: green;\">\/\/ the first derivative of the function f at each iteration<\/span><br \/>\n<span class=\"keyword\" style=\"color: blue;\">double<\/span> <span class=\"local name\" style=\"color: #1f377f;\">dx<\/span> <span class=\"operator\">=<\/span> <span class=\"number\">0<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color: green;\">\/\/ step size (delta x)<\/span><br \/>\n<span class=\"keyword\" style=\"color: blue;\">int<\/span> <span class=\"local name\" style=\"color: #1f377f;\">I<\/span> <span class=\"operator\">=<\/span> <span class=\"number\">0<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color: green;\">\/\/ number of iterations <\/span><br \/>\n<span class=\"class name - identifier - (TRANSIENT)\" style=\"color: #2b91af;\">Transform<\/span> <span class=\"local name\" style=\"color: #1f377f;\">tr<\/span><span class=\"punctuation\">;<\/span><span class=\"comment\" style=\"color: green;\">\/\/= Transform.Identity;<\/span><br \/>\n<span class=\"keyword\" style=\"color: blue;\">bool<\/span> <span class=\"local name - unnecessary code - (TRANSIENT)\" style=\"color: #1f377f;\">rootFound<\/span> <span class=\"ReSharper Dead Code - operator - (TRANSIENT)\">=<\/span><span class=\"ReSharper Dead Code\"> <\/span><span class=\"ReSharper Dead Code - keyword - (TRANSIENT)\" style=\"color: blue;\">false<\/span><span class=\"punctuation\">;<\/span><span class=\"comment\" style=\"color: green;\">\/\/ a flag to identify whether an intersection found or not<\/span><br \/>\n<span class=\"keyword - control\" style=\"color: #8f08c4;\">do<\/span><br \/>\n<span class=\"punctuation\">{<\/span><br \/>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">t<\/span> <span class=\"operator\">+=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">dx<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color: green;\">\/\/ move t to the new position  <\/span><br \/>\n<span class=\"comment\" style=\"color: green;\">\/\/ ensure the parameter is within the limits<\/span><br \/>\n<span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">t<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t1<\/span><span class=\"punctuation\">)<\/span><br \/>\n<span class=\"punctuation\">{<\/span><br \/>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">t<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t1<\/span><span class=\"punctuation\">;<\/span><br \/>\n<span class=\"punctuation\">}<\/span><br \/>\n<span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">t<\/span> <span class=\"operator\">&gt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t2<\/span><span class=\"punctuation\">)<\/span><br \/>\n<span class=\"punctuation\">{<\/span><br \/>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">t<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t2<\/span><span class=\"punctuation\">;<\/span><br \/>\n<span class=\"punctuation\">}<\/span><\/p>\n<p><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">I<\/span><span class=\"operator\">++<\/span><span class=\"punctuation\">;<\/span><br \/>\n<span class=\"comment\" style=\"color: green;\">\/\/ compute C(t) and C'(t) <\/span><br \/>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">tr<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">cc<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color: #74531f;\">ComputeDerivatives<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">t<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">false<\/span><span class=\"punctuation\">);<\/span><br \/>\n<span class=\"comment\" style=\"color: green;\">\/\/compute the objective function f(t)<\/span><br \/>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">f<\/span> <span class=\"operator\">=<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">tr<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Origin<\/span> <span class=\"operator - operator - overloaded - (TRANSIENT)\" style=\"color: #74531f;\">&#8211;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">q<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Origin<\/span><span class=\"punctuation\">)<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color: #74531f;\">DotProduct<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">q<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Normal<\/span><span class=\"punctuation\">);<\/span><br \/>\n<span class=\"comment\" style=\"color: green;\">\/\/ compute the derivative of function f(t)<\/span><br \/>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">df<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">tr<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">BasisX<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color: #74531f;\">DotProduct<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">q<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Normal<\/span><span class=\"punctuation\">);<\/span><br \/>\n<span class=\"comment\" style=\"color: green;\">\/\/ find the step <\/span><br \/>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">dx<\/span> <span class=\"operator\">=<\/span> <span class=\"operator\">&#8211;<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">f<\/span> <span class=\"operator\">\/<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">df<\/span><span class=\"punctuation\">;<\/span><br \/>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">rootFound<\/span> <span class=\"operator\">=<\/span> <span class=\"class name - identifier - static symbol - (TRANSIENT)\" style=\"color: #2b91af;\">Math<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Abs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">f<\/span><span class=\"punctuation\">)<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">epsilon<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color: green;\">\/\/ check if f is small enough<\/span><br \/>\n<span class=\"punctuation\">}<\/span> <span class=\"keyword - control\" style=\"color: #8f08c4;\">while<\/span> <span class=\"punctuation\">(<\/span><br \/>\n<span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">I<\/span> <span class=\"operator\">&lt;<\/span> <span class=\"number\">100<\/span> <span class=\"comment\" style=\"color: green;\">\/\/ stop if more than 100 iterations is done<\/span><br \/>\n<span class=\"operator\">&amp;&amp;<\/span><br \/>\n<span class=\"operator\">!<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">rootFound<\/span> <span class=\"comment\" style=\"color: green;\">\/\/ stop if root is found <\/span><br \/>\n<span class=\"punctuation\">);<\/span><br \/>\n<span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">rootFound<\/span><span class=\"punctuation\">)<\/span><br \/>\n<span class=\"punctuation\">{<\/span><br \/>\n<span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">intersectionPoints<\/span><span class=\"operator\">.<\/span><span class=\"identifier - method name - (TRANSIENT)\" style=\"color: #74531f;\">Add<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">tr<\/span><span class=\"operator\">.<\/span><span class=\"identifier - property name - (TRANSIENT)\">Origin<\/span><span class=\"punctuation\">);<\/span><br \/>\n<span class=\"punctuation\">}<\/span><br \/>\n<span class=\"punctuation\">}<\/span><br \/>\n<span class=\"comment\" style=\"color: green;\">\/\/divide the domain [t1,t2] into [t1,t] and [t,t2] and continue <\/span><br \/>\n<span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Curve_PlaneIntersection4<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">cc<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">q<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t1<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">t<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">intersectionPoints<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">epsilon<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">tolerance<\/span><span class=\"punctuation\">);<\/span><br \/>\n<span class=\"identifier - method name - static symbol - (TRANSIENT)\" style=\"color: #74531f;\">Curve_PlaneIntersection4<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">cc<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">q<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - local name - (TRANSIENT)\" style=\"color: #1f377f;\">t<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">t2<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">intersectionPoints<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">epsilon<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier - parameter name - (TRANSIENT)\" style=\"color: #1f377f;\">tolerance<\/span><span class=\"punctuation\">);<\/span><br \/>\n<span class=\"punctuation\">}<\/span><\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Plane-Curve intersection from algebraic point of view is quiet similar to Plane-Line intersection which we discussed in previous post. In this post I would like to take the same approach in finding the Plane-Curve intersection which involves root finding techniques, and in the next post we will also look at Face-Curve intersection method and we [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":890,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":""},"categories":[45],"tags":[50,33,47,48],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Plane and Curve intersection - Parametric Zoo<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Plane and Curve intersection - Parametric Zoo\" \/>\n<meta property=\"og:description\" content=\"Plane-Curve intersection from algebraic point of view is quiet similar to Plane-Line intersection which we discussed in previous post. In this post I would like to take the same approach in finding the Plane-Curve intersection which involves root finding techniques, and in the next post we will also look at Face-Curve intersection method and we [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/\" \/>\n<meta property=\"og:site_name\" content=\"Parametric Zoo\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-31T21:31:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-03-31T21:31:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/Curve-plane-intersection.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1733\" \/>\n\t<meta property=\"og:image:height\" content=\"1156\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"PARA\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"PARA\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"24 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.parametriczoo.com\/#website\",\"url\":\"https:\/\/www.parametriczoo.com\/\",\"name\":\"Parametric Zoo\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.parametriczoo.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/#primaryimage\",\"url\":\"https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/Curve-plane-intersection.jpg\",\"contentUrl\":\"https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/Curve-plane-intersection.jpg\",\"width\":1733,\"height\":1156},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/\",\"url\":\"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/\",\"name\":\"Plane and Curve intersection - Parametric Zoo\",\"isPartOf\":{\"@id\":\"https:\/\/www.parametriczoo.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/#primaryimage\"},\"datePublished\":\"2020-03-31T21:31:53+00:00\",\"dateModified\":\"2020-03-31T21:31:58+00:00\",\"author\":{\"@id\":\"https:\/\/www.parametriczoo.com\/#\/schema\/person\/0368c6eb8bfe3a003504793be2a2e0e3\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.parametriczoo.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Plane and Curve intersection\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.parametriczoo.com\/#\/schema\/person\/0368c6eb8bfe3a003504793be2a2e0e3\",\"name\":\"PARA\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.parametriczoo.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2b2ff0ff40493545df12d0b31a504675?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2b2ff0ff40493545df12d0b31a504675?s=96&d=mm&r=g\",\"caption\":\"PARA\"},\"url\":\"https:\/\/www.parametriczoo.com\/index.php\/author\/para\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Plane and Curve intersection - Parametric Zoo","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/","og_locale":"en_US","og_type":"article","og_title":"Plane and Curve intersection - Parametric Zoo","og_description":"Plane-Curve intersection from algebraic point of view is quiet similar to Plane-Line intersection which we discussed in previous post. In this post I would like to take the same approach in finding the Plane-Curve intersection which involves root finding techniques, and in the next post we will also look at Face-Curve intersection method and we [&hellip;]","og_url":"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/","og_site_name":"Parametric Zoo","article_published_time":"2020-03-31T21:31:53+00:00","article_modified_time":"2020-03-31T21:31:58+00:00","og_image":[{"width":1733,"height":1156,"url":"https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/Curve-plane-intersection.jpg","type":"image\/jpeg"}],"author":"PARA","twitter_card":"summary_large_image","twitter_misc":{"Written by":"PARA","Est. reading time":"24 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.parametriczoo.com\/#website","url":"https:\/\/www.parametriczoo.com\/","name":"Parametric Zoo","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.parametriczoo.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/#primaryimage","url":"https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/Curve-plane-intersection.jpg","contentUrl":"https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/Curve-plane-intersection.jpg","width":1733,"height":1156},{"@type":"WebPage","@id":"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/","url":"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/","name":"Plane and Curve intersection - Parametric Zoo","isPartOf":{"@id":"https:\/\/www.parametriczoo.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/#primaryimage"},"datePublished":"2020-03-31T21:31:53+00:00","dateModified":"2020-03-31T21:31:58+00:00","author":{"@id":"https:\/\/www.parametriczoo.com\/#\/schema\/person\/0368c6eb8bfe3a003504793be2a2e0e3"},"breadcrumb":{"@id":"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.parametriczoo.com\/index.php\/2020\/03\/31\/plane-and-curve-intersection\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.parametriczoo.com\/"},{"@type":"ListItem","position":2,"name":"Plane and Curve intersection"}]},{"@type":"Person","@id":"https:\/\/www.parametriczoo.com\/#\/schema\/person\/0368c6eb8bfe3a003504793be2a2e0e3","name":"PARA","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.parametriczoo.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2b2ff0ff40493545df12d0b31a504675?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2b2ff0ff40493545df12d0b31a504675?s=96&d=mm&r=g","caption":"PARA"},"url":"https:\/\/www.parametriczoo.com\/index.php\/author\/para\/"}]}},"jetpack_featured_media_url":"https:\/\/www.parametriczoo.com\/wp-content\/uploads\/2020\/03\/Curve-plane-intersection.jpg","_links":{"self":[{"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/posts\/663"}],"collection":[{"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/comments?post=663"}],"version-history":[{"count":0,"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/posts\/663\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/media\/890"}],"wp:attachment":[{"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/media?parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/categories?post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/tags?post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}