Author Topic: math smart guys help me out: finding if point is inside polyhedron  (Read 877 times)

im not good at math so i need help.

i got a polyhedron (probably a circle, or a cone or something) and i want to check if a 3d point is inside that shape.


how do i find if a line intersects a 3d face? im going to use that and see if a vector cast from the 3d point intersects a certain number of faces of the polyhedron, to check if its inside. but i dont know how to calculate if a line intersects a 3d face.

some smart math people help me. please explain it in math formulas and expressions and stuff and give variables descriptive names other than A or B

a line/vector intersects a 3D face if there's a point or more that the two meet, AKA the coordinates are equal to one another

I'm guessing the polyhedron or whatever is oriented at the origin?

a line/vector intersects a 3D face if there's a point or more that the two meet, AKA the coordinates are equal to one another
that much is understood. i need to find the point of intersection given the line and the face

I'm guessing the polyhedron or whatever is oriented at the origin?
no.

The best solution for this depends on what kind of information you're given. Are you just given the shape's number of sides and dimensions, or a function for each plane that makes up the shape? Post the original question this comes from.

If you want to know if/where a line intersects a 3D face, set their equations equal to each other and then simplify. Alternatively, do it using parametric equations.
« Last Edit: March 31, 2018, 01:57:03 PM by SeventhSandwich »

The information you're given: an equation for the line, and a set of normals, each with 3 3d points. The normals don't have an equation, they're just sets of data...

i cant post an original question because there isn't any. its for a programming project, im making bootleg raycasting. there's two parts of the problem, finding the point of intersection between a line and a shape. once that's figured out i can find out if the point is also inside a shape

Normals are an equation sorta - they're the vector equation that points out perpendicular to the surface of the plane. I assume they're giving you the x,y,z components in the 'sets of data'.

Here's basically what you're gonna want to do: take your line and parameterize it. So if your line goes from (1,2,3) to (8,4,9), the equation for your line is (1+7t,2+2t,3+6t), where t is 0 to 1. This will make it significantly easier to solve the rest of the problem. This might have already been done depending on what 'equation for the line' you have.

Then take your normals and the 3d points they come with and solve for the equation of your plane. Basically the normals tell you everything about the slope of your plane in three different axes, but the 3d points tell you where to actually put that plane. If your normal vectors are given as (Nx, Ny, Nz) and your 3d points are (Px, Py, Pz), the formula for your plane is going to be:

(X - Px)Nx + (Y-Py)Ny + (Z-Pz)Nz = 0

Rearrange it so that all the constants are on the right side.

Then simply take whatever plane equation you have, maybe something like X + Y + Z = 3, and substitute in your line's parameters, which might be something like X = 2t, Y = 2 + 3t, Z = 4t, and then solve for t. So in this case, that's:
(2t) + (2+3t) + (4t) = 3
9t + 2 = 3
9t = 1
t = 1/9, and you plug that back into your parametric equation to get (2/9,2+3/9,4/9), which is the point where that line intersects the plane.

On second look, you mentioned having 'three points in 3D' per face normal, right? I imagine this means you're dealing with faces made out of trigs rather than quads.

That complicates things a little bit because it means you're going to need to limit what kinds of intersections are 'allowed' to happen. Basically, solving for the intersection of a plane and a line will tell you where /some/ intersection happens, but you need to know whether it happens on the small triangle where the plane actually exists.

I found this resource that explains how to do it:
https://math.stackexchange.com/questions/476608/how-to-check-if-point-is-within-a-rectangle-on-a-plane-in-3d-space

ok that makes sense ill check it out

How the forget y'all do this stuff; I have to use my fingers to subtract 14-8

How the forget y'all do this stuff; I have to use my fingers to subtract 14-8

smh your name