JuliaGeometry / JuliaGeometry/GeometryBasics.jl

Area of 2D triangle can be negative

Open
#121 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
215
Forks
64
Avg merge
3d 18h
Merged PRs (30d)
2

Description

For example:

julia> area(Point2f0[[0,0], [0,1], [1,1]])
-0.5f0

The relevant area method is here:
https://github.com/JuliaGeometry/GeometryBasics.jl/blob/24d0ee53b0d2ff3eca5bc3a8c864ad53d534df76/src/triangulation.jl#L36

I think there are two issues with this method:

  1. It's the generic implementation for N dimensions, but it only works for N=2, as it assumes that cross exists and returns a scalar.
  2. It's missing an abs call on the result.

Regarding the first point: there's already a specific method for N=3, and we can make one for N=2. Do we need a generic method for N>3?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/triangulation.jl at the area method linked in the issue, and reproduce the Point2f0 example in Julia. Compare it with the existing 3D method, then determine how 2D orientation and dimensions above 3 should be handled. Done means the reported case has the intended nonnegative area and the supported dimensional behavior is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.