// 1 step = 3.63 degrees void Turn(double degrees) { float StepsPerDegree = 3.645; Steps targetSteps; targetSteps.l = -degrees * StepsPerDegree + GetSteps().l; targetSteps.r = degrees * StepsPerDegree + GetSteps().r; SetTargetSteps(targetSteps.l, targetSteps.r); }
// 1 step = 7.71 mm void Move(double mm) { Steps steps; steps.l = mm * StepsPermm + GetSteps().l; steps.r = mm * StepsPermm + GetSteps().r; printf("Moving %lf millimeters\n", mm); printf("Setting steps: %d %d\n", steps.l, steps.r); SetTargetSteps(steps.l, steps.r); }
bool KeyFollow::SetLevel(wxByte nStep, wxByte nLevel) { if(nStep > GetSteps() || nLevel > m_nMaxValue) return false; m_vKFsteps[nStep]->level = nLevel; return true; }
bool KeyFollow::SetKey(wxByte nStep, wxByte nKey) { if(nStep > GetSteps() || nKey > MAX_KEYS) return false; m_vKFsteps[nStep]->key = nKey; return true; }
Steps* SongUtil::GetStepsByDescription( const Song *pSong, StepsType st, RString sDescription ) { vector<Steps*> vNotes; GetSteps( pSong, vNotes, st, Difficulty_Invalid, -1, -1, sDescription ); if( vNotes.size() == 0 ) return NULL; else return vNotes[0]; }
void main() { int a[100]; int h[100]; int n,k; RandomArray(a,n); PrintArray(a,n); GetSteps(h,k,n); ShellSort(a,n,h,k); PrintArray(a,n); getch(); }
std::map <Ball, int> bfs(const std::map <Ball, bool> &sonar, const Ball &from) { std::queue <Ball> spiral; std::map <Ball, int> distances; spiral.push(from); distances[from] = 0; while (!spiral.empty()) { Ball pointer = spiral.front(); spiral.pop(); for(const auto &step : GetSteps()) { Ball move = pointer + step; if(sonar.count(move) == 0 && (distances.count(move) == 0)) { distances[move] = distances[pointer] + 1; spiral.push(move); } } } return distances; }
Steps* SongUtil::GetOneSteps( const Song *pSong, StepsType st, Difficulty dc, int iMeterLow, int iMeterHigh, const RString &sDescription, unsigned uHash, bool bIncludeAutoGen ) { vector<Steps*> vpSteps; GetSteps( pSong, vpSteps, st, dc, iMeterLow, iMeterHigh, sDescription, bIncludeAutoGen, uHash, 1 ); // get max 1 if( vpSteps.empty() ) return NULL; else return vpSteps[0]; }
void Move3(double mm) { int initialSteps = GetSteps().l; float target = GetSteps().l + mm * StepsPermm; printf ("Speed: %d\n", SetSpeed(400, 400)); while (GetSteps().l * 1.0 < target) { // "Busy wait" until target is readched... printf("%d steps!\n", GetSteps().l); } Stop(); printf("Final steps: %d\n", GetSteps().l); float movedmm = (GetSteps().l - initialSteps) / StepsPermm; printf("Moved %lf mm!\n", movedmm); }
void update_position(float D) { newSteps = GetSteps(); diffSteps.l = newSteps.l - prevSteps.l; diffSteps.r = newSteps.r - prevSteps.r; diffmmL = (diffSteps.l * 1.0) / StepsPermm; diffmmR = (diffSteps.r * 1.0) / StepsPermm; dist = (diffmmL + diffmmR) / 2; ang = (diffmmR - diffmmL) / D; //dx = dist * sin(ang) / ang; //dy = dist * (1-cos(ang)) / ang; // Using functions below instead because division by 0 is not possible. dx = dist * cos(ang/2); dy = dist * sin(ang/2); prevSteps = newSteps; RobPos.x += dx * cos(thPrev) - dy * sin(thPrev); RobPos.y += dx * sin(thPrev) + dy * cos(thPrev); th = ang + thPrev; if (th >= 2 * PI) th -= 2 * PI; else if (th < 0) th += 2 * PI; RobPos.th = th; thPrev = th; printf("dist: %lf mm\nang : %lf rad\ndx/p: %lf\ndy/p: %lf\n\n", dist, ang, dx * cos(thPrev) - dy * sin(thPrev), dx * sin(thPrev) + dy * cos(thPrev)); printf("Robot position: (%lf, %lf)\nRobot Angle: %lf\n\n", RobPos.x, RobPos.y, RobPos.th); Sleep(10); }
bool Game_Party::ApplyStateDamage() { bool damage = false; std::vector<int16_t> states = GetInflictedStates(); const auto steps = GetSteps(); for (auto state_id : states) { RPG::State *state = ReaderUtil::GetElement(Data::states, state_id); // NOTE: We do steps + 1 here because this gets called before steps are incremented. if (state->hp_change_map_steps > 0 && state->hp_change_map_val > 0 && (((steps + 1) % state->hp_change_map_steps) == 0) ) { for (auto actor : GetActors()) { if (actor->HasState(state_id)) { actor->ChangeHp(-std::max<int>(0, std::min<int>(state->hp_change_map_val, actor->GetHp() - 1))); damage = true; } } } if (state->sp_change_map_steps > 0 && state->sp_change_map_val > 0 && (((steps + 1) % state->sp_change_map_steps) == 0) ){ for (auto actor : GetActors()) { if (actor->HasState(state_id)) { actor->ChangeSp(-state->sp_change_map_val); damage = true; } } } } return damage; }
wxByte KeyFollow::GetLevel(wxByte nStep) { if(nStep > GetSteps()) return 0; return m_vKFsteps[nStep]->level; }
wxByte KeyFollow::GetKey(wxByte nStep) { if(nStep > GetSteps()) return 0; return m_vKFsteps[nStep]->key; }
KeyFollow::~KeyFollow() { for(wxByte nStep = 0; nStep < GetSteps(); ++nStep) delete m_vKFsteps[nStep]; }