Skip to content

The attempt to avoid dividing by zero is incorrect #15

@tspink

Description

@tspink

hipAngle1 = atan(X / Z); // calc hip angle from vertical

The check you have on Line 389, to avoid dividing by zero on Line 391 is incorrect. You are ensuring that the dividend (i.e. the number to be divided, X) is not zero, when you should be ensuring that the divisor (i.e. the number that divides the dividend, Z) is not zero.

Therefore the check should be to ensure that Z does not become zero. There is nothing wrong with the dividend (in this case X) becoming zero. As the X approaches zero, so does the value of the fraction - which is correct.

I note that Line 395 then uses the result of the hipHypotenuse, so it is this division that may need to be protected.

(Note: this error is made in multiple places)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions