[QGIS-Developer] QgsTriangle.angles() return wrong values ?

Loïc Bartoletti lbartoletti at tuxfamily.org
Sun Dec 5 02:34:35 PST 2021


Salut Nicolas,

I think I added this very strange hack when I ported my old python code 
(with other geometry functions that were not or slightly different from 
QgsGeometryUtils). However, I have no memory of why.

You can open an issue and assign it to me, I will try to find that old 
code and fix it. We can discuss this later this week.

Loïc

Le 04/12/2021 à 20:32, Nicolas Godet a écrit :
> A workaround would be to add 90° to the lowest value if the sum is 
> lower than 180°.
> https://github.com/Artelia/Mesh_tools/commit/5d40a8807f1c8264ccff51b365ce8d58ac333011
>
> That’s not ideal, especially in case of very flat triangle…
>
>
>> Le 4 déc. 2021 à 19:52, Nicolas Godet <nicolas.godet at outlook.fr> a 
>> écrit :
>>
>> 
>> Seems an issue more than a feature to me.
>> At least, the doc should reflect this behavior.
>>
>> Should I open a issue on GH ?
>>
>>> Le 4 déc. 2021 à 19:45, Andrea Giudiceandrea <andreaerdna at libero.it> 
>>> a écrit :
>>>
>>>  Il 04/12/2021 13:52, Nicolas Godet ha scritto:
>>>> >>> triangle.angles()
>>>> [0.7119509950830287, 0.0008857138004074727, 0.85795961791146]
>>>> >>> [math.degrees(a) for a in triangle.angles()]
>>>> [40.79178723839677, 0.05074766261984076, 49.157465098983366]
>>>>
>>>> We should have a near-90° angle, which we don't...
>>>
>>> Hi Nicolas,
>>> it seems the QgsTriangle::angles() fails to correctly return the 
>>> value of angles greater than 90° deg. (Pi/2 rad.).
>>>
>>> Actually the function code strangely subtract 90 to such angles:
>>>
>>> https://github.com/qgis/QGIS/blob/dd0cd13a00998bc153c0b6519ea75038b57a6df5/src/core/geometry/qgstriangle.cpp#L397-L403
>>>   angles.append( ( a1 > M_PI_2 ? a1 - M_PI_2 : a1 ) );
>>>   angles.append( ( a2 > M_PI_2 ? a2 - M_PI_2 : a2 ) );
>>>   angles.append( ( a3 > M_PI_2 ? a3 - M_PI_2 : a3 ) );
>>>
>>> In fact, the correct value of the angle is 90.05074766261984076 deg. 
>>> and not 0.05074766261984076.
>>>
>>> Regards.
>>>
>>> Andrea
>>> _______________________________________________
>>> QGIS-Developer mailing list
>>> QGIS-Developer at lists.osgeo.org
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info:https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20211205/e1658ebb/attachment.html>


More information about the QGIS-Developer mailing list