Skip to content

Division by zero error on 1-1-2 triangles #40

@adamfranco

Description

@adamfranco

For pairs of segments that have the same length and a base that is twice their length, the circumcircle-radius algorithm results in a division-by-zero error. The test script below will demonstrate this.

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import math
import sys

a = 0.0949651002884
b = 0.0949651002884
c = 0.189930200577

a = 1
b = 1
c = 2

sys.stderr.write("\n\na={}\nb={}\nc={}\nfabs={}\n(a+b+c)={}\n(b+c-a)={}\n(c+a-b)={}\n(a+b-c)={}\n\n".format(a,b,c, math.fabs((a+b+c)*(b+c-a)*(c+a-b)*(a+b-c)), (a+b+c), (b+c-a), (c+a-b), (a+b-c)))

r = (a * b * c)/math.sqrt(math.fabs((a+b+c)*(b+c-a)*(c+a-b)*(a+b-c)))

print r

I've not yet found another algorithm for finding the circumcircle radius that doesn't have this issue, but there may be one out there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions