/* Calculates if a position is eclipsed. */ bool is_eclipsed(const double pos[3], const double sol[3], double *depth) { double Rho[3], earth[3]; /* Determine partial eclipse */ double sd_earth = ArcSin(xkmper / vec3_length(pos)); vec3_sub(sol, pos, Rho); double sd_sun = ArcSin(sr / vec3_length(Rho)); vec3_mul_scalar(pos, -1, earth); double delta = ArcCos( vec3_dot(sol, earth) / vec3_length(sol) / vec3_length(earth) ); *depth = sd_earth - sd_sun - delta; if (sd_earth < sd_sun) return false; else if (*depth >= 0) return true; else return false; }
/* Calculates stellite's eclipse status and depth */ int Sat_Eclipsed(vector_t *pos, vector_t *sol, double *depth) { double sd_sun, sd_earth, delta; vector_t Rho, earth; /* Determine partial eclipse */ sd_earth = ArcSin(xkmper/pos->w); Vec_Sub(sol,pos,&Rho); sd_sun = ArcSin(__sr__/Rho.w); Scalar_Multiply(-1,pos,&earth); delta = Angle(sol,&earth); *depth = sd_earth - sd_sun - delta; if( sd_earth < sd_sun ) return( 0 ); else if( *depth >= 0 ) return( 1 ); else return( 0 ); } /*Function Sat_Eclipsed*/
void Calculate_RADec_and_Obs ( double _time, vector_t *pos, vector_t *vel, geodetic_t *geodetic, obs_astro_t *obs_set) { /* Reference: Methods of Orbit Determination by */ /* Pedro Ramon Escobal, pp. 401-402 */ double phi,theta,sin_theta,cos_theta,sin_phi,cos_phi, az,el,Lxh,Lyh,Lzh,Sx,Ex,Zx,Sy,Ey,Zy,Sz,Ez,Zz, Lx,Ly,Lz,cos_delta,sin_alpha,cos_alpha; obs_set_t obs; Calculate_Obs(_time,pos,vel,geodetic,&obs); /* if( isFlagSet(VISIBLE_FLAG) ) {*/ az = obs.az; el = obs.el; phi = geodetic->lat; theta = FMod2p(ThetaG_JD(_time) + geodetic->lon); sin_theta = sin(theta); cos_theta = cos(theta); sin_phi = sin(phi); cos_phi = cos(phi); Lxh = -cos(az) * cos(el); Lyh = sin(az) * cos(el); Lzh = sin(el); Sx = sin_phi * cos_theta; Ex = -sin_theta; Zx = cos_theta * cos_phi; Sy = sin_phi * sin_theta; Ey = cos_theta; Zy = sin_theta*cos_phi; Sz = -cos_phi; Ez = 0; Zz = sin_phi; Lx = Sx*Lxh + Ex * Lyh + Zx*Lzh; Ly = Sy*Lxh + Ey * Lyh + Zy*Lzh; Lz = Sz*Lxh + Ez * Lyh + Zz*Lzh; obs_set->dec = ArcSin(Lz); /* Declination (radians)*/ cos_delta = sqrt(1 - Sqr(Lz)); sin_alpha = Ly / cos_delta; cos_alpha = Lx / cos_delta; obs_set->ra = AcTan(sin_alpha,cos_alpha); /* Right Ascension (radians)*/ obs_set->ra = FMod2p(obs_set->ra); /*}*/ /*if*/ } /* Procedure Calculate_RADec */
void Standard_model_low_scale_constraint<Two_scale>::apply() { assert(model && "Error: Standard_model_low_scale_constraint::apply():" " model pointer must not be zero"); qedqcd.runto(scale, 1.0e-5); model->calculate_DRbar_masses(); const double alpha_em = qedqcd.displayAlpha(softsusy::ALPHA); const double alpha_s = qedqcd.displayAlpha(softsusy::ALPHAS); const double mz_pole = qedqcd.displayPoleMZ(); double delta_alpha_em = 0.; double delta_alpha_s = 0.; if (model->get_thresholds()) { delta_alpha_em = model->calculate_delta_alpha_em(alpha_em); delta_alpha_s = model->calculate_delta_alpha_s(alpha_s); } const double alpha_em_drbar = alpha_em / (1.0 - delta_alpha_em); const double alpha_s_drbar = alpha_s / (1.0 - delta_alpha_s); const double e_drbar = Sqrt(4.0 * Pi * alpha_em_drbar); const double g1 = model->get_g1(); const double g2 = model->get_g2(); const double mZ = model->get_thresholds() ? model->calculate_MVZ_DRbar(mz_pole) : mz_pole; double theta_w = model->calculate_theta_w(qedqcd, alpha_em_drbar); if (IsFinite(theta_w)) { model->get_problems().unflag_non_perturbative_parameter( "sin(theta_W)"); } else { model->get_problems().flag_non_perturbative_parameter( "sin(theta_W)", theta_w, get_scale(), 0); theta_w = ArcSin(Electroweak_constants::sinThetaW); } model->set_v(Re((2*mZ)/Sqrt(0.6*Sqr(g1) + Sqr(g2)))); model->calculate_Yu_DRbar(qedqcd); model->calculate_Yd_DRbar(qedqcd); model->calculate_Ye_DRbar(qedqcd); model->set_g1(1.2909944487358056*e_drbar*Sec(theta_w)); model->set_g2(e_drbar*Csc(theta_w)); model->set_g3(3.5449077018110318*Sqrt(alpha_s_drbar)); if (model->get_thresholds()) qedqcd.setPoleMW(model->recalculate_mw_pole(qedqcd.displayPoleMW())); }
Ecliptical EquatorialToEcliptical( const Equatorial & equatorial, Angle obliquity ) { double sinRA = equatorial.RightAscension().Sin( ); double cosRA = equatorial.RightAscension().Cos( ); double sinDec = equatorial.Declination().Sin( ); double cosDec = equatorial.Declination().Cos( ); double tanDec = (cosDec == 0.) ? infinity : sinDec / cosDec; double sinObl = obliquity.Sin( ); double cosObl = obliquity.Cos( ); Angle lng = ArcTan( sinRA * cosObl + tanDec * sinObl, cosRA ); lng.NormalizePositive( ); Angle lat = ArcSin( sinDec * cosObl - sinRA * cosDec * sinObl ); return Ecliptical( lng, lat, equatorial.Distance() ); }
Equatorial EclipticalToEquatorial( const Ecliptical & ecliptical, Angle obliquity ) { double sinLong = ecliptical.Longitude().Sin( ); double cosLong = ecliptical.Longitude().Cos( ); double sinLat = ecliptical.Latitude().Sin( ); double cosLat = ecliptical.Latitude().Cos( ); double tanLat = (cosLat == 0.) ? infinity : sinLat / cosLat; double sinObl = obliquity.Sin( ); double cosObl = obliquity.Cos( ); Angle ra = ArcTan( sinLong * cosObl - tanLat * sinObl, cosLong ); ra.NormalizePositive( ); Angle dec = ArcSin( sinLat * cosObl + sinLong * cosLat * sinObl ); return Equatorial( ra, dec, ecliptical.Distance() ); }
/** * Calculates V_CKM angles from Wolfenstein parameters (see * hep-ph/0406184) */ void CKM_parameters::set_from_wolfenstein(double lambdaW, double aCkm, double rhobar, double etabar) { assert(Abs(lambdaW) <= 1. && "Error: Wolfenstein lambda out of range!"); assert(Abs(aCkm) <= 1. && "Error: Wolfenstein A parameter out of range!"); assert(Abs(rhobar) <= 1. && "Error: Wolfenstein rho-bar parameter out of range!"); assert(Abs(etabar) <= 1. && "Error: Wolfenstein eta-bar parameter out of range!"); theta_12 = ArcSin(lambdaW); theta_23 = ArcSin(aCkm * Sqr(lambdaW)); const double lambdaW3 = Power(lambdaW, 3); const double lambdaW4 = Power(lambdaW, 4); const std::complex<double> rpe(rhobar, etabar); const std::complex<double> V13conj = aCkm * lambdaW3 * rpe * Sqrt(1.0 - Sqr(aCkm) * lambdaW4) / Sqrt(1.0 - Sqr(lambdaW)) / (1.0 - Sqr(aCkm) * lambdaW4 * rpe); if (std::isfinite(Re(V13conj)) && std::isfinite(Im(V13conj))) { theta_13 = ArcSin(Abs(V13conj)); delta = Arg(V13conj); } }
/*** FIXME: formalise with other copies */ static void Calc_RADec (gdouble jul_utc, gdouble saz, gdouble sel, qth_t *qth, obs_astro_t *obs_set) { double phi,theta,sin_theta,cos_theta,sin_phi,cos_phi, az,el,Lxh,Lyh,Lzh,Sx,Ex,Zx,Sy,Ey,Zy,Sz,Ez,Zz, Lx,Ly,Lz,cos_delta,sin_alpha,cos_alpha; geodetic_t geodetic; geodetic.lon = qth->lon * de2ra; geodetic.lat = qth->lat * de2ra; geodetic.alt = qth->alt / 1000.0; geodetic.theta = 0; az = saz * de2ra; el = sel * de2ra; phi = geodetic.lat; theta = FMod2p(ThetaG_JD(jul_utc) + geodetic.lon); sin_theta = sin(theta); cos_theta = cos(theta); sin_phi = sin(phi); cos_phi = cos(phi); Lxh = -cos(az) * cos(el); Lyh = sin(az) * cos(el); Lzh = sin(el); Sx = sin_phi * cos_theta; Ex = -sin_theta; Zx = cos_theta * cos_phi; Sy = sin_phi * sin_theta; Ey = cos_theta; Zy = sin_theta*cos_phi; Sz = -cos_phi; Ez = 0; Zz = sin_phi; Lx = Sx*Lxh + Ex * Lyh + Zx*Lzh; Ly = Sy*Lxh + Ey * Lyh + Zy*Lzh; Lz = Sz*Lxh + Ez * Lyh + Zz*Lzh; obs_set->dec = ArcSin(Lz); /* Declination (radians)*/ cos_delta = sqrt(1 - Sqr(Lz)); sin_alpha = Ly / cos_delta; cos_alpha = Lx / cos_delta; obs_set->ra = AcTan(sin_alpha,cos_alpha); /* Right Ascension (radians)*/ obs_set->ra = FMod2p(obs_set->ra); }
Horizontal EquatorialToHorizontal( const Equatorial & equatorial, Angle localSiderealTime, Angle geographicLatitude ) { Angle hourAngle = localSiderealTime - equatorial.RightAscension(); double sinHA = hourAngle.Sin( ); double cosHA = hourAngle.Cos( ); double sinDec = equatorial.Declination().Sin( ); double cosDec = equatorial.Declination().Cos( ); double tanDec = (cosDec == 0.) ? infinity : sinDec / cosDec; double sinLat = geographicLatitude.Sin( ); double cosLat = geographicLatitude.Cos( ); Angle az = ArcTan( sinHA, cosHA * sinLat - tanDec * cosLat ); az += Angle( M_PI ); az.NormalizePositive( ); Angle alt = ArcSin( sinDec * sinLat + cosHA * cosDec * cosLat ); return Horizontal( az, alt, equatorial.Distance() ); }
Equatorial HorizontalToEquatorial( const Horizontal & horizontal, Angle localSiderealTime, Angle geographicLatitude ) { Angle az = horizontal.Azimuth() - Angle( M_PI ); double sinAz = az.Sin( ); double cosAz = az.Cos( ); double sinAlt = horizontal.Altitude().Sin( ); double cosAlt = horizontal.Altitude().Cos( ); double tanAlt = (cosAlt == 0.) ? infinity : sinAlt / cosAlt; double sinLat = geographicLatitude.Sin( ); double cosLat = geographicLatitude.Cos( ); // (Meeus has an error here, which I've corrected.) Angle hourAngle = ArcTan( sinAz, cosAz * sinLat + tanAlt * cosLat ); Angle ra = localSiderealTime - hourAngle; ra.NormalizePositive( ); Angle dec = ArcSin( sinAlt * sinLat - cosAz * cosAlt * cosLat ); return Equatorial( ra, dec, horizontal.Distance() ); }
Equatorial GalacticToEquatorial( const Galactic & galactic ) { Angle galNorthRAAdj( 192.25 - 180., Angle::Degree ); Angle galNorthDec( 27.4, Angle::Degree ); Angle longOffset( 33. + 90., Angle::Degree ); Angle adjLong = galactic.Longitude() - longOffset; double sinAdjLong = adjLong.Sin( ); double cosAdjLong = adjLong.Cos( ); double sinLat = galactic.Latitude().Sin( ); double cosLat = galactic.Latitude().Cos( ); double tanLat = (cosLat == 0.) ? infinity : sinLat / cosLat; double sinNDec = galNorthDec.Sin( ); double cosNDec = galNorthDec.Cos( ); Angle y = ArcTan( sinAdjLong, cosAdjLong * sinNDec - tanLat * cosNDec ); Angle ra = y + galNorthRAAdj; ra.NormalizePositive( ); Angle dec = ArcSin( sinLat * sinNDec + cosAdjLong * cosLat * cosNDec ); return Equatorial( ra, dec, galactic.Distance() ); }
Galactic EquatorialToGalactic( const Equatorial & equatorial ) { Angle galNorthRA( 192.25, Angle::Degree ); Angle galNorthDec( 27.4, Angle::Degree ); Angle longOffset( 33. + 270., Angle::Degree ); Angle adjRA = galNorthRA - equatorial.RightAscension(); double sinAdjRA = adjRA.Sin( ); double cosAdjRA = adjRA.Cos( ); double sinDec = equatorial.Declination().Sin( ); double cosDec = equatorial.Declination().Cos( ); double tanDec = (cosDec == 0.) ? infinity : sinDec / cosDec; double sinNDec = galNorthDec.Sin( ); double cosNDec = galNorthDec.Cos( ); Angle x = ArcTan( sinAdjRA, cosAdjRA * sinNDec - tanDec * cosNDec ); Angle lng = longOffset - x; lng.NormalizePositive( ); Angle lat = ArcSin( sinDec * sinNDec + cosAdjRA * cosDec * cosNDec ); return Galactic( lng, lat, equatorial.Distance() ); }
void Calculate_RADec(double time, const double pos[3], const double vel[3], geodetic_t *geodetic, vector_t *obs_set) { /* Reference: Methods of Orbit Determination by */ /* Pedro Ramon Escobal, pp. 401-402 */ double phi, theta, sin_theta, cos_theta, sin_phi, cos_phi, az, el, Lxh, Lyh, Lzh, Sx, Ex, Zx, Sy, Ey, Zy, Sz, Ez, Zz, Lx, Ly, Lz, cos_delta, sin_alpha, cos_alpha; Calculate_Obs(time,pos,vel,geodetic,obs_set); az=obs_set->x; el=obs_set->y; phi=geodetic->lat; theta=FMod2p(ThetaG_JD(time)+geodetic->lon); sin_theta=sin(theta); cos_theta=cos(theta); sin_phi=sin(phi); cos_phi=cos(phi); Lxh=-cos(az)*cos(el); Lyh=sin(az)*cos(el); Lzh=sin(el); Sx=sin_phi*cos_theta; Ex=-sin_theta; Zx=cos_theta*cos_phi; Sy=sin_phi*sin_theta; Ey=cos_theta; Zy=sin_theta*cos_phi; Sz=-cos_phi; Ez=0.0; Zz=sin_phi; Lx=Sx*Lxh+Ex*Lyh+Zx*Lzh; Ly=Sy*Lxh+Ey*Lyh+Zy*Lzh; Lz=Sz*Lxh+Ez*Lyh+Zz*Lzh; obs_set->y=ArcSin(Lz); /* Declination (radians) */ cos_delta=sqrt(1.0-Sqr(Lz)); sin_alpha=Ly/cos_delta; cos_alpha=Lx/cos_delta; obs_set->x=AcTan(sin_alpha,cos_alpha); /* Right Ascension (radians) */ obs_set->x=FMod2p(obs_set->x); }
void MatrixToEuler(MATRIXCH *m, EULER *e) { int x, sinx, cosx, siny, cosy, sinz, cosz; int abs_cosx, abs_cosy, abs_cosz; int SineMatrixPitch, SineMatrixYaw, SineMatrixRoll; int CosMatrixPitch, CosMatrixYaw, CosMatrixRoll; #if 0 textprint("CosMatrixPitch = %d\n", CosMatrixPitch); /* WaitForReturn(); */ #endif if(m->mat32 >-65500 && m->mat32<65500) { /* Yaw */ /* Pitch */ #if j_and_r_change SineMatrixPitch = -m->mat32; #else SineMatrixPitch = -m->mat23; #endif SineMatrixPitch >>= m2e_scale; #if 0 textprint("SineMatrixPitch = %d\n", SineMatrixPitch); /* WaitForReturn(); */ #endif CosMatrixPitch = SineMatrixPitch * SineMatrixPitch; CosMatrixPitch >>= m2e_shift; CosMatrixPitch = -CosMatrixPitch; CosMatrixPitch += ONE_FIXED_S; CosMatrixPitch *= ONE_FIXED_S; CosMatrixPitch = SqRoot32(CosMatrixPitch); if(CosMatrixPitch) { if(CosMatrixPitch > ONE_FIXED_S) CosMatrixPitch = ONE_FIXED_S; else if(CosMatrixPitch < -ONE_FIXED_S) CosMatrixPitch = -ONE_FIXED_S; } else CosMatrixPitch = 1; SineMatrixYaw = WideMulNarrowDiv( #if j_and_r_change m->mat31 >> m2e_scale, ONE_FIXED_S, CosMatrixPitch); #else m->mat13 >> m2e_scale, ONE_FIXED_S, CosMatrixPitch); #endif #if 0 textprint("SineMatrixYaw = %d\n", SineMatrixYaw); /* WaitForReturn(); */ #endif CosMatrixYaw = WideMulNarrowDiv( m->mat33 >> m2e_scale, ONE_FIXED_S, CosMatrixPitch); #if 0 textprint("CosMatrixYaw = %d\n", CosMatrixYaw); /* WaitForReturn(); */ #endif /* Roll */ SineMatrixRoll = WideMulNarrowDiv( #if j_and_r_change m->mat12 >> m2e_scale, ONE_FIXED_S, CosMatrixPitch); #else m->mat21 >> m2e_scale, ONE_FIXED_S, CosMatrixPitch); #endif #if 0 textprint("SineMatrixRoll = %d\n", SineMatrixRoll); /* WaitForReturn(); */ #endif CosMatrixRoll = WideMulNarrowDiv( m->mat22 >> m2e_scale, ONE_FIXED_S, CosMatrixPitch); #if 0 textprint("CosMatrixRoll = %d\n", CosMatrixRoll); /* WaitForReturn(); */ #endif /* Tables are for values +- 2^16 */ sinx = SineMatrixPitch << m2e_scale; siny = SineMatrixYaw << m2e_scale; sinz = SineMatrixRoll << m2e_scale; cosx = CosMatrixPitch << m2e_scale; cosy = CosMatrixYaw << m2e_scale; cosz = CosMatrixRoll << m2e_scale; #if 0 textprint("sines = %d, %d, %d\n", sinx, siny, sinz); textprint("cos's = %d, %d, %d\n", cosx, cosy, cosz); /* WaitForReturn(); */ #endif /* Absolute Cosines */ abs_cosx = cosx; if(abs_cosx < 0) abs_cosx = -abs_cosx; abs_cosy = cosy; if(abs_cosy < 0) abs_cosy = -abs_cosy; abs_cosz = cosz; if(abs_cosz < 0) abs_cosz = -abs_cosz; /* Euler X */ if(abs_cosx > Cosine45) { x = ArcSin(sinx); if(cosx < 0) { x = -x; x += deg180; x &= wrap360; } } else { x = ArcCos(cosx); if(sinx < 0) { x = -x; x &= wrap360; } } #if (j_and_r_change == No) x = -x; x &= wrap360; #endif e->EulerX = x; /* Euler Y */ if(abs_cosy > Cosine45) { x = ArcSin(siny); if(cosy < 0) { x = -x; x += deg180; x &= wrap360; } } else { x = ArcCos(cosy); if(siny < 0) { x = -x; x &= wrap360; } } #if (j_and_r_change == No) x = -x; x &= wrap360; #endif e->EulerY = x; /* Euler Z */ if(abs_cosz > Cosine45) { x = ArcSin(sinz); if(cosz < 0) { x = -x; x += deg180; x &= wrap360; } } else { x = ArcCos(cosz); if(sinz < 0) { x = -x; x &= wrap360; } } #if (j_and_r_change == No) x = -x; x &= wrap360; #endif e->EulerZ = x; }
static base_t my_asin(const base_t& i) { return ArcSin(i); }
void Calculate_Obs(double _time, vector_t *pos, vector_t *vel, geodetic_t *geodetic, obs_set_t *obs_set) { double sin_lat,cos_lat, sin_theta,cos_theta, el,azim, top_s,top_e,top_z; vector_t obs_pos,obs_vel,range,rgvel; Calculate_User_PosVel(_time, geodetic, &obs_pos, &obs_vel); range.x = pos->x - obs_pos.x; range.y = pos->y - obs_pos.y; range.z = pos->z - obs_pos.z; rgvel.x = vel->x - obs_vel.x; rgvel.y = vel->y - obs_vel.y; rgvel.z = vel->z - obs_vel.z; Magnitude(&range); sin_lat = sin(geodetic->lat); cos_lat = cos(geodetic->lat); sin_theta = sin(geodetic->theta); cos_theta = cos(geodetic->theta); top_s = sin_lat * cos_theta * range.x + sin_lat * sin_theta * range.y - cos_lat * range.z; top_e = -sin_theta * range.x + cos_theta * range.y; top_z = cos_lat * cos_theta * range.x + cos_lat * sin_theta * range.y + sin_lat * range.z; azim = atan(-top_e/top_s); /*Azimuth*/ if( top_s > 0 ) azim = azim + pi; if( azim < 0 ) azim = azim + twopi; el = ArcSin(top_z/range.w); obs_set->az = azim; /* Azimuth (radians) */ obs_set->el = el; /* Elevation (radians)*/ obs_set->range = range.w; /* Range (kilometers) */ /* Range Rate (kilometers/second)*/ obs_set->range_rate = Dot(&range, &rgvel)/range.w; /* Corrections for atmospheric refraction */ /* Reference: Astronomical Algorithms by Jean Meeus, pp. 101-104 */ /* Correction is meaningless when apparent elevation is below horizon */ // obs_set->el = obs_set->el + Radians((1.02/tan(Radians(Degrees(el)+ // 10.3/(Degrees(el)+5.11))))/60); if( obs_set->el >= 0 ) SetFlag(VISIBLE_FLAG); else { obs_set->el = el; /*Reset to true elevation*/ ClearFlag(VISIBLE_FLAG); } /*else*/ } /*Procedure Calculate_Obs*/
void Render(double time) { GLfloat bs_rad = shape.BoundingSphere().Radius()*1.2f; auto light = CamMatrixf::Orbiting( shape.BoundingSphere().Center(), shape.BoundingSphere().Radius()*10.0, FullCircles(time / 23.0), Degrees(35 + SineWave(time / 31.0) * 50) ); GLfloat lgt_tgt_dist = Distance( shape.BoundingSphere().Center(), light.Position() ); auto lgt_proj = CamMatrixf::PerspectiveX( ArcSin(bs_rad/lgt_tgt_dist)*2, 1.0f, lgt_tgt_dist-bs_rad, lgt_tgt_dist+bs_rad ); auto camera = CamMatrixf::Orbiting( shape.BoundingSphere().Center(), shape.BoundingSphere().Radius()*2.8, FullCircles(time / 17.0), Degrees(SineWave(time / 19.0) * 80) ); GLfloat cam_tgt_dist = Distance( shape.BoundingSphere().Center(), camera.Position() ); auto cam_proj = CamMatrixf::PerspectiveX( ArcSin(bs_rad/cam_tgt_dist)*2, double(width)/height, cam_tgt_dist-bs_rad, cam_tgt_dist+bs_rad ); auto model = ModelMatrixf::RotationZ(Degrees(SineWave(time / 21.0)*25))* ModelMatrixf::Translation(0.0f,-bs_rad*0.25f, 0.0f); depth_vao.Bind(); depth_prog.Use(); depth_prog.camera_matrix.Set(lgt_proj*light); depth_prog.model_matrix.Set(model); depth_buffer.SetupViewport(); depth_buffer.Bind(); gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.ClearDepth(1.0f); gl.Clear().ColorBuffer().DepthBuffer(); gl.Enable(Capability::PolygonOffsetFill); shape.Draw(); // draw_vao.Bind(); draw_prog.Use(); draw_prog.camera_matrix.Set(cam_proj*camera); draw_prog.light_matrix.Set(lgt_proj*light); draw_prog.model_matrix.Set(model); draw_prog.camera_position.Set(camera.Position()); draw_prog.light_position.Set(light.Position()); DefaultFramebuffer::Bind(Framebuffer::Target::Draw); gl.Viewport(width, height); gl.ClearColor(0.2f, 0.2f, 0.2f, 0.0f); gl.ClearDepth(1.0f); gl.Clear().ColorBuffer().DepthBuffer(); gl.Disable(Capability::PolygonOffsetFill); shape.Draw(); }
void Calculate_Obs(double time, const double pos[3], const double vel[3], geodetic_t *geodetic, vector_t *obs_set) { /* The procedures Calculate_Obs and Calculate_RADec calculate */ /* the *topocentric* coordinates of the object with ECI position, */ /* {pos}, and velocity, {vel}, from location {geodetic} at {time}. */ /* The {obs_set} returned for Calculate_Obs consists of azimuth, */ /* elevation, range, and range rate (in that order) with units of */ /* radians, radians, kilometers, and kilometers/second, respectively. */ /* The WGS '72 geoid is used and the effect of atmospheric refraction */ /* (under standard temperature and pressure) is incorporated into the */ /* elevation calculation; the effect of atmospheric refraction on */ /* range and range rate has not yet been quantified. */ /* The {obs_set} for Calculate_RADec consists of right ascension and */ /* declination (in that order) in radians. Again, calculations are */ /* based on *topocentric* position using the WGS '72 geoid and */ /* incorporating atmospheric refraction. */ double sin_lat, cos_lat, sin_theta, cos_theta, el, azim, top_s, top_e, top_z; double obs_pos[3]; double obs_vel[3]; double range[3]; double rgvel[3]; Calculate_User_PosVel(time, geodetic, obs_pos, obs_vel); vec3_sub(pos, obs_pos, range); vec3_sub(vel, obs_vel, rgvel); double range_length = vec3_length(range); sin_lat=sin(geodetic->lat); cos_lat=cos(geodetic->lat); sin_theta=sin(geodetic->theta); cos_theta=cos(geodetic->theta); top_s=sin_lat*cos_theta*range[0]+sin_lat*sin_theta*range[1]-cos_lat*range[2]; top_e=-sin_theta*range[0]+cos_theta*range[1]; top_z=cos_lat*cos_theta*range[0]+cos_lat*sin_theta*range[1]+sin_lat*range[2]; azim=atan(-top_e/top_s); /* Azimuth */ if (top_s>0.0) azim=azim+pi; if (azim<0.0) azim = azim + 2*M_PI; el=ArcSin(top_z/range_length); obs_set->x=azim; /* Azimuth (radians) */ obs_set->y=el; /* Elevation (radians) */ obs_set->z=range_length; /* Range (kilometers) */ /* Range Rate (kilometers/second) */ obs_set->w = vec3_dot(range, rgvel)/vec3_length(range); obs_set->y=el; /**** End bypass ****/ if (obs_set->y<0.0) obs_set->y=el; /* Reset to true elevation */ }
double ArcCos(double arg) { /* Returns arccosine of argument */ return(pio2-ArcSin(arg)); }
/* Returns orccosine of rgument */ double ArcCos(double arg) { return( pio2 - ArcSin(arg) ); } /*Function ArcCos*/