Changeset 14709 for trunk/FACT++/src/InterpreterV8.cc
- Timestamp:
- 12/01/12 18:59:31 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/InterpreterV8.cc
r14695 r14709 1250 1250 } 1251 1251 1252 Handle<Value> InterpreterV8:: LocalDist(const Arguments &args)1252 Handle<Value> InterpreterV8::CalcDist(const Arguments &args, const bool local) 1253 1253 { 1254 1254 if (args.Length()!=2) … … 1266 1266 }; 1267 1267 1268 const Handle<String> s_zd = String::New("zd"); 1269 const Handle<String> s_az = String::New("az"); 1270 1271 const double zd0 = obj[0]->Get(s_zd)->NumberValue() * M_PI/180; 1272 const double az0 = obj[0]->Get(s_az)->NumberValue() * M_PI/180; 1273 const double zd1 = obj[1]->Get(s_zd)->NumberValue() * M_PI/180; 1274 const double az1 = obj[1]->Get(s_az)->NumberValue() * M_PI/180; 1275 1276 if (!finite(zd0) || !finite(zd1) || !finite(az0) || !finite(az1)) 1268 const Handle<String> s_theta = String::New(local?"zd":"dec"); // was: zd 1269 const Handle<String> s_phi = String::New(local?"az":"ra"); // was: az 1270 1271 const double conv_t = M_PI/180; 1272 const double conv_p = local ? -M_PI/180 : M_PI/12; 1273 const double offset = local ? 0 : M_PI; 1274 1275 const double theta0 = offset - obj[0]->Get(s_theta)->NumberValue() * conv_t; 1276 const double phi0 = obj[0]->Get(s_phi )->NumberValue() * conv_p; 1277 const double theta1 = offset - obj[1]->Get(s_theta)->NumberValue() * conv_t; 1278 const double phi1 = obj[1]->Get(s_phi )->NumberValue() * conv_p; 1279 1280 if (!finite(theta0) || !finite(theta1) || !finite(phi0) || !finite(phi1)) 1277 1281 return ThrowException(String::New("some values not valid or not finite.")); 1278 1282 … … 1291 1295 // cos(az1-az0) = cos(az1)*cos(az0) + sin(az1)*sin(az0) 1292 1296 1293 const double x = sin( zd0) * sin(zd1) * cos(az1-az0);1294 const double y = cos( zd0) * cos(zd1);1297 const double x = sin(theta0) * sin(theta1) * cos(phi1-phi0); 1298 const double y = cos(theta0) * cos(theta1); 1295 1299 1296 1300 const double res = acos(x + y) * 180/M_PI; 1297 1301 1298 1302 return handle_scope.Close(Number::New(res)); 1303 } 1304 1305 Handle<Value> InterpreterV8::LocalDist(const Arguments &args) 1306 { 1307 return CalcDist(args, true); 1308 } 1309 1310 Handle<Value> InterpreterV8::SkyDist(const Arguments &args) 1311 { 1312 return CalcDist(args, false); 1299 1313 } 1300 1314 … … 1970 1984 Handle<FunctionTemplate> sky = FunctionTemplate::New(ConstructorSky); 1971 1985 sky->SetClassName(String::New("Sky")); 1986 sky->Set(String::New("dist"), FunctionTemplate::New(SkyDist), ReadOnly); 1972 1987 global->Set(String::New("Sky"), sky, ReadOnly); 1973 1988
Note:
See TracChangeset
for help on using the changeset viewer.