How to tell if a position is within a cylinder

Hello,

I have cylinder made to look like a cone pointing out to space, and many entities orbiting the earth, which sometimes intersect with this cone. Here is a sandcastle example: Cesium Sandcastle

I am trying to find a way that I can compute whether an orbiting entity is intersects with the cone, and maybe just doing something simple like logging the id of the entity when that happens.

Any ideas on the best way to approach this? There are not many methods surrounding the cylinder objects, and I am not quite sure the best way to get an approximation of the space which a cylinder occupies. The best idea I can think of is calculating the volume of the cylinder, and then converting that to a collection of coordinates, but I wonder if that is not the best approach due to the granularity of evaulations that would provide you.

Thank you for any help you can offer

Maybe we can turn it into a mathematical problem,

input: cone Center, length,topRadius,bottomRadius,
output: bool(if a position is within a cylinder)

step:

  1. get position of P1,P2
  2. Calculate the vertical foot(P4) of P3 to line(P1,P2)
  3. Calculate the radius(length1) of P4
  4. Calculate the length2(P3,P4)
  5. compare length1,length2

Hi Fav,

Thanks for the advice! This seems like a good solution, although I am not sure how to find the radius of the cone at a given location within the cylinder (P4). If I write a sandcastle demo completing all other steps, would you be so kind as to fill in that bit of logic for me? Or would you be able to point me to some documentation / example of how I might acheive this step?

Thanks again for the help!