No it's the intersection point of two vectors. However the vectors do have an origin which might have started the confusion but they are still vectors in 3 space. They could be thought of as lines but I rarely use the term lines anymore. Whether they are 2D or 3D I usually refer to them as vectors since this makes thinking about the various operations that can be performed on them and their geometric interpretations much clearer.
X = cross product
. = dot product
mag = magnitude
v1 = p1 + t1 * d1
v2 = p2 + t2 * d2
t1 = ((p2 - p1) X d2) . (d1 X d2) / mag((d1 X d2) * (d1 X d2))
t2 = ((p2 - p1) X d1) . (d1 X d2) / mag((d1 X d2) * (d1 X d2))
- p1(t1) and p2(t2) are the intersection point or the point closest to the intersection if one exists
- If the vectors are skew (lie in different planes) then the closest point of intersection is p1(t1) and p2(t2). There should be a theoretical distance between these by which to determine if the vectors are 'close enough' to be considered crossing.
- if (d1 X d2) == (0.0f,0.0f,0.0f) then the vectors are parallel or coincident and they do not cross.
So the solution to my problem as to where the vectors cross is:
Code:
D3DXVECTOR3 vecLeftFire = GetLook() * GetRight() + (convergence_offset_vector);
D3DXVECTOR3 vecRightFire = GetLook() * GetRight() + (-convergence_offset_vector);
D3DXVECTOR3 toVecRightFire = vecRightFire - vecLeftFire;
D3DXVECTOR3 vecCrossDirections;
D3DXVec3Cross(&vecCrossDirections,&vecLeftFire,&vecRightFire);
D3DXVECTOR3 vecCrossWithRightFire;
D3DXVec3Cross(&vecCrossWithRightFire,&toVecRightFire,&vecRightFire);
D3DXVECTOR3 vecCrossWithLeftFire;
D3DXVec3Cross(&vecCrossWithLeftFire,&toVecRightFire,&vecLeftFire);
D3DXVECTOR3 vecCrossDirectionsSqrd = vecCrossDirections * vecCrossDirections;
float t1 = D3DXVec3Dot(&vecCrossWithRightFire,&vecCrossDirections) / vecCrossDirectionsSqrd;
float t2 = D3DXVec3Dot(&vecCrossWithLeftFire,&vecCrossDirections) / vecCrossDirectionsSqrd;
D3DXVECTOR3 vecLeftIntersect = GetLaserPos(LEFT_WING) + (t1 * vecLeftFire);
D3DXVECTOR3 vecRightIntersect = GetLaserPos(RIGHT_WING) + (t2 * vecRightFire);
D3DXVECTOR3 toRightIntersect = vecRightIntersect - vecLeftIntersect;
float length = D3DXVec3Length(&toRightIntersect);
if (length <= <some_fudge_distance>)
{
D3DXVECTOR3 vecNormToRightIntersect;
D3DXVec3Normalize(&vecNormToRightIntersect,&vecToRightIntersect);
D3DXVECTOR3 vecIntersectionPoint = vecLeftIntersect + ((length * 0.5f) * vecNormToRightInstersect);
}
...
Now all that is left to do is to pass in vecIntersectionPoint to D3DXVec3Project() to get the screen coordinates and I should be able to place a reticle at the point where the lasers will meet.