Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public override Intersection Intersect(Ray ray)
- {
- Intersection result = new Intersection();
- result.Thing = this;
- result.Ray = ray;
- // Find t.
- double t = - (Vector3.Dot(Norm,ray.Start) + Offset) / (Vector3.Dot(Norm, ray.Dir));
- result.Dist = t;
- // 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;
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement