cl-vectors
cl-vectors copied to clipboard
bug in discrete-bezier-curve
There is a bug in defun discrete-bezier-curve
.
Sometimes it calls (atan 0.0 0.0)
, spec [1] specifies that:
If both are supplied, number2 can be zero provided number1 is not zero. The problem is fixed using a safe version of atan:
(safe-atan (x y)
(if (and (= x 0) (= y 0))
0
(atan x y)))
I'm not sure if "0" is the correct answer.
Regards, Alessandro
[1] http://clhs.lisp.se/Body/f_asin_.htm
The problem is that two consecutive points must be disjoint.
Actually there should be no attempt to compute atan
in the first place for these points.
The correct solution, I think, is to either filter out these points (either at the user responsibility, and maybe here in the code as a first pass before subdividing) or simply to reject such paths.
However, this could also happen because of the subdivision itself, but it would surprise me in this case.
(Sorry for the late reply.)