misc.cpp

changeset 0
c51cce84a9ac
child 13
3955ff2a7d72
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc.cpp	Fri Mar 15 20:11:18 2013 +0200
@@ -0,0 +1,37 @@
+#include "common.h"
+#include <math.h>
+
+double GetWordFloat (str& s, int n) {
+	return atof ((s / " ")[n]);
+}
+
+long GetWordInt (str& s, int n) {
+	return atol ((s / " ")[n]);
+}
+
+vertex ParseVertex (str& s, int n) {
+	vertex v;
+	v.x = GetWordFloat (s, n);
+	v.y = GetWordFloat (s, n+1);
+	v.z = GetWordFloat (s, n+2);
+	
+	return v;
+}
+
+void StripWhitespace (str& s) {
+	str other;
+	
+	for (size_t i = 0; i < ~s; i++)
+		if (s[i] > 32 && s[i] < 127)
+			other += s[i];
+}
+
+vertex bearing::project (vertex& vSource, ulong ulLength) {
+	vertex vDest = vSource;
+	
+	vDest.x += (cos (fAngle) * ulLength);
+	vDest.y += (sin (fAngle) * ulLength);
+	vDest.x += (cos (fPitch) * ulLength);
+	vDest.z += (sin (fPitch) * ulLength);
+	return vDest;
+}
\ No newline at end of file

mercurial