|
-
Aug 21st, 2004, 05:16 PM
#1
Thread Starter
Lively Member
intersection [RESOLVED, tnx]
working in space (3-d)
i have a line (a vector; v=[vx,vy,vz]) and a triangle (three vectors to define three distinct points; v1=[v1x,v1y,v1z],v2=[v2x,v2y,v2z],v3=[v3x,v3y,v3z]) and i need to determine whether there is an intersection between them or not...
chalanging, not?
Last edited by Doddddy; Aug 28th, 2004 at 07:26 AM.
'nothin last forever even cold november rain
-
Aug 23rd, 2004, 06:50 AM
#2
-
Aug 23rd, 2004, 09:37 AM
#3
Re: ok
Originally posted by sql_lall
4) Check whether this point is inside the triangle.
Now, point 4 is still the harder bit, but i'm sure there is a simple way to do it....maybe project a line form the point to point A, and see where intersects the side BC...i dunno
Well I would guess you would have to do it the same way as with a sqare, just two times...because if you checks it like a square then it might be on that part of the sqare where not the the triangle is...ie: check 2 vectors, then two "other" vectors in the triangle...not sure tho...
-
Aug 23rd, 2004, 10:17 AM
#4
Thread Starter
Lively Member
well actually i forgot about a point for the line as it crosses the origin. Anyhow tnx for all the help guys, i'll go try it now
'nothin last forever even cold november rain
-
Aug 23rd, 2004, 06:56 PM
#5
To check if a point is inside a triangle ABC, you can check if it is on the same side of AB, BC, CA. IIRC you can do this using dot(AB,AP), so a point P is in the triangle iif:
sign(dot(AB,AP)) = sign(dot(BC,BP)) = sign(dot(CA,CP))
where dot=inner product.
This is just of the top of my head, so I could be completely wrong.
BTW. a quick google gets you this
-
Aug 24th, 2004, 04:59 PM
#6
Thread Starter
Lively Member
thanks twanvl
'nothin last forever even cold november rain
-
Aug 26th, 2004, 08:46 PM
#7
Originally posted by twanvl
To check if a point is inside a triangle ABC, you can check if it is on the same side of AB, BC, CA. IIRC you can do this using dot(AB,AP), so a point P is in the triangle iif:
sign(dot(AB,AP)) = sign(dot(BC,BP)) = sign(dot(CA,CP))
where dot=inner product.
This is just of the top of my head, so I could be completely wrong.
BTW. a quick google gets you this
Completely right.
(old post :P)
a point X is outside of a triangle ABC if
ABX is a clockwise turn OR
BCX is a clockwise turn OR
CAX is a clockwise turn
a point X is inside of a triangle ABC if
ABX is a counter clockwise turn AND
BCX is a counter clockwise turn AND
CAX is a counter clockwise turn
You can determine clockwise/counterclockwise by taking the determinant:
Code:
SomeType Determinant(x1, y1, x2, y2, x3, y3)
{
float determ = (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1);
if (determ >= 0.0)
return CounterClockwise;
else
return Clockwise;
}
so:
Code:
if ( (Determinant(A.x, A.y, B.x, B.y, X.x, X.y) == CW) ||
(Determinant(B.x, B.y, C.x, C.y, X.x, X.y) == CW) ||
(Determinant(C.x, C.y, A.x, A.y, X.x, X.y) == CW))
{
Point X is outside
}
else
{
Point X is inside
}
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Oct 28th, 2005, 03:45 AM
#8
New Member
Re: intersection [RESOLVED, tnx]
Can you do something like this.
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. Does anyone have it?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|