[cig-commits] r8950 - cs/benchmark/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Wed Dec 19 12:07:09 PST 2007


Author: luis
Date: 2007-12-19 12:07:08 -0800 (Wed, 19 Dec 2007)
New Revision: 8950

Added:
   cs/benchmark/cigma/trunk/src/Misc.cpp
   cs/benchmark/cigma/trunk/src/Misc.h
Log:
Add Misc.{h,cpp} for miscellaneous functions

Added: cs/benchmark/cigma/trunk/src/Misc.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/Misc.cpp	2007-12-19 20:07:02 UTC (rev 8949)
+++ cs/benchmark/cigma/trunk/src/Misc.cpp	2007-12-19 20:07:08 UTC (rev 8950)
@@ -0,0 +1,21 @@
+#include <iostream>
+#include <iomanip>
+#include <cassert>
+#include "Misc.h"
+
+
+double pick_from_interval(double a, double b)
+{
+    return a + (b - a) * rand()/(RAND_MAX + 1.0);
+}
+
+void bbox_random_point(double minpt[3], double maxpt[3], double x[3])
+{
+    const int nsd = 3;
+    for (int i = 0; i < nsd; i++)
+    {
+        assert(minpt[i] <= maxpt[i]);
+        x[i] = pick_from_interval(minpt[i], maxpt[i]);
+    }
+}
+

Added: cs/benchmark/cigma/trunk/src/Misc.h
===================================================================
--- cs/benchmark/cigma/trunk/src/Misc.h	2007-12-19 20:07:02 UTC (rev 8949)
+++ cs/benchmark/cigma/trunk/src/Misc.h	2007-12-19 20:07:08 UTC (rev 8950)
@@ -0,0 +1,10 @@
+#ifndef __MISC_H__
+#define __MISC_H__
+
+#include <cstdlib>
+#include <ctime>
+
+double pick_from_interval(double a, double b);
+void bbox_random_point(double minpt[3], double maxpt[3], double x[3]);
+
+#endif



More information about the cig-commits mailing list