Changeset 303


Ignore:
Timestamp:
01/21/15 13:05:54 (9 years ago)
Author:
Maciej Komosinski
Message:

Improved error messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/util/3d.cpp

    r286 r303  
    1717{
    1818        double q = x*x + y*y + z*z;
    19         if (q < 0) { if (report_errors) FramMessage("Pt3D", "operator()", "sqrt domain error", 3); return 0; }
     19        if (q < 0) { if (report_errors) FMprintf("Pt3D", "operator()", FMLV_ERROR, "sqrt(%g): domain error", q); return 0; }
    2020        return sqrt(q);
    2121}
     
    2424{
    2525        double len = length();
    26         if (fabs(len) < 1e-50) { if (report_errors) FramMessage("Pt3D", "normalize()", "vector too small", 1); x = 1; y = 0; z = 0; return false; }
     26        if (fabs(len) < 1e-50) { if (report_errors) FMprintf("Pt3D", "normalize()", FMLV_WARN, "vector[%g,%g,%g] too small", x, y, z); x = 1; y = 0; z = 0; return false; }
    2727        operator/=(len);
    2828        return true;
     
    4141Orient Orient_1(Pt3D(1, 0, 0), Pt3D(0, 1, 0), Pt3D(0, 0, 1));
    4242
    43 // prosty obrot
     43// simple rotation
    4444void rotate2D(double k, double &x, double &y)
    4545{
     
    6464        Pt3D    t1(X), t2(dir);
    6565        if (getAngle(t1.x, t1.y, z)) // non-vertical
    66         {       
     66        {
    6767                rotate2D(-z, t1.x, t1.y);
    6868                rotate2D(-z, t2.x, t2.y);
     
    7070        }
    7171        else // vertical
    72         {       
     72        {
    7373                z = 0;
    7474                if (t1.z < 0)
     
    120120        {
    121121                y.x = 0; y.y = -x.z; y.z = x.y; // (0,-z,y)
    122         } 
     122        }
    123123        if ((ay <= ax) && (ay <= az)) // y
    124124        {
    125125                y.x = -x.z; y.y = 0; y.z = x.x; // (-z,0,x)
    126         } 
     126        }
    127127        else // z
    128128        {
    129129                y.x = -x.y; y.y = x.x; y.z = 0; // (-y,x,0)
    130         } 
     130        }
    131131        y.normalize();
    132132        z.vectorProduct(x, y);
     
    137137{
    138138        double q = x*x + y*y;
    139         if (q < 0) { if (Pt3D::report_errors) FramMessage("", "d2()", "sqrt domain error", 3); return 0; }
     139        if (q < 0) { if (Pt3D::report_errors) FMprintf("", "d2()", FMLV_ERROR, "sqrt(%g): domain error", q); return 0; }
    140140        return sqrt(q);
    141141}
Note: See TracChangeset for help on using the changeset viewer.