Okay I'm just going to explain it because I don't have any formulas/code for this new version of what I want to do.
The task is testing if a point in 3D space lies within an object (defined by a point array and index array to make triangles). So I'd read about collision detection before using planes to test if it's in front or behind the plane and for convex objects all triangles will need to be in front, blah, blah.
But I didn't understand any of it or any of the maths involved so struggled with it myself and basically came up with my own methods of achieving this. Currently I stand at sending the 3 points on the current plane in testing, and the test point(s) into a function which transforms the plane and points onto it's own (X,Y,Z) mapping system and simply testing if Z > 0 for being inside the shape.
Rotating the plane takes time and power though so just today I spent like 10 minutes thinking and came up with testing the angle between 2 lines, the normal of the plane, and any of the 3 plane points to the point in testing. My theory is that if the angle < (pi/2) then point is inside shape.
I suppose I've pointlessly rambled for quite a while but I wanted to ask if this new method is sound... And also to ask if anyone know's how I'd calculate the normal to the plane. I was worried that a cross product of 2 of the planes lines would create a normal in the opposite direction because I don't fully understand how it works mathematically.
Since normal vectors are directional, it is necessary to do all calculations in the same manner. For instance, if a triangle's vertices are given to the formula in a counter clockwise fashion rather than clockwise, the resulting normal vector will point in the opposite direction.
testing the angle between 2 lines, the normal of the plane, and any of the 3 plane points to the point in testing. My theory is that if the angle < (pi/2) then point is inside shape.
Can you explain this a little clearer, I don't understand what you mean.
@htirwin
Once I have the direction vector for the normal of the plane (position shouldn't matter) I'll find the angle between this normal, and the direction vector from one of the 3 points to the point in testing (shouldn't matter which point as they should all be <90 if the test point is behind plane)
Here I've redone my sketches on the PC, hopefully this should clear up what I'm wanting to do... [link removed]
I've redone my sketches on the PC (very rough) but hopefully it should clear up what I'm wanting to do. [link removed]
ABC is a plane of 3 points, D is the point to be tested whether it's in front or behind the plane, n is the normal to ABC.
I should be able to test for the angle between (n, AD) || (n, BD) || (n CD)
If the angle in testing (D) is in front of the plane then clearly AD, BD and CD all point in the opposite direction to n, so a test for the angle should return greater than half pi (or 90 degrees for n00bs XD ).
I'm testing for the angle using the dot product over the product of the magnitudes of the 2 vectors, which get's cos(a), then simply inverse it.
EDIT: Whoops, Sorry for the double post, it didn't show up for a long while some reason.
Okay I think I've covered this enough to ensure that I can get things pointing in the right directions. Suppose I'll find out because it'll either sometimes work (when objects are colliding) or never work (cos it's broken) =D