この曲線はこれらの点で構成されています。赤い線が曲線と交差しているかどうかを知りたいです。赤い線は PointA と PointB で構成されています。私に何ができる ?
1 に答える
0
struct pos
{
double x ;
double y ;
};
struct line
{
pos st ;
pos end ;
};
int n ;
double Multiply(pos p1, pos p2, pos p0)
{
return ( (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y) );
}
bool iscross(line L1, line L2)
{
return( (max(L1.st.x, L1.end.x) >= min(L2.st.x, L2.end.x)) &&
(max(L2.st.x, L2.end.x) >= min(L1.st.x, L1.end.x)) &&
(max(L1.st.y, L1.end.y) >= min(L2.st.y, L2.end.y)) &&
(max(L2.st.y, L2.end.y) >= min(L1.st.y, L1.end.y)) &&
(Multiply(L2.st, L1.end, L1.st) * Multiply(L1.end, L2.end, L1.st) >= 0) &&
(Multiply(L1.st, L2.end, L2.st) * Multiply(L2.end, L1.end, L2.st) >= 0)
);
}
于 2013-01-22T08:56:12.613 に答える