Hi again Doc,
First thing you can do is check the dot product between the normal vectors of both cones' planes. If the dot product is less than zero, the cones cannot intersect. If the dot product is one, then the cones must intersect.
An easier way to think about "nice" 3D shapes (like cones) is to ask if it can project to 2D. In this case, happily the problem can be reduced to 2D.
You've got two "plane normal vectors" that intersect at the origin. This means they are co-planar. If you find this plane (which is straight forward with a couple of cross products), then project the outline of the cones onto this plane, you've reduced the problem down to a question of "does triangle A intersect triangle B".
Or, more simply:
- Get the "apex angle" of each cone/triangle from its normal vector
- Get the angle subtended between the normals of each plane
- If the sum of the apex angles is greater than this subtended angle, your cones/triangles intersect.
So, let's say you know a few things:
1. The unit vectors of each plane's normal vector:
zVec1 = rand(1,3); zVec1 = zVec1/norm(zVec1)
zVec2 = rand(1,3); zVec2 = zVec2/norm(zVec2)
2. The "height" of each triangle (ie, the distance from your cone plane to the global origin:
3. The "width" of each triangle (ie, the radius of each cone):
Now you've got all you need to calculate the apex angle of each cone (ie, between the cone wall and the normal vector):
ang1 = atand(wdth1/ht1)
ang2 = atand(wdth2/ht2)
And the angle between the two plane normal vectors:
twoVecDotProd = dot(zVec1,zVec2)
angBetweenNormVecs = acosd(twoVecDotProd)
Now you've got your result:
conesIntersect = twoVecDotProd>0 && ang1+ang2 >= angBetweenNormVecs
Does that work for you?
Sven.
Best Answer