ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
circles in a square world....... (Sdk)
circles in a square world....... // SdkbrezJan 28, 2000, 12:23am
'sup yall. this is the source (highlights) to my circle bot;
circles in a square world proved to be an easier task than I first expected, but to save y'all a little grey matter if ya come across it.....btw, all my values are hardcoded, but a generic "circleBot" could be easily adapted from this.. 1. prototypes...... void legwork(int x_axis, double z_axis, int yaw); double the_math(int x); 2. source........ while (1) while (x_axis < 17000) { //first quarter circle legwork(x_axis += 100, the_math(x_axis), yaw += 5); } while (x_axis > 0) { //second quarter circle legwork(x_axis -= 100, -(the_math(x_axis)), yaw +=5); } while (x_axis > -17000) { //third quarter circle legwork(x_axis -= 100, -(the_math(x_axis)), yaw += 5); } yaw = 0; //reset to 0 degrees while (x_axis < 0) { //fourth quarter circle legwork(x_axis += 100, the_math(x_axis), yaw += 5); } } } void legwork(int x_axis, double z_axis, int yaw) { aw_wait(1000); aw_int_set(AW_MY_YAW, yaw); aw_int_set(AW_MY_X, x_axis); aw_int_set(AW_MY_Z, (int) z_axis); if (aw_state_change()) printf("aw_state_changed failed"); } double the_math(int x) //returns the z coordinate { return sqrt((-(x * x)) + 255000000); // x^2 + y^2 = sqrt(r) } ..........brez. |