Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8925873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:49:03+00:00 2026-06-15T07:49:03+00:00

My Plane class has two fields: public Vector3 Norm; //normal vector public double Offset;

  • 0

My Plane class has two fields:

public Vector3 Norm; //normal vector 
public double Offset; //signed distance to origin

This is the code I use for intersection, and I don’t know if it is correct. I double
checked my equations and everything, but I would like to get feedback from people
more experienced with this.

public override Intersection Intersect(Ray ray)
{
    // Create Intersection.
    Intersection result = new Intersection();

    // Find t.
    double t = - (Vector3.Dot(Norm,ray.Start) + Offset) / (Vector3.Dot(Norm, ray.Dir));
    if (t < 0) // the ray does not hit the surface, that is, the surface is "behind" the ray
        return null;

    // Get a point on the plane.
    Vector3 p = ray.Start + t * ray.Dir;

    // Does the ray intersect the plane inside or outside?
    Vector3 planeToRayStart = ray.Start - p;
    double dot = Vector3.Dot (planeToRayStart, Norm);
    if (dot > 0) {
        result.Inside = false;
    } else {
        result.Inside = true;
    }

    result.Dist = t;
    return result;
}

Also, I am not sure what to do if t is close to 0? Should I check with epsilon and how big
should epsilon be? Also I am not sure if I check correctly whether the ray intersects the plane
from in or out?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:49:05+00:00Added an answer on June 15, 2026 at 7:49 am

    You’re code looks mostly fine, see this slide. Since your plane is essentially defined as the set of rays which start at a particular point (which is encapsulate in the offset parameter) and are orthogonal to the normal vector, you just need to plug in the definition for a point on the viewing ray in order to determine which point on the viewing ray defines such an orthogonal ray.

    The problem will be if your viewing ray is in the plane. In this case, the viewing ray and the normal ray will be orthogonal so their dot product will be 0 and the you’ll get a divide-by-0 exception. You’ll need to check for that in advance: if the dot product of the viewing vector and the normal is 0, then it means the viewing ray is parallel to the plane so there either is no intersection, or there are an infinite number of intersections (the ray is inside the plane). Either way, I think for ray tracing you would generally just say there’s no point of intersection (i.e., nothing to render), because in the latter case, you’re looking at a two-dimensional flat surface exactly head on, so you wouldn’t see anything.

    I don’t see any reason you need to specially handle “close to 0”. Either the ray is parallel to the plane and there’s nothing to render, or it’s not and it intersects the plane at exactly one point. You’ll get into floating point rounding errors eventually, but this is just a small source of error in your rendering which is only an approximation of the scene anyway. As long as you keep your dimensions reasonably large, the floating point errors should be insubstantial.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java HashMap of type <MyType,Double> . The MyType class has two
I have two classes. One class has a variable Image plane = null; in
I have a class that inherits from CCNode. This class has two CCSprites. When
I have one instance of Class A. It has two members, Object A and
I have a class that uses a CardLayout which has two cards that have
The UserProfile has a one-to-one to 'User' and a many-to-one to Place class UserProfile(
I am having a little design crisis, I am making a Plane class, which
I'm creating an air traffic control system. I have a class called plane that
Having such class can I instatiate it in place? abstract class Mammal { public
My application has a requirement that we need to encrypt index fields. Right now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.