• 10
• 12
• 12
• 14
• 17

# [C#] Dealing with parallel rays using this parametric algorithm for octree traversal

This topic is 2974 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi folks, I'm currently trying to implement a 2D version of an octree traversal algorithm before moving on to 3D. The algorithm is found in the paper titled "An Efficient Parametric Algorithm for Octree Traversal" found here. On the bottom of page 5 (section 3.3) it tells me that: t_xm(o,r) = +∞ OR -∞ depending on whether the ray's origin is less than (x0 + x1) / 2. Is x0 and x1, in this case, the min and max point of the node? In which case I would use the following:
            float txm;
float tym;

if (float.IsInfinity(tx0) || float.IsInfinity(tx1))
{
txm = ray.Origin.X < (node.MinPoint.X + node.MaxPoint.X) * 0.5f ? float.PositiveInfinity : float.NegativeInfinity;
}
else
{
txm = 0.5f * (tx0 + tx1);
}
if (float.IsInfinity(ty0) || float.IsInfinity(ty1))
{
tym = ray.Origin.Y < (node.MinPoint.Y + node.MaxPoint.Y) * 0.5f ? float.PositiveInfinity : float.NegativeInfinity;
}
else
{
tym = 0.5f * (ty0 + ty1);
}


Is txm worked out the same way based on comparing both tx0 and tx1 to infinity where:
            Vector2 t0 = node.MinPoint - ray.Origin;
t0 /= ray.Direction;

Vector2 t1 = node.MaxPoint - ray.Origin;
t1 /= ray.Direction;

tx0 = t0.X; tx1 = t1.X; ty0 = t0.Y; ty1 = t0.Y; and the ray's direction is 0 then /0 will equal ±infinity. Or should tx0 and tx1 be compared to +∞ OR -∞ and dealt with separately? In other words, is what I have coded correct? Is there any way of dealing with the parallel case in a better manner and avoiding infinite numbers at all? Thank you.