Opened 3 years ago

Closed 8 months ago

#51 closed defect (fixed)

ModelGeometry: sqrt(negative)

Reported by: Maciej Komosinski Owned by: oriona
Priority: major Milestone:
Component: Framsticks core Version:
Keywords: Cc:

Description

"sqrt: DOMAIN error" for example:

frams "var m=Model.newFromString(\"//0\np:sh=1,ry=1\n\"); var mg=ModelGeometry.forModel(m); mg.geom_density=2; Simulator.print(mg.sizesAndAxes());" -q

Visual Studio output:

> var m=Model.newFromString("//0\np:sh=1,ry=1\n"); var mg=ModelGeometry.forModel(m); mg.geom_density=2; Simulator.print(mg.sizesAndAxes());
Script.Message: [(2.0,2.0,2.0),Orient@(-0,1,0)]

C++Builder output:

sqrt: DOMAIN error

sqrt: DOMAIN error

sqrt: DOMAIN error
Script.Message: [(2.0,2.0,2.0),Orient@(-0,1,0)]

In:
GeometryUtils::getNextEllipseSegmentationPoint(d, edge.z, edge.x, area.z, area.x);
y = b * sqrt(1.0 - (x*x) / (a*a));
sqrt domain error! sqrt(-0.0998866) because x=0.908248 and a=0.866025

Change History (2)

comment:1 Changed 3 years ago by Maciej Komosinski

Summary: sqrt(negative)ModelGeometry: sqrt(negative)

comment:2 Changed 8 months ago by Maciej Komosinski

Resolution: fixed
Status: newclosed

In 810:

Don't unnecessarily calculate sqrt(negative_value) [fixes #51]

Note: See TracTickets for help on using tickets.