AcademySoftwareFoundation / AcademySoftwareFoundation/openvdb

Divide by zero checks

Open
#759 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
3.4k
Forks
774
Avg merge
3d 9h
Merged PRs (30d)
34

Description

I noticed that there is no divide-by-zero check [here](https://github.com/AcademySoftwareFoundation/openvdb/blob/78b445dc8c86285539cccc512ebfbd4e96dcda26/openvdb/math/Proximity.cc#L123):

```c++;
} else {
// c projects inside the [a,b] interval.
t = t / denom; // => Divide
return a + (ab * t);
}
```

Also also [there](https://github.com/AcademySoftwareFoundation/openvdb/blob/50f2cf20310acec3ece89f902486b1f67040fe11/openvdb/math/Math.h#L429):

```c++
if (Abs(b) > Abs(a)) {
relError = Abs((a - b) / b); // => Divide
} else {
relError = Abs((a - b) / a); // => Divide
}
```

I'm not sure whether they would cause any trouble.

Contributor guide

Open the contributing guide

Research direction

Start by inspecting the linked sections of openvdb/math/Proximity.cc and openvdb/math/Math.h, then trace the callers to determine whether either denominator can be zero. Confirm the intended behavior for those cases and verify that both divide-by-zero paths are handled without changing valid calculations.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.