Changeset 6534 for trunk/psLib/src/astro/psSphereOps.c
- Timestamp:
- Mar 6, 2006, 3:53:24 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astro/psSphereOps.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psSphereOps.c
r6309 r6534 8 8 * @author Dave Robbins, MHPCC 9 9 * 10 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-0 2-02 23:19:58$10 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-03-07 01:53:24 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 39 39 } 40 40 41 static psSphereRot* sphereRotAlloc(void) 42 { 43 psSphereRot *sphereRot = (psSphereRot* ) psAlloc(sizeof(psSphereRot)); 44 psMemSetDeallocator(sphereRot, (psFreeFunc)sphereRotFree); 45 return (sphereRot); 46 } 47 41 48 psSphereRot* psSphereRotAlloc(double alphaP, 42 49 double deltaP, 43 50 double phiP) 44 51 { 45 psSphereRot r,s,t; 52 psSphereRot *r = sphereRotAlloc(); 53 psSphereRot *s = sphereRotAlloc(); 54 psSphereRot *t = sphereRotAlloc(); 55 46 56 //The following represents: r =a rotation about the z-axis by alphaP, s =a rotation about 47 57 // the y-axis by deltaP, and t =a rotation about the z-axis by phiP. 48 r .q0=0;49 r .q1=0;50 r .q2=sin(alphaP/2.0);51 r .q3=cos(alphaP/2.0);52 53 s .q0=0;54 s .q1=sin(deltaP/2.0);55 s .q2=0;56 s .q3=cos(deltaP/2.0);57 58 t .q0=0;59 t .q1=0;60 t .q2=sin(phiP/2.0);61 t .q3=cos(phiP/2.0);58 r->q0=0; 59 r->q1=0; 60 r->q2=sin(alphaP/2.0); 61 r->q3=cos(alphaP/2.0); 62 63 s->q0=0; 64 s->q1=sin(deltaP/2.0); 65 s->q2=0; 66 s->q3=cos(deltaP/2.0); 67 68 t->q0=0; 69 t->q1=0; 70 t->q2=sin(phiP/2.0); 71 t->q3=cos(phiP/2.0); 62 72 63 73 // calculate t*s*r. 64 psSphereRot* temp = psSphereRotCombine(NULL, &t,&s);65 psSphereRot* result = psSphereRotCombine(NULL, temp, &r);74 psSphereRot* temp = psSphereRotCombine(NULL,t,s); 75 psSphereRot* result = psSphereRotCombine(NULL, temp, r); 66 76 psFree(temp); 67 77 psFree(r); 78 psFree(s); 79 psFree(t); 68 80 return result; 69 81 } … … 83 95 { 84 96 //allocate space for a new sphere rotation and set deallocator 85 psSphereRot* rot = (psSphereRot*)psAlloc(sizeof(psSphereRot)); 86 psMemSetDeallocator(rot, (psFreeFunc)sphereRotFree); 97 psSphereRot* rot = sphereRotAlloc(); 87 98 88 99 //The magnitude of a rotation quaternion should = 1 so we normalize here in case the … … 108 119 //if output sphere rotation is NULL, allocate a new sphere rotation to return 109 120 if (out == NULL) { 110 out = (psSphereRot* ) psAlloc(sizeof(psSphereRot)); 111 psMemSetDeallocator(out, (psFreeFunc)sphereRotFree); 121 out = sphereRotAlloc(); 112 122 } 113 123 //Since q3 is the magnitude and q0,q1,q2 are direction, the conjugate rotation … … 173 183 //If output rotation is NULL, allocate a new psSphereRot to return 174 184 if (out == NULL) { 175 out = (psSphereRot* ) psAlloc(sizeof(psSphereRot)); 176 psMemSetDeallocator(out, (psFreeFunc)sphereRotFree); 185 out = sphereRotAlloc(); 177 186 } 178 187
Note:
See TracChangeset
for help on using the changeset viewer.
