LibreCAD / LibreCAD_3

LibreCAD 3 is a next generation 2D CAD application written to be modular, with a core independent from GUI toolkits. Scripting is possible with Lua.
http://librecad.org
Other
311 stars 103 forks source link

Dragging arc is crashing program #329

Closed rupakbajgain closed 4 years ago

rupakbajgain commented 4 years ago

Use drag points in arc throws const char *

rupakbajgain commented 4 years ago

It is happening only for entity created using builder but it does not happen i create by spliting circle, Throws error Points describe a volume, not a area.

Jedi18 commented 4 years ago

The issue seems to be in the setDragPoints function in arc.cpp in primitives. The new entity is not created properly (has inf and nan as the values), which causes the crash later on. https://github.com/LibreCAD/LibreCAD_3/blob/1dc4b410ba147f0a3c1c12af102e197f5200baa9/lckernel/cad/primitive/arc.cpp#L176

Jedi18 commented 4 years ago

In createArcBulge function

    auto isCCW = bulge>0.;
    auto delta = atan(bulge) * 4.0;

    auto middle = p1.mid(p2);
    auto dist = p1.distanceTo(p2)/2.0;

    auto radius = std::abs(dist / std::sin(delta/2.0));

Bulge is 0, so delta is 0 since tan(0)=0, this leads to sin(0)=0, which results in radius getting infinity as it's value.

Jedi18 commented 4 years ago

We are passing in CCW() instead of bulge() as the third parameter to createArcBulge, which is the bug here.

rupakbajgain commented 4 years ago

thanks @Jedi18 , i fixed it, have you done it too? the bulge function is also not working properly.

rupakbajgain commented 4 years ago

Ok, i will remove that from my code to not create conflict.

Jedi18 commented 4 years ago

That wont be a problem, it wont create a conflict if it's the same changes to that file.

Jedi18 commented 4 years ago

@feragon This issue can be closed, it was fixed in #333