# Inside / Outside Detector

So I was toying around with the pose reader I tried to use on the baby and wondered what other kinds of shapes would work.

A sphere is just a distance measurement system.

A cone is an angle measurement.

So I kept going until I got to a cylinder. Now at first I thought I could create an nurbs curve along the central axis of the cylinder and then measure the distance to the nearest point on the curve, but that would actually get make the reader pill-shaped.

So instead I found the nearest point on the surface, then took the dot product of the normals of the surface at that point, and the vector from that point to the point being tested. This returns a negative number if the second vector is pointing in the "opposite" direction from the normal, meaning the test point is inside the nurbs surface.

This system works for any closed surface with a continuous set of normals.

In cases where the surface is not closed it acts as though the tangents at the edge of the surface extended out forever so it also get's the desired results for planes, cones, and of course cylinders.

I'm not sure where to apply this yet but it might be useful for simplified collision, like on a cylindrical skirt.

Tags: