A method of safeguarding a machine, in particular a robot arm, in which objects are recognized in a work zone (20, 22) of the machine and in which a check is made for a recognized object t whether its presence is permitted and the machine is otherwise switched into a risk-reducing or safe state, wherein objects are recognized in that at least one contactless distance sensor that is moved along with the machine and that has at least one distance measurement beam measures an actual measured value for a distance from the work zone (20, 22) or from an object arranged there; a first virtual distance measurement beam that simulates the distance measurement beam is formed from a pose of the distance sensor, the site of incidence of the first virtual distance measurement beam on a surface model of the work zone (20, 22) is determined, and a first virtual measured value is calculated for the distance; and the actual measured value is compared with the first virtual measured value to decide whether an object is in the distance measurement beam, wherein at least one further virtual distance measurement beam having an offset from the first virtual distance measurement beam is formed, the site of incidence of the at least one further virtual distance measurement beam on the surface model is determined, and at least one further virtual measured value is calculated for the distance; characterized in that a comparison is made whether the actual measured value is compatible with the virtual measured values, is in particular the same as at least one of the virtual measured values except for a tolerance; and in that an object is recognized in the distance measurement beam if the actual measured value is not compatible with the virtual measured values. wherein objects are recognized in that at least one contactless distance sensor that is moved along with the machine and that has at least one distance measurement beam measures an actual measured value for a distance from the work zone (20, 22) or from an object arranged there; a first virtual distance measurement beam that simulates the distance measurement beam is formed from a pose of the distance sensor, the site of incidence of the first virtual distance measurement beam on a surface model of the work zone (20, 22) is determined, and a first virtual measured value is calculated for the distance; and the actual measured value is compared with the first virtual measured value to decide whether an object is in the distance measurement beam, wherein at least one further virtual distance measurement beam having an offset from the first virtual distance measurement beam is formed, the site of incidence of the at least one further virtual distance measurement beam on the surface model is determined, and at least one further virtual measured value is calculated for the distance; characterized in that a comparison is made whether the actual measured value is compatible with the virtual measured values, is in particular the same as at least one of the virtual measured values except for a tolerance; and in that an object is recognized in the distance measurement beam if the actual measured value is not compatible with the virtual measured values.