is there is a way to check if a given location is inside an object

im starting a trace from a random location so i want to know if the location is inside an object to cancel it .