<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Find object &#x2F; surface normal for given point in space]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'd like to find an object / surface normal (tangent vector) for a given point in space. More in detail I have an object and a spline following the objects surface and I want to get the object normal for each spline point.</p>
<p dir="auto">I couldn't find a way how to approach this, yet ....<br />
Maybe someone has a tip or an idea?<br />
(I want to do this in python)</p>
<p dir="auto">best, Index</p>
]]></description><link>http://developers.maxon.net/forum/topic/13450/find-object-surface-normal-for-given-point-in-space</link><generator>RSS for Node</generator><lastBuildDate>Fri, 12 Jun 2026 02:06:33 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/13450.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 03 Jul 2021 19:22:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Find object &#x2F; surface normal for given point in space on Mon, 26 Jul 2021 09:03:09 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/indexofrefraction">@<bdi>indexofrefraction</bdi></a>,</p>
<p dir="auto">without further questions or replies, we will consider this topic as solved by Thursday and flag it accordingly.</p>
<p dir="auto">Thank you for your understanding,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum/post/67263</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/67263</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Mon, 26 Jul 2021 09:03:09 GMT</pubDate></item><item><title><![CDATA[Reply to Find object &#x2F; surface normal for given point in space on Wed, 07 Jul 2021 20:15:46 GMT]]></title><description><![CDATA[<p dir="auto">thanks ferdinand,</p>
<p dir="auto">that's a roadmap !!<br />
gosh, it looks like i have quite some work ahead of me!<br />
<img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":-)" alt="🙂" /></p>
<p dir="auto">dunno yet, if i'm crazy enough to give it a try :))</p>
<p dir="auto">ps. that also means that the nearest intersection between<br />
a point and an object without vector is not possible with GeRayCollider (?)</p>
]]></description><link>http://developers.maxon.net/forum/post/67085</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/67085</guid><dc:creator><![CDATA[indexofrefraction]]></dc:creator><pubDate>Wed, 07 Jul 2021 20:15:46 GMT</pubDate></item><item><title><![CDATA[Reply to Find object &#x2F; surface normal for given point in space on Wed, 07 Jul 2021 18:40:47 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/indexofrefraction">@<bdi>indexofrefraction</bdi></a>,</p>
<p dir="auto">as a disclaimer upfront, this is a private posting of mine, your case is still being handled by @m_adam.</p>
<p dir="auto">When I see your case correctly, you are interested in the point <em>p</em> and its normal <em>n</em> on a polygonal mesh <em>M</em> that is closest to a given point <em>q</em> on a spline <em>S</em>. Or in short, you are interested in the projection of <em>q</em> onto <em>M</em>. Ray-casting, e.g., <code>GeRayCollider</code>, will not help you much here I would say, since coming up with  a ray-casting direction is the same problem as the one you are trying to solve; as you already did find out yourself.</p>
<p dir="auto">Cinema 4D's Python SDK has no projection helper class, so, you would have to do that on your own. The general procedure would be:</p>
<ol>
<li>Find the the vertex <em>v</em> in <em>M</em> that is closest to <em>q</em>.</li>
<li>Get the list <em>L</em> of all polygons that are attached to <em>v</em> - you can use <code>c4d.utils.Neighbor</code> for that.</li>
<li>Project <em>q</em> onto all polygons in <em>L</em> and store the results in <em>R</em>. Principally, what one has to do here is point-plane projections. The concrete procedure is something like the following for a single polygon <em>P</em>.<br />
a. Compute the point-plane projection <em>proj</em> of <em>q</em> for each triangle <em>T</em> in <em>P</em>.<br />
b. Convert <em>proj</em> from Cartesian into Barycentric coordinates and clamp the point to the interval [0, 1]. We have to do this since there is no guarantee that the point we projected onto the plane of <em>T</em> actually does lie within <em>T</em>. So, we ware using Barycentric coordinates to rectify this.<br />
c. Convert the clamped points back into Cartesian coordinates and then select the one closest to <em>q</em>. This point is the clamped projection of <em>q</em> onto <em>P</em>.</li>
<li>Select the point in <em>R</em> that is closest to <em>q</em>, that point is <em>p</em>, the projection of your query point <em>q</em> onto <em>M</em>.</li>
<li>Define the normal of <em>p</em> as one of the normals of the polygon <em>P</em> the point <em>p</em> is associated with. That polygon is already known to us due to the prior computations. How to compute the normal exactly depends on what you would consider to be the <em>object</em> normal.</li>
</ol>
<p dir="auto">For all that you do not need any fancy classes or libraries, but it can be a bit slow if you do this for very large meshes. The expensive part is the first step, finding the closest vertex <em>v</em> in <em>M</em>. Which is probably why Maxime mentioned kd-trees. They are a form <a href="https://en.wikipedia.org/wiki/Binary_space_partitioning" target="_blank" rel="noopener noreferrer nofollow ugc">Binary-Space-Partitioning</a>, i.e., a performant way to find the closest point <em>p</em> out of a point cloud <em>C</em> for a query point <em>q</em>. Since the Cinema Python SDK has no kd-Tree, you would have to write your own BSP implementation, a octree would be enough in this case (which is effectively just a clever form of a 3D-lattice). But this is not really needed functionality-wise, it will just make your solution more performant.</p>
<p dir="auto">Cheers,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum/post/67081</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/67081</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Wed, 07 Jul 2021 18:40:47 GMT</pubDate></item><item><title><![CDATA[Reply to Find object &#x2F; surface normal for given point in space on Wed, 07 Jul 2021 16:46:54 GMT]]></title><description><![CDATA[<p dir="auto">thanks maxime,</p>
<p dir="auto">hm.. looking at c4d.utils.GeRayCollider ...<br />
is it correct that i always have to define a ray vector ?<br />
as i understand it GetNearestIntersection() is just the nearest intersection with the given vector, right?</p>
<p dir="auto">is possible to eval the nearest intersection between a point and an object without vector?<br />
or is that what KdTree is used for ?</p>
<p dir="auto">best, index</p>
]]></description><link>http://developers.maxon.net/forum/post/67077</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/67077</guid><dc:creator><![CDATA[indexofrefraction]]></dc:creator><pubDate>Wed, 07 Jul 2021 16:46:54 GMT</pubDate></item><item><title><![CDATA[Reply to Find object &#x2F; surface normal for given point in space on Mon, 05 Jul 2021 16:00:38 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/indexofrefraction">@<bdi>indexofrefraction</bdi></a> unfortually the Python Cinema 4D API does not provide any way to easily find an object/surface normal for a given point in space.</p>
<p dir="auto">One things could be to use a <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d.utils/GeRayCollider/index.html" target="_blank" rel="noopener noreferrer nofollow ugc">c4d.utils.GeRayCollider</a> to retrieve the polygon attached to the point and then compute yourself the surface normal.</p>
<p dir="auto">Another way would be to create a KdTree and retrieve the nearest point and compute this tangent vector yourself.But there is no KdTree in the Python Cinema 4D SDK, so you will need to build it yourself.</p>
<p dir="auto">Cheers,<br />
Maxime.</p>
]]></description><link>http://developers.maxon.net/forum/post/67062</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/67062</guid><dc:creator><![CDATA[m_adam]]></dc:creator><pubDate>Mon, 05 Jul 2021 16:00:38 GMT</pubDate></item></channel></rss>