Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <chrono>
- #include <cmath>
- #define DELAY_BETWEEN_WIGGLES 50 //In milliseconds.
- #define MAX_WIGGLE_SHIFT 50 //In spaces.
- #define PI 3.14159265
- #define PID4 0.785398163397
- void nanowait(){
- std::chrono::time_point<std::chrono::high_resolution_clock> start = std::chrono::high_resolution_clock::now();
- for(;;){
- if(std::chrono::high_resolution_clock::now()-start>std::chrono::milliseconds(DELAY_BETWEEN_WIGGLES)){
- return;
- }
- }
- }
- int main(){
- float wavelength = 5.0f; //Not exact. Actual wavelength is x8 of this value.
- for(;;){
- //Limited loop so it doesn't break down due to float percision errors.
- for(unsigned int i = 0; i < floor(wavelength*8) ;i++){
- int shift = floor((cos(( float(i)/wavelength ) * PID4 )+1.0f)*(MAX_WIGGLE_SHIFT/2));
- std::cout << std::string( shift , ' ') << "wiggle" << i << std::endl;
- nanowait();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement