Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should g/IArea always return absolute value of area? #88

Open
dgtized opened this issue Dec 31, 2021 · 0 comments
Open

Should g/IArea always return absolute value of area? #88

dgtized opened this issue Dec 31, 2021 · 0 comments

Comments

@dgtized
Copy link
Contributor

dgtized commented Dec 31, 2021

Triangles like (g/area (t/triangle2 [0 0] [0 10] [10 10])) returns -50.0 for area, which seems somewhat counter-intuitive. This behavior is the same for polygons like (g/area (p/polygon2 [0 0] [0 10] [10 0])). This is used to test the clockwise/counterclockwise ordering of points for certain polygon operations like extrude, and extrude-shell, so it does appear to be expected behavior. However, I also notice that g/IVolume has both a volume and signed-volume method.

My proposal is that g/IArea should be split the same way as the volume interface into area and signed-area, with signed-area returning the current implementations and area returning the absolute value of signed area. This seems more intuitive, but appreciate it would be a breaking change for any code dependent on this behavior.

I can also find a few places this is already accounted for, as example area for tetrahedron is implemented as: (transduce (map #(m/abs* (apply gu/tri-area3 %))) + (g/faces _))), ensuring it's area is not signed. There is similar code leftover in the org file for mesh2 (which didn't appear to translate into the no-org branch), and in the private area-xf in geom/utils.

Happy to submit a pull request if others are interested in this change in behavior, and welcome any feedback on this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant