Node: Utility Functions, Next: , Previous: Polyhedron Reference, Up: Top



Utility Functions

double trunc (double d) Function
Defined in pspglb.web. For some reason, when I compile 3DLDF using GNU CC on a PC Pentium II XEON under Linux 2.4.4 i686, the standard library function trunc() is not available. Therefore, I've had to write one. This is a kludge! Someday, I'll have to try to find a better solution to this problem.

pair<real, real> solve_quadratic (real a, real b, real c) Function
Defined in pspglb.web. This function tries to find the solutions S_0 and S_1 to the quadratic equation ax^2 + bx + c according to the formulae S_0 == -b + sqrt(b^2 - 4ac) / 2a) and S_1 == -b - sqrt( b^2 - 4ac) / 2a. Let r stand for the return value. If S_0 cannot be found, r.first will be INVALID_REAL, otherwise S_0. If S_1 cannot be found, r.second will be INVALID_REAL, otherwise S_1.
          (x + 4)(x + 2) = x^2 + 6x + 8 = 0
          
          real_pair r = solve_quadratic(1, 6, 8);
          => r.first == -2
          => r.second == -4
          
          real_pair r = solve_quadratic(1, -2, 4);
          => r.first == INVALID_REAL
          => r.second == INVALID_REAL