[Numpy-discussion] floating point arithmetic issue

Guillaume Chérel guillaume.c.cherel@gmail....
Tue Aug 3 09:12:11 CDT 2010


Hi Pauli,

> If your circles are quite small, you probably want to clip the "painting"
> to a box not much larger than a single circle:
>
> # untested, something like below
> def point_to_index(x, y, pad=0):
>    return np.clip(200 * rr / (xmax - xmin) + pad, 0, 200), \
>           np.clip(200 * rr / (ymax - ymin) + pad, 0, 200)

I'm not sure I understand what you're doing with the clip function
here. Could you say what are the two returned arrays supposed to
represent?

Thanks
guillaume

>
> i0, j0 = point_to_index(xx - rr, yy - rr, pad=-2)
> i1, j1 = point_to_index(xx + rr, yy + rr, pad=2)
>
> box = np.index_exp[i0:j0,i1:j1]
> mask[box] |= (grid_x[box] - xx)**2 + (grid_y[box] - yy)**2 < rr**2
> # same as: mask[i0:j0,i1:j1] |= (grid_x[i0:j0,i1:j1] ...
>
> --
> Pauli Virtanen
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list