Vector3f Renderer::Uniform_Sample_All_light(const Scenes* scenes,const std::vector<Light*>& _ligs, const Ray &ray, Intersect& isec, const sampler2D *sample, const TransformV* trans, const Renderer* render) { //direct illumination Vector3f Result(0.f,0.f,0.f); Ray ShadowRay; Vector3f AverageDir(0.f,0.f,0.f); Vector3f Shadow_dir; if(_ligs.size() == 0) return Result; for(int i=0;i<_ligs.size();i++) { if(_ligs[i]->is_Delta) Result += Uniform_Sample_One_light(scenes, _ligs[i], ray, isec, sample, trans, render, Shadow_dir,0); else { Vector3f tempRes(0.f,0.f,0.f); int TotalS = sample->get_xspp() * sample->get_yspp(); for(int j=0;j<TotalS;j++) { tempRes += Uniform_Sample_One_light(scenes, _ligs[i], ray, isec, sample, trans, render, Shadow_dir,j); AverageDir += Shadow_dir; } tempRes = tempRes / TotalS; Result += tempRes; } } return Result; }
/* Compute satellite position & velocity at the given time * using this ephemeris. * * @throw InvalidRequest if required data has not been stored. */ Xvt GloEphemeris::svXvt(const CommonTime& epoch) const throw( gpstk::InvalidRequest ) { // Check that the given epoch is within the available time limits. // We have to add a margin of 15 minutes (900 seconds). if ( epoch < (ephTime - 900.0) || epoch >= (ephTime + 900.0) ) { InvalidRequest e( "Requested time is out of ephemeris data" ); GPSTK_THROW(e); } // Values to be returned will be stored here Xvt sv; // If the exact epoch is found, let's return the values if ( epoch == ephTime ) // exact match for epoch { sv.x[0] = x[0]*1.e3; // m sv.x[1] = x[1]*1.e3; // m sv.x[2] = x[2]*1.e3; // m sv.v[0] = v[0]*1.e3; // m/sec sv.v[1] = v[1]*1.e3; // m/sec sv.v[2] = v[2]*1.e3; // m/sec // In the GLONASS system, 'clkbias' already includes the // relativistic correction, therefore we must substract the late // from the former. sv.relcorr = sv.computeRelativityCorrection(); sv.clkbias = clkbias + clkdrift * (epoch - ephTime) - sv.relcorr; sv.clkdrift = clkdrift; sv.frame = ReferenceFrame::PZ90; // We are done, let's return return sv; } // Get the data out of the GloRecord structure double px( x[0] ); // X coordinate (km) double vx( v[0] ); // X velocity (km/s) double ax( a[0] ); // X acceleration (km/s^2) double py( x[1] ); // Y coordinate double vy( v[1] ); // Y velocity double ay( a[1] ); // Y acceleration double pz( x[2] ); // Z coordinate double vz( v[2] ); // Z velocity double az( a[2] ); // Z acceleration // We will need some PZ-90 ellipsoid parameters PZ90Ellipsoid pz90; double we( pz90.angVelocity() ); // Get sidereal time at Greenwich at 0 hours UT double gst( getSidTime( ephTime ) ); double s0( gst*PI/12.0 ); YDSTime ytime( ephTime ); double numSeconds( ytime.sod ); double s( s0 + we*numSeconds ); double cs( std::cos(s) ); double ss( std::sin(s) ); // Initial state matrix Vector<double> initialState(6), accel(3), dxt1(6), dxt2(6), dxt3(6), dxt4(6), tempRes(6); // Get the reference state out of GloEphemeris object data. Values // must be rotated from PZ-90 to an absolute coordinate system // Initial x coordinate (m) initialState(0) = (px*cs - py*ss); // Initial y coordinate initialState(2) = (px*ss + py*cs); // Initial z coordinate initialState(4) = pz; // Initial x velocity (m/s) initialState(1) = (vx*cs - vy*ss - we*initialState(2) ); // Initial y velocity initialState(3) = (vx*ss + vy*cs + we*initialState(0) ); // Initial z velocity initialState(5) = vz; // Integrate satellite state to desired epoch using the given step double rkStep( step ); if ( (epoch - ephTime) < 0.0 ) rkStep = step*(-1.0); CommonTime workEpoch( ephTime ); double tolerance( 1e-9 ); bool done( false ); while (!done) { // If we are about to overstep, change the stepsize appropriately // to hit our target final time. if( rkStep > 0.0 ) { if( (workEpoch + rkStep) > epoch ) rkStep = (epoch - workEpoch); } else { if ( (workEpoch + rkStep) < epoch ) rkStep = (epoch - workEpoch); } numSeconds += rkStep; s = s0 + we*( numSeconds ); cs = std::cos(s); ss = std::sin(s); // Accelerations are computed once per iteration accel(0) = ax*cs - ay*ss; accel(1) = ax*ss + ay*cs; accel(2) = az; dxt1 = derivative( initialState, accel ); for( int j = 0; j < 6; ++j ) tempRes(j) = initialState(j) + rkStep*dxt1(j)/2.0; dxt2 = derivative( tempRes, accel ); for( int j = 0; j < 6; ++j ) tempRes(j) = initialState(j) + rkStep*dxt2(j)/2.0; dxt3 = derivative( tempRes, accel ); for( int j = 0; j < 6; ++j ) tempRes(j) = initialState(j) + rkStep*dxt3(j); dxt4 = derivative( tempRes, accel ); for( int j = 0; j < 6; ++j ) initialState(j) = initialState(j) + rkStep * ( dxt1(j) + 2.0 * ( dxt2(j) + dxt3(j) ) + dxt4(j) ) / 6.0; // If we are within tolerance of the target time, we are done. workEpoch += rkStep; if ( std::fabs(epoch - workEpoch ) < tolerance ) done = true; } // End of 'while (!done)...' px = initialState(0); py = initialState(2); pz = initialState(4); vx = initialState(1); vy = initialState(3); vz = initialState(5); sv.x[0] = 1000.0*( px*cs + py*ss ); // X coordinate sv.x[1] = 1000.0*(-px*ss + py*cs); // Y coordinate sv.x[2] = 1000.0*pz; // Z coordinate sv.v[0] = 1000.0*( vx*cs + vy*ss + we*(sv.x[1]/1000.0) ); // X velocity sv.v[1] = 1000.0*(-vx*ss + vy*cs - we*(sv.x[0]/1000.0) ); // Y velocity sv.v[2] = 1000.0*vz; // Z velocity // In the GLONASS system, 'clkbias' already includes the relativistic // correction, therefore we must substract the late from the former. sv.relcorr = sv.computeRelativityCorrection(); sv.clkbias = clkbias + clkdrift * (epoch - ephTime) - sv.relcorr; sv.clkdrift = clkdrift; sv.frame = ReferenceFrame::PZ90; // We are done, let's return return sv; } // End of method 'GloEphemeris::svXvt(const CommonTime& t)'