I am using GNU Octave with the package matgeom-1.2.2
If I use the function “intersectLineCircle(lines,circles)” with multiple lines and circles I find an error message
when in the array of lines one line has intersections with its corresponding circle and the subsequent line doesn’t.
I use circles = [ 0 0 1 ; 0 0 1]
and lines = [ 0 0 1 0; 2 2 1 0]
then I get the error:
error: reshape: can’t reshape 4x1 array to 2x2x2 array
Inspection of the function intersectLineCircle.m in the package gives me the information that the problem likely
is in the conditional part:
if nCircles == 1 points = [... line(1:2) + u(:,1) .* line(3:4); ... line(1:2) + u(:,2) .* line(3:4)]; else tmp = [... line(valid, 1:2) + u(:,1) .* line(valid, 3:4) ... line(valid, 1:2) + u(:,2) .* line(valid, 3:4)].'; points(:, :, valid) = permute(reshape(tmp, [2, 2, nCircles]), [2 1 3]); end
And specifically in the “else” part.
I think what goes wrong is that the tmp matrix is forme of valid lines, lines with intersection determined by the boolean “valid” and
that it only finds one valid line, thus, tmp becomes a 4 x 1 matrix, whereas the matrix [ 2 2 nCircles] is a 2x2x2 matrix.
With two lines with intersections it works ok, then a 4 x 2 matrix is formed which can be reshaped to a 2x2x2 matrix …
Also with no lines with intersections it works …
it could work if in the reshape part the number of circles is reduced to that number of circles with intersections,
but I am not 100% sure if this is correct.
Thank for your message!
I have merge upstream into our fork of matgeom. Could you check if the problem is still in that version?
I tested and it seems it is still there. So you will have to report upstream Issues · mattools/matGeom · GitHub
To install the development package, you need to download the sources from here
cd octave_pkg make dist
This will create an installable
tar.gz file in the folder
Then from the octave prompt you can install the package as usual
pkg install <tar.gz>
I will try to fix this small issue, but please report the bug upstream, I will then make a merge request there.