Line vs Plane: Difference between revisions
Updated and revisited the page
Nikitaivanov (talk | contribs) (Created page with "Finds the point at which a line intersects a plane. /uploads/Line vs Plane.png Inputs: * Line From: Line's starting position * Line To: Line's end position * Plane Point: A position in the plane (defaults to 0,0,0 if unwired) * Plane Normal: A vector perpendicular to the plane (i.e. the direction the plane is pointing at, or the angle of the plane) Outputs: * Intersection: The point where the line intersects the plane (or nan if there...") |
(Updated and revisited the page) |
||
Line 1: | Line 1: | ||
{{Block | |||
|image=Line vs Plane.png | |||
|type=s | |||
|folder=math | |||
|input1={{Port|v|Line From}} | |||
|input2={{Port|v|Line To}} | |||
|input3={{Port|v|Plane Point}} | |||
|input4={{Port|v|Plane Normal}} | |||
|output1={{Port|v|Intersection}} | |||
}} | |||
Finds the point at which a line intersects a plane. | Finds the point at which a line intersects a plane. | ||
== Notes == | == Notes == | ||
* It's a line, not a line segment, so the intersection will be found even if it's not in-between the line's from/to positions. | * It's a line, not a line segment, so the intersection will be found even if it's not in-between the line's from/to positions. | ||
* Plane Point is a position on the plane. | |||
: Plane Normal is a vector perpendicular to the plane (i.e. the direction the plane is pointing at, or the angle of the plane). | |||
* The output is NaN if the line does not intersect the plane. | |||
: This happens if the line is parallel to the plane or plane normal is (0,0,0) | |||
== Example == | == Example == | ||
Line 20: | Line 24: | ||
A common use case for Line vs Plane is to find the world coordinate of the user's finger: | A common use case for Line vs Plane is to find the world coordinate of the user's finger: | ||
{{Image|Line vs plane example1.png|Place a block on the floor where the player touches}} | |||
The finger touches a 2D screen, but there's a whole bunch 3D points along a line | The finger touches a 2D screen, but there's a whole bunch 3D points along a line ''into'' the scene, which are all at that 2D coordinate. | ||
So the above script first uses [[Screen To World]] to get two points on that line, and then Line vs Plane to pick out the ''one'' position that lies on the floor plane (point 0,0,0 and normal 0,1,0). | |||
As a result, the Wood block will move to the finger! | |||
[[Category:Blocks]] | [[Category:Blocks]] |