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

Remove require calls #33

Merged
merged 1 commit into from
Jun 15, 2024
Merged

Remove require calls #33

merged 1 commit into from
Jun 15, 2024

Conversation

mauriciopoppe
Copy link
Owner

No description provided.

@mauriciopoppe mauriciopoppe merged commit 72f136f into master Jun 15, 2024
3 checks passed
@mauriciopoppe mauriciopoppe deleted the remove-require-calls branch June 15, 2024 03:10
mauriciopoppe added a commit that referenced this pull request Jul 27, 2024
… the origin is not in the polygon

The PR #33 added detection for an edge case where all the points are
part of a plane, the detection algorithm was:

1. Compute the initial tetrahedron containing 4 vertices.
2. Taking any 3 vertex from it create a plane.
3. Project all the points towards the plane using dot product,
   if the dot product is greater than some tolerance (not zero because
   of float point errors) then it means that a point is not part of
   plane.

There is an error in (3), let's assume a simple input in 2d where all
the points are not a polygon.

- [2, 0], [2, 1], [2, -1] (they're points in x=2)
- [1, 0] which is a point in x=1

An ascii diagram:

```
 1       x
 |
 |
-0---x---x
 |
 |
-1       x
x=0 x=1 x=2
```

If step (2) detected that all the points in x=2 were part of the plane
where the normal is [1, 0] then by following (3) and projecting point
[1, 0] to the plane (note that the point is not the normal) would
result on it being behind the face and therefore it pass the check
and consider the input to be a plane.

The problem in (3) is that we should compare the projection of the point
to test [1, 0] to the projection of any plane point to the plane

- project [2, 0] to the plane with a normal [1, 0] is
  dot([2,0], [1,0]) = 2
- project [1, 0] to the plane with a normal [1, 0] is
  dot([1,0], [1,0]) = 1
- The diff is 1 and is greater than any tolerance (typically
  tolerance is a tiny value like 1e-9)
mauriciopoppe added a commit that referenced this pull request Jul 27, 2024
… the origin is not in the polygon

The PR #33 added detection for an edge case where all the points are
part of a plane, the detection algorithm was:

1. Compute the initial tetrahedron containing 4 vertices.
2. Taking any 3 vertex from it create a plane.
3. Project all the points towards the plane using dot product,
   if the dot product is greater than some tolerance (not zero because
   of float point errors) then it means that a point is not part of
   plane.

There is an error in (3), let's assume a simple input in 2d where all
the points are not a polygon.

- [2, 0], [2, 1], [2, -1] (they're points in x=2)
- [1, 0] which is a point in x=1

An ascii diagram:

```
 1       x
 |
 |
-0---x---x
 |
 |
-1       x
x=0 x=1 x=2
```

If step (2) detected that all the points in x=2 were part of the plane
where the normal is [1, 0] then by following (3) and projecting point
[1, 0] to the plane (note that the point is not the normal) would
result on it being behind the face and therefore it pass the check
and consider the input to be a plane.

The problem in (3) is that we should compare the projection of the point
to test [1, 0] to the projection of any plane point to the plane

- project [2, 0] to the plane with a normal [1, 0] is
  dot([2,0], [1,0]) = 2
- project [1, 0] to the plane with a normal [1, 0] is
  dot([1,0], [1,0]) = 1
- The diff is 1 and is greater than any tolerance (typically
  tolerance is a tiny value like 1e-9)
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

Successfully merging this pull request may close these issues.

1 participant