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

May throw exception in Profiles.kt #103

Closed
EthanHu29 opened this issue May 28, 2024 · 0 comments
Closed

May throw exception in Profiles.kt #103

EthanHu29 opened this issue May 28, 2024 · 0 comments

Comments

@EthanHu29
Copy link

core/Profiles.kt

89 val rawIndex = this.disps.binarySearch(x)
90 val beginIndex = if (rawIndex >= 0) {
91 rawIndex
92 } else {
...
98 for (index in beginIndex..disps.lastIndex) {
val v = vels.last()
100 val a = minAccels[index - 1]

        val targetDisp = newDisps.last() + (targetVel * targetVel - v * v) / (2 * a)
        if (x + targetDisp > disps[index]) {
            newDisps.add(disps[index] - x)
 105         vels.add(sqrt(v * v + 2 * a * (this.disps[index] - this.disps[index - 1])))

...

Here I list lines may throw exception. In line 89, rawIndex could be 0, when x == this.disps[0],
then beginInedex = 0.
In this scenario line 100 and 105 could throw exception, when index =0,
100: minAccels[index - 1] becomes minAccels[- 1]
105: this.disps[index - 1] becomes this.disps[- 1],

Any suggestion on this issue?

@rbrott rbrott closed this as completed in 60fcbd6 May 29, 2024
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