Isuue in computing shortest distance between the cone and sphere
Posted: Tue Aug 30, 2022 5:12 am
Hi,
I am trying to find the shortest distance between a cone and a sphere in C++. The information on the cone is as follows. The centre of the base circle of the cone is at {0, 0, -1}, and the vertex of the cone is at {0,0,0}. The radius and height of the cone are 0.58454 and 1, respectively. Similarly, the radius of the sphere is 0.1 centred at {0.9, 0.9, 0.1}. The shortest distance is computed to be 1.3016, and the foot of the perpendicular is found to be inside the cone instead of on the cone. The correct shortest distance is 1.1493.
I am attaching the code here.
Please help me to fix the code. Thanks a lot!
I am trying to find the shortest distance between a cone and a sphere in C++. The information on the cone is as follows. The centre of the base circle of the cone is at {0, 0, -1}, and the vertex of the cone is at {0,0,0}. The radius and height of the cone are 0.58454 and 1, respectively. Similarly, the radius of the sphere is 0.1 centred at {0.9, 0.9, 0.1}. The shortest distance is computed to be 1.3016, and the foot of the perpendicular is found to be inside the cone instead of on the cone. The correct shortest distance is 1.1493.
I am attaching the code here.
Please help me to fix the code. Thanks a lot!