Sign in to follow this  

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

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;
                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;
                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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this