Feature: Add a way to set the polygon length from the star-toolbar
Had a great time adding this new feature:
Inspired by the code written by @doctormo for adding a way to set the polygon length from the star-toolbar, I updated that code to output the correct polygon length and fix the transformation issues.
Logic for pointy star:
For every vertex
, compute two distances i.e outer to inner vertex
distance and inner to next outer vertex
distance (covering a whole spoke of the star).
After the above computation, we have total perimeter with us. Let's divide this with total number of sides (i.e 2*n) so that we get our average side length.
Logic for flattened polygon:
Compute total perimeter of the polygon by finding distance between consecutive vertices. Let's divide this with total number of sides (i.e n) so that we get our average polygon length.
Just to add on: There will be some minor precision inaccuracies(very very small) in length calculation as we are doing addition and division with floating point numbers.
Here is the video featuring how the new feature will look like: After_Fix
Merge request reports
Activity
- Resolved by Aman Gupta
Excelent work.
There is one error from the video and that is the center of transformation which is not correct. It should be the center of the star object, and as you change the length it should contract from all sides equally instead of shifting right and left.
- Resolved by Aman Gupta
- Resolved by Aman Gupta
- Resolved by Aman Gupta
I started on a code review but stopped when I realised that the solution you're using involves storing an attribute in the polygon object. Since this is a red flag, I'll stop the review here and we can talk more about if this is needed or if it can be re-coded a different way.
requested review from @doctormo
- Resolved by Aman Gupta
Maybe you shouldn't worry about object properties dialog. It underwent some significant changes in the separate branch I've been working on. I think it will be easy to enhance it later to cover this new entry. All I need is functions to call to read a length and to change it, so I can reuse the logic.
added 1 commit
- 70419515 - Fixed transformation issues and reverted changes of dialog
- Resolved by Aman Gupta
@doctormo please have a review. I have done the following changes:
- Added setSideLength() that also resolves the transformation issues.
- Revert back all the object properties dialog changes as @mkov is doing significant changes related to it in a separate branch.
- Removed the dependency on storing an attribute in polygon object as it was a red flag.
- Uploaded new video for reference.
Edited by Aman Gupta
- Resolved by Aman Gupta
I think label "Length" is going to be ambiguous. Maybe "Side" for a polygon would be better? Not sure what to use for a star.
Is there a reason why this new length value is remembered in preferences?
- Resolved by Aman Gupta
I have changed the label from 'Length' to 'Edge'.
If anything else is yet to be done then please let me know.Edited by Aman Gupta
started a merge train