Changeset 5455 for trunk/psLib/src/astro/psEarthOrientation.c
- Timestamp:
- Nov 1, 2005, 3:07:25 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astro/psEarthOrientation.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psEarthOrientation.c
r5450 r5455 9 9 * @author Robert Daniel DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-1 0-28 02:25:22$11 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-11-02 01:07:25 $ 13 13 * 14 14 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 54 54 static bool eocInit() 55 55 { 56 int nFail = 0;56 unsigned int nFail = 0; 57 57 58 58 // Read config file … … 158 158 } 159 159 160 psSphere *psAberration(psSphere *a ctual,161 const psSphere *a pparent,160 psSphere *psAberration(psSphere *apparent, 161 const psSphere *actual, 162 162 const psSphere *direction, 163 163 double speed) 164 164 { 165 PS_ASSERT_PTR_NON_NULL(a pparent, NULL);165 PS_ASSERT_PTR_NON_NULL(actual, NULL); 166 166 PS_ASSERT_PTR_NON_NULL(direction, NULL); 167 167 if (fabs(speed) < DBL_EPSILON) { … … 171 171 } 172 172 173 if (a ctual== NULL) {174 a ctual= psSphereAlloc();173 if (apparent == NULL) { 174 apparent = psSphereAlloc(); 175 175 } else { 176 a ctual->r = 0.0;177 a ctual->d = 0.0;178 a ctual->rErr = 0.0;179 a ctual->dErr = 0.0;176 apparent->r = 0.0; 177 apparent->d = 0.0; 178 apparent->rErr = 0.0; 179 apparent->dErr = 0.0; 180 180 } 181 181 psSphere *rp = psSphereAlloc(); … … 188 188 // mu = apparent->r * direction->r + apparent->d * direction->d; 189 189 psCube* directionVector = psSphereToCube(direction); 190 psCube* a pparentVector = psSphereToCube(apparent);191 mu = acos(directionVector->x*a pparentVector->x +192 directionVector->y*a pparentVector->y +193 directionVector->z*a pparentVector->z);190 psCube* actualVector = psSphereToCube(actual); 191 mu = acos(directionVector->x*actualVector->x + 192 directionVector->y*actualVector->y + 193 directionVector->z*actualVector->z); 194 194 195 195 //rp = apparent - mu * direction; 196 rp->r = a pparent->r - mu * direction->r;197 rp->d = a pparent->d - mu * direction->d;196 rp->r = actual->r - mu * direction->r; 197 rp->d = actual->d - mu * direction->d; 198 198 199 199 mu_p = mu + speed * ((mu * mu - 1.0) / (1.0 - speed * mu)); … … 210 210 r_p->d = mu_p * direction->d + a * rp->d; 211 211 212 *a ctual= *r_p;212 *apparent = *r_p; 213 213 /* 214 214 psSphereRot *rot = NULL; … … 218 218 double sinD = sin(direction->d); 219 219 rot = psSphereRotQuat(cosR*cosD, sinR*cosD, sinD, speed); 220 220 221 221 actual = psSphereRotApply(actual, rot, apparent); 222 222 */ … … 224 224 psFree(r_p); 225 225 psFree(directionVector); 226 psFree(a pparentVector);226 psFree(actualVector); 227 227 psFree(rpVector); 228 return a ctual;229 } 230 231 psSphere *psGravityDeflection(psSphere *a ctual,232 psSphere *a pparent,228 return apparent; 229 } 230 231 psSphere *psGravityDeflection(psSphere *apparent, 232 psSphere *actual, 233 233 psSphere *sun) 234 234 { 235 PS_ASSERT_PTR_NON_NULL(a pparent, NULL);235 PS_ASSERT_PTR_NON_NULL(actual, NULL); 236 236 PS_ASSERT_PTR_NON_NULL(sun, NULL); 237 237 238 // calculating the a ctual angle from the apparentangle and the sun position239 240 // first, calculate the angle between the sun vector and the a pparentvector238 // calculating the apparent angle from the actual angle and the sun position 239 240 // first, calculate the angle between the sun vector and the actual vector 241 241 242 242 // Moving to cartesian first: XXX -- is this required? 243 243 psCube* sunVector = psSphereToCube(sun); 244 psCube* a pparentVector = psSphereToCube(apparent);244 psCube* actualVector = psSphereToCube(actual); 245 245 246 246 // use dot product to calculate the angle of separation 247 247 // N.B., assuming the psSphereToCube function returns a unit vector. 248 double theta = acos(sunVector->x*a pparentVector->x +249 sunVector->y*a pparentVector->y +250 sunVector->z*a pparentVector->z);248 double theta = acos(sunVector->x*actualVector->x + 249 sunVector->y*actualVector->y + 250 sunVector->z*actualVector->z); 251 251 252 252 double r0 = PS_AU * tan(theta); … … 259 259 //if deflection is greater than limit, the light rays will hit the sun 260 260 psWarning("Invalid positions. Light ray will not be seen on earth.\n"); 261 psFree(a pparentVector);261 psFree(actualVector); 262 262 psFree(sunVector); 263 return a ctual;264 } 265 266 if (a ctual== NULL) {267 a ctual= psSphereAlloc();263 return apparent; 264 } 265 266 if (apparent == NULL) { 267 apparent = psSphereAlloc(); 268 268 } else { 269 a ctual->r = 0.0;270 a ctual->d = 0.0;271 a ctual->rErr = 0.0;272 a ctual->dErr = 0.0;273 } 274 275 // bend the a pparentvector away from the sun vector by deflection angle.269 apparent->r = 0.0; 270 apparent->d = 0.0; 271 apparent->rErr = 0.0; 272 apparent->dErr = 0.0; 273 } 274 275 // bend the actual vector away from the sun vector by deflection angle. 276 276 // XXX: Not sure how to do this. Dave thinks the formula should be: 277 277 // theta = atan(r0/d)*tan(deflection), phi = thete/tan(deflection) … … 281 281 theta = atan(r0/PS_AU) * tan(deflection); 282 282 phi = sqrt( deflection*deflection - theta*theta ); 283 a ctual->r = theta;284 a ctual->d = phi;285 psFree(a pparentVector);283 apparent->r = theta; 284 apparent->d = phi; 285 psFree(actualVector); 286 286 psFree(sunVector); 287 return a ctual;287 return apparent; 288 288 } 289 289
Note:
See TracChangeset
for help on using the changeset viewer.
