void Scene03::updateSpaceShip(float deltaTime) { spaceship->line()->color = WHITE; float rotspeed = 3.14f; static Vector2 velocity = Vector2((rand()%100)-50, (rand()%100)-50); static Polar polar = Polar((rand()%360) * DEG_TO_RAD, 400.0f); if (input()->getKey( GLFW_KEY_UP )) { spaceship->line()->color = RED; velocity += polar.cartesian() * deltaTime; // thrust } if (input()->getKey( GLFW_KEY_RIGHT )) { polar.angle += rotspeed * deltaTime; // rotate right } if (input()->getKey( GLFW_KEY_LEFT )) { polar.angle -= rotspeed * deltaTime; // rotate left } spaceship->rotation = polar.angle; spaceship->position += velocity * deltaTime; if (spaceship->position.x < 0) { spaceship->position.x = SWIDTH; } if (spaceship->position.x > SWIDTH) { spaceship->position.x = 0; } if (spaceship->position.y < 0) { spaceship->position.y = SHEIGHT; } if (spaceship->position.y > SHEIGHT) { spaceship->position.y = 0; } }
void BigStroke(Painter& sw) { int n = 0; double r = 400; int i = 0; while(r > 5) { Pointf p = Polar(i * M_2PI / 400) * r + Pointf(400, 400); if(i) sw.Line(p); else sw.Move(p); sw.Line(Polar((i * M_2PI / 400 + M_2PI / 800)) * (r - 3) + Pointf(400, 400)); n += 2; r = r - 0.01; i++; } sw.Stroke(1, Black()); sw.Text(0, 0, "Elements: " + AsString(n), Arial(20)).Fill(Blue()); }
void Big(Painter& sw) { int n = 0; double sgn = 1; for(int r = 400; r > 5; r -= 3) { for(int i = 0; i < 400; i++) { Pointf p = Polar(sgn * i * M_2PI / 400) * r + Pointf(400, 400); if(i) sw.Line(p); else sw.Move(p); sw.Line(Polar(sgn * (i * M_2PI / 400 + M_2PI / 800)) * (r - 6) + Pointf(400, 400)); n += 2; } sw.Close(); sgn = -sgn; } sw.Fill(Black()); sw.Text(0, 0, "Elements: " + AsString(n), Arial(20)).Fill(Blue()); }
void Stroker::Round(const Pointf& p, const Pointf& v1, const Pointf& v2, double r) { double tolerance = 0.3; double a1 = Bearing(v1); double a2 = Bearing(v2); if(a1 < a2) a1 += 2 * M_PI; while(a1 > a2) { PutLine(Polar(p, r, a1)); a1 -= fid; } }
inline void Helper ( Matrix<Real>& d, Matrix<Complex<Real>>& e, Matrix<Real>& w, SortType sort, const HermitianEigSubset<Real>& subset ) { typedef Complex<Real> C; const Int n = d.Height(); Matrix<Real> eReal( n-1, 1 ); C yLast = 1; for( Int j=0; j<n-1; ++j ) { const C psi = e.Get(j,0); const Real psiAbs = Abs(psi); if( psiAbs == Real(0) ) yLast = 1; else yLast = Polar(Real(1),Arg(psi*yLast)); eReal.Set( j, 0, psiAbs ); } HermitianTridiagEig( d, eReal, w, sort, subset ); }
Complex Complex::Sqrt( Complex &c ) { Float32 a=sqrt(c.GetPolarMagnitude()); Float32 b=0.5*c.GetPolarAngle(); return Polar( a,b ); }
bool Glider::load(QSettings *config, int id) { QString keyname = "Glider%1"; //check if an entry exists if( config->contains( keyname.arg( id ) ) ) { QStringList data = config->value( keyname.arg( id ), "" ).toString().split(';', QString::KeepEmptyParts); // qDebug("Glider::load(): No of fetched glider items is %d", data.count()); // check to see if we have enough data members available if( data.count() < 15 ) { return false; } m_type = data[0]; m_registration = data[1]; m_callSign = data[2]; if( data[3].toInt() == 1 ) { m_seats = singleSeater; } else { m_seats = doubleSeater; } m_maxWater = data[4].toInt(); Speed V1, V2, V3, W1, W2, W3; V1.setKph( data[5].toDouble() ); V2.setKph( data[7].toDouble() ); V3.setKph( data[9].toDouble() ); W1.setMps( data[6].toDouble() ); W2.setMps( data[8].toDouble() ); W3.setMps( data[10].toDouble() ); m_polar = Polar( m_type, V1, W1, // v/w pair 1 V2, W2, // v/w pair 2 V3, W3, // v/w pair 3 data[12].toDouble(), // wing area data[13].toDouble(), // empty weight data[14].toDouble() ); // gross weight m_lastSafeID = id; if( data.count() >= 17 ) { m_polar.setWater( data[15].toInt() ); m_coPilot = data[16]; } if( data.count() >= 18 ) { m_polar.setAddLoad( data[17].toDouble() ); } if( data.count() >= 19 ) { m_isSelected = data[18].toInt(); } return true; } return false; }
Polar Planet::local2polar(Vec2 pl) const { return Polar(pl); }