Re: ...
- From
- Alexei Ivanov ()
- To
- All ()
- Date
- 2000-02-23T17:06:53Z
- Area
- RU.ALGORITHMS
From: Alexei Ivanov <A.Ivanov@tu-bs.de>
Hi,
Victor Anikeev wrote:
> AI> A(x1,y1), B(x2,y2), C(x3,y3) P(x,y)
> AI> xx1 = x1+x2-x-x;
> AI> yy1 = y1+y2-y-y;
> AI> xx2 = x3-x;
> AI> yy2 = y3-y;
> AI> if((abs(xx1+xx2) <= (abs(xx1) + abs(xx2))) && (abs(yy1+yy2) <=
> AI> (abs(yy1) + abs(yy2)))) { puts("There is a inner point of the
> AI> triangle."); // the bounds include (=) } else { puts("There is not
> AI> inner point of the triangle."); }
>
> Можно переделать для трехмерного случая?
Yes.
I make some mistakes. Right version will be not so easy. :-)
2 dimensional version.
1. A(x1',y1'), B(x2',y2'), C(x3',y3') P(x,y)
2. A(x1 = x1' - x, y1 = y1' - y),
B(x2 = x2' - x, y2 = y2' - y),
C(x3 = x3' - x, y3 = y3' - y)
P(0,0)
3. c1 = (x1*x2 + y1*y2)/sqrt((x1*x1 + y1*y1)*(x2*x2 + y2*y2));
c2 = (x2*x3 + y2*y3)/sqrt((x2*x2 + y2*y2)*(x3*x3 + y3*y3));
c3 = (x3*x1 + y3*y1)/sqrt((x3*x3 + y3*y3)*(x1*x1 + y1*y1));
4. if(c1 > c2) { cc1 = c1; cc2 = c2;}
else { cc1 = c2; cc2 = c1;}
if(c3 > cc2) cc2 = c3;
5. if((cc1 + cc2) <= 0) puts("There is a inner point of the triangle.");
else puts("There is not inner point of the triangle.");
3 dimensional version.
1. A(x1',y1',z1'), B(x2',y2',z2'), C(x3',y3',z3') P(x,y,z)
2. A(x1 = x1' - x, y1 = y1' - y, z1 = z1' - z),
B(x2 = x2' - x, y2 = y2' - y, z2 = z2' - z),
C(x3 = x3' - x, y3 = y3' - y, z3 = z3' - z),
P(0,0,0)
3. determinant || x1 y1 z1 ||
|| x2 y2 z2 ||
|| x3 y3 z3 ||
if(determinant != 0) puts("There is not inner point of the triangle.");
4. c1 = (x1*x2 + y1*y2 + z1*z2)/sqrt((x1*x1 + y1*y1 + z1*z1)*(x2*x2 + y2*y2 + z2*z2));
c2 = (x2*x3 + y2*y3 + z2*z3)/sqrt((x2*x2 + y2*y2 + z2*z2)*(x3*x3 + y3*y3 + z3*z3));
c3 = (x3*x1 + y3*y1 + z3*z1)/sqrt((x3*x3 + y3*y3 + z3*z3)*(x1*x1 + y1*y1 + z1*z1));
4. if(c1 > c2) { cc1 = c1; cc2 = c2;}
else { cc1 = c2; cc2 = c1;}
if(c3 > cc2) cc2 = c3;
5. if((cc1 + cc2) <= 0) puts("There is a inner point of the triangle.");
else puts("There is not inner point of the triangle.");
--
Alexey Ivanov, Braunschweig-Germany
--- ifmail v.2.15dev4
* Origin: Institut fuer Halbleitertechnik (2:5020/400)