I need someone for a very small job, I have to find the point resulting of two segments crossing in a 3D space. I found several method on the net and tried this one: D3DXVECTOR3 AB=B-A;
D3DXVECTOR3 CD=D-C;
D3DXVec3Normalize(&AB,&AB);
D3DXVec3Normalize(&CD,&CD);
if (D3DXVec3Dot(&AB,&CD)<0.01f)
continue;
float dx,dy,dz,c,d;
dx=fabs(AB.x)+fabs(CD.x);
dy=fabs(AB.y)+fabs(CD.y);
dz=fabs(AB.z)+fabs(CD.z);
if (dx>dz && dy>dz) //plan dx/dy
{
c=(AB.y*A.x+AB.x*C.y-AB.x*A.y-AB.y*C.x)/(AB.y*CD.x-AB.x*CD.y);
d=(CD.y*C.x+CD.x*A.y-CD.x*C.y-CD.y*A.x)/(CD.y*AB.x-CD.x*AB.y);
}
else if (dx>dy && dz>dy) //plan dx/dz
{
c=(AB.z*A.x+AB.x*C.z-AB.x*A.z-AB.z*C.x)/(AB.z*CD.x-AB.x*CD.z);
d=(CD.z*C.x+CD.x*A.z-CD.x*C.z-CD.z*A.x)/(CD.z*AB.x-CD.x*AB.z);
}
else if (dy>dx && dz>dx) //plan dy/dz
{
c=(AB.z*A.y+AB.y*C.z-AB.y*A.z-AB.z*C.y)/(AB.z*CD.y-AB.y*CD.z);
d=(CD.z*C.y+CD.y*A.z-CD.y*C.z-CD.z*A.y)/(CD.z*AB.y-CD.y*AB.z);
}
//CX[nCX++] = ;
V0=A+AB*c;
V1=C+CD*d;
V=V0-V1;
if (D3DXVec3Length(&V)>PRECISION)
continue;
CX[nCX++]=V1;
And it work but with a bad precision, with segments of 10 units long I have to set the PRECISION variable to 1 and the point is visualy not one the segments, just near.
Then what I need is another method to find that point knowing segments are sometimes not perfectly on the same plane (but almost).
I need the job done quickly (within 24hours max)
Hello Sir...
I have a very good experience in algorithms, geometry and math.
Please contact me for details ASAP.
Looking forward to work for you Sir.
Best Regards.