def _points_for_axis_and_size(axis, radius):
        # calculate a point on the edge of the circular side of the cylinder
        # (p3). The norm between p1 and p3 is then the radius.
        # find point 3 perpendicular to p1, p2 at distance p3 -p1

        p1, p2 = axis

        # define axis as vector
        v = p2 - p1

        # rule out both points are equal
        if geometry.norm(v) == 0:
            raise ValueError('Axis should be defined by two unique points')

        # random point that does not lie on the axis
        ok = False
        while not ok:
            q = np.random.rand(3)
            if geometry.dot(q, v) != 0:
                ok = True

        # vector from p1 to q
        w = q - p1

        # defines a plane on which the axis lies
        n = geometry.normalize(geometry.cross(v, w))

        p3 = p1 + (n * radius)

        return p1, p2, p3
    def _make_sitk_mask(self):
        p1, p2, p3 = self.coordinates_world
        radius = geometry.norm(p3 - p1)
        axis = (p1, p2)

        self.logger.debug('making mask at {0} with radius {1}'.format(
            axis, radius))
        mask = geometry.sitk_cylinder(self.image, axis=axis, radius=radius)

        return mask
    def _make_sitk_mask(self):
        p1, p2 = self.coordinates_world

        center = 0.5 * (p1 + p2)
        radius = geometry.norm(p2 - p1) / 2

        mask = geometry.sitk_sphere(image=self.image,
                                    center=center,
                                    radius=radius)
        return mask
    def _make_sitk_mask(self):

        c = self.coordinates_world
        radius = 0.5 * geometry.norm(c[1] - c[0])
        center = 0.5 * (c[0] + c[1])

        self.logger.debug('Making mask at point: {0} with radius: {1}'.format(
            center, radius))

        mask = geometry.sitk_circle(self.image, center=center, radius=radius)
        return mask
 def radius(self):
     p1, p2 = self.coordinates_phantom
     return geometry.norm(p2 - p1) / 2
 def radius(self):
     """ Get/Set the radius of the cylinder """
     p1, _, p3 = self.coordinates_phantom
     return geometry.norm(p3 - p1)