MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), bouncyPhysics(false), simulationPaused(false), gravityPhysics(true), simulationBorder(false), deltaT(TIMER_INTERVAL*3) { ui->setupUi(this); ui_bouncyToggle = findChild<QPushButton*>("bouncyToggle"); ui_pauseToggle = findChild<QPushButton*>("pauseToggle"); ui_gravityToggle = findChild<QPushButton*>("gravityToggle"); ui_borderToggle = findChild<QPushButton*>("borderToggle"); this->updateButtons(); // set black background QPalette Pal(palette()); Pal.setColor(QPalette::Background, Qt::black); this->setAutoFillBackground(true); this->setPalette(Pal); timerID = startTimer(TIMER_INTERVAL); //testing long double alfa = 0; long double v = 70; long double promien = 200; long double srodekX = 640; long double srodekY = 360; int NUMBER_OF_ORBS = 20; celestialBody cb; for (int i = 1; i <= NUMBER_OF_ORBS; i++) { cb.makePlanet(srodekX+cosl(alfa)*promien,srodekY+sinl(alfa)*promien); cb.setVelocity(sinl(alfa)*v,-cosl(alfa)*v); cbodies.push_back(cb); alfa+=2*M_PI/NUMBER_OF_ORBS; } alfa = 0; v = -30; promien = 100; srodekX = 640; srodekY = 360; NUMBER_OF_ORBS = 10; for (int i = 1; i <= NUMBER_OF_ORBS; i++) { cb.makePlanet(srodekX+cosl(alfa)*promien,srodekY+sinl(alfa)*promien); cb.setVelocity(sinl(alfa)*v,-cosl(alfa)*v); cb.setBrushColor(QColor(Qt::red)); cb.setPenColor(QColor(200,100,100)); cbodies.push_back(cb); alfa+=2*M_PI/NUMBER_OF_ORBS; } }
compl compl_resta(const compl a, const compl b){ compl z; real x, y, k, w ; x = a.mod * cosl(a.ang); y = a.mod * sinl(a.ang); w = b.mod * cosl(b.ang); k = b.mod * sinl(b.ang); z = compl_create((x - w),(y - k)); return z; }
long double complex CLANG_PORT_DECL(ccosl) (long double complex Z) { long double complex Res; __real__ Res = cosl (__real__ Z) * coshl ( __imag__ Z); __imag__ Res = -sinl (__real__ Z) * sinhl ( __imag__ Z); return Res; }
long double complex ccosl (long double complex Z) { long double complex Res; __real__ Res = cosl (__real__ Z) * coshl ( __imag__ Z); __imag__ Res = -sinl (__real__ Z) * sinhl ( __imag__ Z); return Res; }
long double complex CLANG_PORT_DECL(cpowl) (long double complex X, long double complex Y) { long double complex Res; long double i; long double r = hypotl (__real__ X, __imag__ X); if (r == 0.0L) { __real__ Res = __imag__ Res = 0.0L; } else { long double rho; long double theta; i = cargl (X); theta = i * __real__ Y; if (__imag__ Y == 0.0L) /* This gives slightly more accurate results in these cases. */ rho = powl (r, __real__ Y); else { r = logl (r); /* rearrangement of cexp(X * clog(Y)) */ theta += r * __imag__ Y; rho = expl (r * __real__ Y - i * __imag__ Y); } __real__ Res = rho * cosl (theta); __imag__ Res = rho * sinl (theta); } return Res; }
void cm_float_cos(unsigned argc, obj_t args) { obj_t recvr = CAR(args); m_float_new(consts.cl._float, cosl(FLOAT(recvr)->val)); }
extern "C" void uvm_os_wrap_libmath_cosl(CDataStack& dataStack) { long double x=dataStack.pop().getReal(); long double result=cosl(x); dataStack.push(result); }
long double asinl(long double x) { long double y, y_sin, y_cos; y = 0; while (1) { y_sin = sinl(y); y_cos = cosl(y); if (y > M_PI_2 || y < -M_PI_2) { y = fmodl(y, M_PI); } if (y_sin + LDBL_EPSILON >= x && y_sin - LDBL_EPSILON <= x) { break; } y = y - (y_sin - x) / y_cos; } return y; }
void test_cos() { static_assert((std::is_same<decltype(cos((double)0)), double>::value), ""); static_assert((std::is_same<decltype(cosf(0)), float>::value), ""); static_assert((std::is_same<decltype(cosl(0)), long double>::value), ""); assert(cos(0) == 1); }
D_TYPE _CALLTYPE1 _y1( D_TYPE x ) #endif { D_TYPE z, P1, Q1; /* if the argument is negative, set EDOM error, print an error message, * and return -HUGE */ if (x < 0.0) return( domain_err(OP_Y1, x, LD_IND) ); /* if x <= 7.5 use Hart YONE 6444, the low range approximation */ if ( x <= 7.5 ) return( x*evaluate( x*x, Y1p, 7, Y1q, 8) + (2.0/PI)*(_j1l(x)*logl(x) - 1.0/x) ); /* else if x > 7.5 use Hart PONE 6749 and QONE 7149, the high range approximation */ else { z = 8.0/x; P1 = evaluate( z*z, P1p, 5, P1q, 5); Q1 = z*evaluate( z*z, Q1p, 5, Q1q, 5); return( sqrtl(2.0/(PI*x))* ( P1*sinl(x-3.0*PI/4.0) + Q1*cosl(x-3.0*PI/4.0) ) ); } }
Expression *eval_builtin(enum BUILTIN builtin, Expressions *arguments) { assert(arguments && arguments->dim); Expression *arg0 = (Expression *)arguments->data[0]; Expression *e = NULL; switch (builtin) { case BUILTINsin: if (arg0->op == TOKfloat64) e = new RealExp(0, sinl(arg0->toReal()), Type::tfloat80); break; case BUILTINcos: if (arg0->op == TOKfloat64) e = new RealExp(0, cosl(arg0->toReal()), Type::tfloat80); break; case BUILTINtan: if (arg0->op == TOKfloat64) e = new RealExp(0, tanl(arg0->toReal()), Type::tfloat80); break; case BUILTINsqrt: if (arg0->op == TOKfloat64) e = new RealExp(0, sqrtl(arg0->toReal()), Type::tfloat80); break; case BUILTINfabs: if (arg0->op == TOKfloat64) e = new RealExp(0, fabsl(arg0->toReal()), Type::tfloat80); break; } return e; }
D_TYPE _CALLTYPE1 _y0( D_TYPE x ) #endif { D_TYPE z, P0, Q0; /* if the argument is negative, set EDOM error, print an error message, * and return -HUGE */ if (x < 0.0) return( domain_err(OP_Y0 , x, LD_IND) ); /* if x <= 7.5 use Hart YZERO 6245, the low range approximation */ if ( x <= 7.5 ) return( evaluate( x*x, Y0p, 8, Y0q, 8) + (2.0/PI)*_j0l(x)*logl(x) ); /* else if x > 7.5 use Hart PZERO 6548 and QZERO 6948, the high range approximation */ else { z = 8.0/x; P0 = evaluate( z*z, P0p, 5, P0q, 5); Q0 = z*evaluate( z*z, Q0p, 5, Q0q, 5); return( sqrtl(2.0/(PI*x))*(P0*sinl(x-PI/4) + Q0*cosl(x-PI/4)) ); } }
D_TYPE _CALLTYPE1 _j1( D_TYPE x ) #endif { D_TYPE z, P1, Q1; int sign; /* if the argument is negative, take the absolute value and set sign */ sign = 1; if( x < 0.0 ){ x = -x; sign = -1; } /* if x <= 7.5 use Hart JONE 6047 */ if ( x <= 7.5 ) return( sign*x*evaluate( x*x, J1p, 10, J1q, 4) ); /* else if x > 7.5 use Hart PONE 6749 and QONE 7149, the high range approximation */ else { z = 8.0/x; P1 = evaluate( z*z, P1p, 5, P1q, 5); Q1 = z*evaluate( z*z, Q1p, 5, Q1q, 5); return( sign*sqrtl(2.0/(PI*x))* ( P1*cosl(x-3.0*PI/4.0) - Q1*sinl(x-3.0*PI/4.0) ) ); } }
D_TYPE _CALLTYPE1 _j0( D_TYPE x ) #endif { D_TYPE z, P0, Q0; /* if the argument is negative, take the absolute value */ if ( x < 0.0 ) x = - x; /* if x <= 7.5 use Hart JZERO 5847 */ if ( x <= 7.5 ) return( evaluate( x*x, J0p, 11, J0q, 4) ); /* else if x >= 7.5 use Hart PZERO 6548 and QZERO 6948, the high range approximation */ else { z = 8.0/x; P0 = evaluate( z*z, P0p, 5, P0q, 5); Q0 = z*evaluate( z*z, Q0p, 5, Q0q, 5); return( sqrtl(2.0/(PI*x))*(P0*cosl(x-PI/4) - Q0*sinl(x-PI/4)) ); } }
void Coseno (Token ** Pila) { Token *Operando = EntornoEjecucion_BuscaSimbolo (*Pila); if (Buzon.GetHuboError ()) return; if (NoEsReal (Operando)) { BorrarTokenSiEsVariable (Operando); return; } long double ValorRetorno; long double ValorDominio = Operando->GetDatoReal (); BorrarTokenSiEsVariable (Operando); ValorDominio = Estado.AngulosEnGrados ? ValorDominio * (M_PI / 180.0L) : ValorDominio; if (fabsl (sinl (ValorDominio)) == 1.0L) ValorRetorno = 0.0L; else ValorRetorno = cosl (ValorDominio); if (Buzon.GetHuboError ()) return; Token *TokenRetorno = ConsigueToken (ValorRetorno); if (Buzon.GetHuboError ()) return; delete Desapila (Pila); Apila (Pila, TokenRetorno); if (FueraDeRango (TokenRetorno)) return; return; }
void Game::addAsteroide(){ Asteroide* asteroide; long double x, y, angle; int MAX_VERT = 5 + (rand() % (int)(20 - 5 + 1)); int diametro = 1 + (rand() % (int)(100 - 1 + 1)); asteroide = new Asteroide(MAX_VERT); int POSICION_X = rand()%800; int POSICION_Y = rand()%600; asteroide -> setDiametro(diametro); asteroide -> setTipoDireccion(rand()%7); asteroide -> setVelocidad(200 / diametro); for( int w = 0; w < asteroide -> getNumeroVertices(); w++) { angle = 360.0/asteroide -> getNumeroVertices(); int variacion = int(0.3 * ( asteroide -> getDiametro() + 1) ); x = cosl(w * angle*PI/180.0) * (asteroide -> getDiametro()) + POSICION_X + rand()%variacion; y = sinl(w * angle*PI/180.0) * (asteroide -> getDiametro()) + POSICION_Y + rand()%variacion; asteroide -> addVertice(Vector2D(x, y), w); if (w == 0) asteroide -> addVertice(Vector2D(x, y), asteroide -> getNumeroVertices()); } asteroides.emplace_back(*asteroide); }
long double complex cexpl (long double complex Z) { long double complex Res; long double rho = expl (__real__ Z); __real__ Res = rho * cosl(__imag__ Z); __imag__ Res = rho * sinl(__imag__ Z); return Res; }
void compl_print(const compl c){ /* DESC: Imprime en pantalla c con formato a + i b. */ real x,y; x = c.mod * cosl(c.ang); y = c.mod * sinl(c.ang); printf("el numero complejo es : \t %Lf + i * %Lf \n",x ,y); }
long double test1l(long double x) { long double y1, y2; y1 = sinl(x); y2 = cosl(x); return y1 - y2; }
float impulse_error(int N, int sign, float *data) { #ifdef __ANDROID__ double delta_sum = 0.0f; double sum = 0.0f; #else long double delta_sum = 0.0f; long double sum = 0.0f; #endif int i; for(i=0;i<N;i++) { #ifdef __ANDROID__ double re, im; if(sign < 0) { re = cos(2 * PI * (double)i / (double)N); im = -sin(2 * PI * (double)i / (double)N); }else{ re = cos(2 * PI * (double)i / (double)N); im = sin(2 * PI * (double)i / (double)N); } #else long double re, im; if(sign < 0) { re = cosl(2 * PI * (long double)i / (long double)N); im = -sinl(2 * PI * (long double)i / (long double)N); }else{ re = cosl(2 * PI * (long double)i / (long double)N); im = sinl(2 * PI * (long double)i / (long double)N); } #endif sum += re * re + im * im; re = re - data[2*i]; im = im - data[2*i+1]; delta_sum += re * re + im * im; } #ifdef __ANDROID__ return sqrt(delta_sum) / sqrt(sum); #else return sqrtl(delta_sum) / sqrtl(sum); #endif }
int main () { printf ("%.16Lg\n", cosl(0.7853981633974483096156608458198757210492)); printf ("%.16Lg\n", cosl(0.7853981633974483096156608458198757210492 *29)); printf ("%.16Lg\n", cosl(0.7853981633974483096156608458198757210492 *2)); printf ("%.16Lg\n", cosl(0.7853981633974483096156608458198757210492 *30)); printf ("%.16Lg\n", cosl(0.7853981633974483096156608458198757210492 *4)); printf ("%.16Lg\n", cosl(0.7853981633974483096156608458198757210492 *32)); printf ("%.16Lg\n", cosl(0.7853981633974483096156608458198757210492 *2/3)); printf ("%.16Lg\n", cosl(0.7853981633974483096156608458198757210492 *4/3)); }
long double complex csinl(long double complex z) { long double complex w; long double ch, sh; cchshl(cimagl(z), &ch, &sh); w = sinl(creall(z)) * ch + (cosl(creall(z)) * sh) * I; return (w); }
/** * Calculate the distance between two geodetic location in miles. */ double shgeo_dist(shgeo_t *f_geo, shgeo_t *t_geo) { static const shnum_t mile_mod = 90.9; shnum_t theta, dist; shnum_t lat1, lat2; shnum_t lon1, lon2; shgeo_loc(f_geo, &lat1, &lon1, NULL); shgeo_loc(t_geo, &lat2, &lon2, NULL); theta = lon1 - lon2; dist = (sinl(_deg2rad(lat1)) * sinl(_deg2rad(lat2))) + (cosl(_deg2rad(lat1)) * cosl(_deg2rad(lat2)) * cosl(_deg2rad(theta))); dist = acosl(dist); dist = _rad2deg(dist); dist = dist * mile_mod; return ((double)dist); }
long double complex cexpl(long double complex z) { long double complex w; long double r; r = expl(creall(z)); w = r * cosl(cimagl(z)) + (r * sinl(cimagl(z))) * I; return (w); }
__complex__ long double cexpl(__complex__ long double z) { __complex__ long double ret; long double r_exponent = expl(__real__ z); __real__ ret = r_exponent * cosl(__imag__ z); __imag__ ret = r_exponent * sinl(__imag__ z); return ret; }
long double complex ccosl(long double complex z) { long double complex w; long double ch, sh; _cchshl(cimagl(z), &ch, &sh); w = cosl(creall(z)) * ch - (sinl(creall(z)) * sh) * I; return w; }
long double TSolver::gcalc(const char f,const long double a,const long double b,const long double step) //calculates function { #define ain(x) (a-step<=x && a+step>=x) #define bin(x) (b-step<=x && b+step>=x) #define angin(x) (torad(a)-step<x && torad(a)+step>x) switch (f) {case '+' : return a+b; case '-' : return a-b; case '*' : return a*b; case '/' : if (bin(0)) {Err=E_DEV_ZERO;return 0;};return a/b; case '!' : if (floorl(a)!=a) {Err=E_ARG;return 0;}return factor(a); case '_' : return -a; case cpi : return M_PI; case cx : return X; case fexp : return exp(a); case fln : if (a<0) {Err=E_ARG;return 0;}return logl(a); case flog : if (a<0) {Err=E_ARG;return 0;}return log10l(a); case flogn : if (a<0) {Err=E_ARG;return 0;}return log(a)/log(b); case '^': case f_op_pow: case fpow : if (a<0 && b<1 && b>0 && (!fmodl(b,2))) {Err=E_ARG;return 0;}return powl(a,b); case fsqr : return a*a; case f_op_root: case froot : if (a<0 && (!fmodl(b,2))){Err=E_ARG;return 0;} return (a>0 || (!fmodl(b,2)))?powl(a,1/b):-powl(-a,1/b); case fsqrt : if (a<0) {Err=E_ARG;return 0;}return sqrtl(a); case f_abs : return fabsl(a); case fsin : return sinl(a); case fcos : return cosl(a); case ftan : if (angin(M_PI_2) || angin(M_PI_2+M_PI)) {Err=E_ARG;return 0;} return tanl(a); case fctan : if (angin(0) || angin(M_PI)) {Err=E_ARG;return 0;} return 1/tanl(a); case fsin+ARC : if (fabsl(a)>1) {Err=E_ARG;return 0;} return asinl(a); case fcos+ARC : if (fabsl(a)>1) {Err=E_ARG;return 0;} return acosl(a); case ftan+ARC : return atanl(a); case fctan+ARC: return atanl(1/a); case fsin+HYP : return sinhl(a); case fcos+HYP : return coshl(a); case ftan+HYP : return tanhl(a); case fctan+HYP : return 1/tanhl(a); #ifndef _OLD_ case fsin+HYP+ARC : return asinhl(a); case fcos+HYP+ARC : return acoshl(a); case ftan+HYP+ARC : if (fabsl(a)>=1) {Err=E_ARG;return 0;} return atanhl(a); case fctan+HYP+ARC : if (angin(0)) {Err=E_ARG;return 0;} return atanhl(1/a); #endif default: return 0; } }
long double complex cexpl (long double complex z) { long double a, b; long double complex v; a = REALPART (z); b = IMAGPART (z); COMPLEX_ASSIGN (v, cosl (b), sinl (b)); return expl (a) * v; }
long double complex csinhl(long double complex z) { long double complex w; long double x, y; x = creall(z); y = cimagl(z); w = sinhl(x) * cosl(y) + (coshl(x) * sinl(y)) * I; return w; }
long double complex ccoshl (long double complex a) { long double r, i; long double complex v; r = REALPART (a); i = IMAGPART (a); COMPLEX_ASSIGN (v, coshl (r) * cosl (i), - (sinhl (r) * sinl (i))); return v; }