#include "Snowflake.h" Snowflake::Snowflake() : Snowflake(0, 0, 0, 0, 0) {} Snowflake::Snowflake(double x, double y, double z, double rx, double ry) : x(x) , y(y) , z(z) , rx(rx) , ry(ry) , initialZ(z) { distanceAdjust = uniform(1, 2); } void Snowflake::bind(void) { SimpleDataType::bind(); bindDouble(x, 1); bindDouble(y, 1); bindDouble(z, 1); bindDouble(rx, 1); bindDouble(ry, 1); bindDouble(distanceAdjust, 1); bindDouble(initialZ, 1); } char* Snowflake::toString(int verbose) { static char response[128]; char* temp = response; if (verbose) { temp += sprintf(temp, "x: %.2f\n", x); temp += sprintf(temp, "y: %.2f\n", y); temp += sprintf(temp, "z: %.2f\n", z); temp += sprintf(temp, "rx: %.2f\n", rx); temp += sprintf(temp, "ry: %.2f\n", ry); return response; } sprintf(response, "height: %.2f\n", z); return response; } void Snowflake::reset() { z = initialZ; } void Snowflake::fall(double distance) { distance *= distanceAdjust; z -= distance; while (z < 0) z += initialZ; rx += uniform(0, distance * 20.0); ry += uniform(0, distance * 20.0); } void Snowflake::getTranslation(double& x, double& y, double& z) { x = this->x; y = this->y; z = this->z; } void Snowflake::getRotation(double& rx, double& ry) { rx = this->rx; ry = this->ry; }