PDA

Click to See Complete Forum and Search --> : Planes, Trains, and Triangles


Zaei
May 25th, 2001, 04:27 PM
Little bit of subject line humor there =).

Ok, here I go with my question. I have a lot of 3d points, which i can form into a plane. I can also find out where a ray intersects the plane. What i want to do is feed a function with 3 points at a time (a triangle), and know if the point of intersection on the plane is within that triangle.

::strikes with bad ASCII art::
/ <-Ray
---------------------------------/----
\ / \
\ / \ <-Plane
\ / \
\ +---+/ \
\ \ /*\ \
\ +---+ <-Square \
\ \
----------------------------------------
*= instersect point.


Hope that makes sense... If anyone can help me out, I would be grateful =).

Z.

[edit]
instersect point? i cannot spell =).

Illuminator
May 25th, 2001, 05:41 PM
If you can find the point in the plane that the ray intersects in your should be able to find a square made up of four adjcent points that it passes through.

assuming all of you triangles that make up the plane are aligned the same way


P1 -------
\ /\
\ / \
\ / \
------- P2


Two of you triangle vertices will always be the same, the ones that determine the diagonal. Then to find the third vetice you find which of the points P1 or P2 is closer to the intersection point.

Zaei
May 25th, 2001, 10:37 PM
What is a formula to determine if a point is within a triangle? Doesnt matter if its 2D or 3D, either will work.

Z.

Zaei
May 26th, 2001, 11:49 AM
Woo hoo. I figured this one out =). If anyone ever needs this for anything, to find if a point lies within a triangle on a plane, first make vectors running from the point you want to test to each point in the triangle, then you add the angles between each vector (DotProduct). If the total equals (is within say, 0.01 of) 2Pi, the point is withing the triangle.

Z.

kapedu
Oct 28th, 2005, 03:50 AM
This solution is simple enough for me. You may try it.
If the triangle is A B C and the point is P, check if the area of triangle ABC is equal (difference 0.00001) same as sum of areas of triangles made by either side of triangle and point P

area(ABC) - [area(ABP)+area(ACP)+area(BCP)] < 0.00001

You may calculate area of triangle using Heron Formula:
http://mathworld.wolfram.com/HeronsFormula.html

I need a VB code to determine intersection point of line and a plane (triangle). Does anyone have it?