<?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[Extraction of indexes out of range of safeframe]]></title><description><![CDATA[<p dir="auto">Hi, I'm looking for codes and trying to combine them because I want to extract out-of-frame indexes for objects that are within the range of the safeframe. However, there's an issue where all indexes that are not out of range are extracted. How can I get an out-of-range index? I want a script that ultimately removes out-of-range vertices.<br />
Below is the code that is currently being written</p>
<p dir="auto"><a href="/forum/assets/uploads/files/1713862596731-test.py">test.py</a></p>
]]></description><link>http://developers.maxon.net/forum/topic/15493/extraction-of-indexes-out-of-range-of-safeframe</link><generator>RSS for Node</generator><lastBuildDate>Wed, 20 May 2026 11:42:19 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/15493.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 Apr 2024 08:51:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Extraction of indexes out of range of safeframe on Wed, 24 Apr 2024 02:21:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ferdinand">@<bdi>ferdinand</bdi></a> Thank you, I got the script I wanted using the answer code!</p>
]]></description><link>http://developers.maxon.net/forum/post/74194</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/74194</guid><dc:creator><![CDATA[seora]]></dc:creator><pubDate>Wed, 24 Apr 2024 02:21:39 GMT</pubDate></item><item><title><![CDATA[Reply to Extraction of indexes out of range of safeframe on Tue, 23 Apr 2024 12:17:22 GMT]]></title><description><![CDATA[<p dir="auto">Hey <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/seora">@<bdi>seora</bdi></a>,</p>
<p dir="auto">Thank you for reaching out to us. I get that you want to determine if a vertex lies within the safe frame, but I do not understand what your concrete question is. There is no such built-in function, you would have to write that yourself (if that is the question).</p>
<p dir="auto">Just cast a ray from the origin of the scene camera towards your vertex (in world coordinates) and check if it intersects with the safe frame. In <a href="https://developers.maxon.net/docs/py/2024_4_0a/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseView/index.html#c4d.BaseView" target="_blank" rel="noopener noreferrer nofollow ugc">BaseView</a> you can find the necessary functions to convert points out of screen into world space. How to write a ray-rectangle intersection is out of scope of support as this is a basic math question.</p>
<p dir="auto">Cheers,<br />
Ferdinand</p>
<h4>Code</h4>
<pre><code class="language-py">"""Warning: This is AI generated and documented code.
"""
from c4d import Vector

def ray_rectangle_intersection(ray_origin: Vector, ray_direction: Vector, rectangle_vertices: list[Vector]) -&gt; tuple[bool, Vector]:
    """
    Determines if a ray intersects with a rectangle in 3D.

    Parameters:
    ray_origin (Vector): The origin of the ray.
    ray_direction (Vector): The direction of the ray.
    rectangle_vertices (list[Vector]): The vertices of the rectangle, ordered either clockwise or counter-clockwise.

    Returns:
    tuple[bool, Vector]: A tuple where the first element is a boolean indicating whether the ray intersects the rectangle,
                         and the second element is the point of intersection if it does, or None otherwise.
    """
    # Compute the normal of the plane that the rectangle lies in
    edge1 = rectangle_vertices[1] - rectangle_vertices[0]
    edge2 = rectangle_vertices[3] - rectangle_vertices[0]
    rectangle_normal = edge1.Cross(edge2)

    # Use the ray-plane intersection formula to find the point where the ray intersects the plane
    t = (rectangle_vertices[0] - ray_origin).Dot(rectangle_normal) / ray_direction.Dot(rectangle_normal)
    intersection_point = ray_origin + t * ray_direction

    # Check if this point lies within the rectangle
    edge3 = rectangle_vertices[2] - rectangle_vertices[1]
    edge4 = rectangle_vertices[2] - rectangle_vertices[3]
    within_rectangle = (edge1.Cross(intersection_point - rectangle_vertices[0]).Dot(rectangle_normal) &gt;= 0 and
                        edge2.Cross(intersection_point - rectangle_vertices[0]).Dot(rectangle_normal) &gt;= 0 and
                        edge3.Cross(intersection_point - rectangle_vertices[1]).Dot(rectangle_normal) &gt;= 0 and
                        edge4.Cross(intersection_point - rectangle_vertices[3]).Dot(rectangle_normal) &gt;= 0)

    return within_rectangle, intersection_point if within_rectangle else None
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/74186</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/74186</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Tue, 23 Apr 2024 12:17:22 GMT</pubDate></item></channel></rss>