Function opensn::CheckPlaneLineIntersect
Defined in File raytracer.h
Function Documentation
-
bool opensn::CheckPlaneLineIntersect(const Vector3 &plane_normal, const Vector3 &plane_point, const Vector3 &line_point_0, const Vector3 &line_point_1, Vector3 &intersection_point, std::pair<double, double> *weights = nullptr)
Computes the intersection of a line with a plane.
The first step of this algorithm is to compute v0 and v1. These are vectors from the plane’s reference point to each of the line-points, respectively. We then take the dot-products of these vectors with the plane normal. We then say that the vectors have a positive sense if the dot-product is positive and a negative sense if the dot-product is negative. If the senses are not equal then the line intersects the plane.
Since the face normal is a normalized vector the dot-product of v0 or v1 will give the projection of the relevant vector along the normal to the plane. We can use this projection to compute a weight associated with each vector. This also then allows us to compute the intersection point.
- Parameters:
plane_normal – The normal associated with the plane
plane_point – The reference point for the plane
line_point_0 – The line’s initial point
line_point_1 – The line’s destination point
intersection_point – The point to be populated with the intersection point
weights – The weights associated with this intersection
- Returns:
Returns true if the line intersects the plane and false otherwise.