/*****************************************************************************/ /* */ /* Copyright (C) 1999-2023 M. Held */ /* */ /* This code is not in the public domain. All rights reserved! Please make */ /* sure to read the full copyright statement contained in "README.txt" or in */ /* the "main" file of this code, such as "main.c". */ /* */ /*****************************************************************************/ /* */ /* Written by: Martin Held */ /* */ /* E-Mail: held@cs.sbg.ac.at */ /* Fax Mail: (+43 662) 8044-611 */ /* Voice Mail: (+43 662) 8044-6304 */ /* Snail Mail: Martin Held */ /* FB Informatik */ /* Universitaet Salzburg */ /* A-5020 Salzburg, Austria */ /* */ /*****************************************************************************/ #ifndef VRONI_BASIC_H #define VRONI_BASIC_H #include "consts.h" #include "util.h" #include "types.h" #define BASIC_MINI 1.0e-20 #ifndef RAND #define RND_MAX 2147483647 #define UniformRandom(x) \ {\ x = ((double) random()) / RND_MAX; } #define RandomInteger(N) \ (\ assert(N > 0), \ basic_i_local = random(), \ basic_i_local - (basic_i_local / (N)) * (N)) #define InitRandom(seed) \ {\ srandom(seed); } #else #ifdef RAND_MAX #define RND_MAX RAND_MAX #else #define RND_MAX 32767 #endif #define UniformRandom(x) \ {\ x = ((double) rand()) / RND_MAX; \ } #define RandomInteger(N) \ (\ assert(N > 0), \ basic_i_local = rand(), \ basic_i_local - (basic_i_local / (N)) * (N)) #define InitRandom(seed) \ {\ srand(seed); } #endif /* #define ScaleX(xc) (scale_factor * (xc - shift.x)) #define ScaleY(yc) (scale_factor * (yc - shift.y)) #define ScaleV(value) (value * scale_factor) #define UnscaleX(xc) (assert(scale_factor > 0.0), xc / scale_factor + shift.x) #define UnscaleY(yc) (assert(scale_factor > 0.0), yc / scale_factor + shift.y) #define UnscaleV(value) (assert(scale_factor > 0.0), value / scale_factor) */ #define CirBBox(p, r, bb_min, bb_max) {\ (bb_min).x = (p).x - r; \ (bb_min).y = (p).y - r; \ (bb_max).x = (p).x + r; \ (bb_max).y = (p).y + r; } #define TriBBox(a, b, c, bb_min, bb_max) {\ MinMax3((a).x, (b).x, (c).x, (bb_min).x, (bb_max).x); \ MinMax3((a).y, (b).y, (c).y, (bb_min).y, (bb_max).y); } #endif