# Wrj4P5

### Latest File Release

 l4P5 (beta-003) 2009-05-05 20:38 Loc (beta-005) 2009-05-05 20:33 wrj4p5 (alpha-011) 2009-05-05 20:41

## ClassLoc - the model of 3D-Location and/or 3D-Vector

` /*[class] Loc              5/1/2006 by Classiclll                           6/24/2006 modified                           6/6/2007 Librarized.  the model of geometric point with location and geometric calculations. */  [members]  float x, y, z;//location of 3D space.  double TOL;  common tolerance constant    [constructer]  Loc(float lx, float ly, float lz)//construct a Loc object with 3D location.  Loc(Loc l)             //cloninng  Loc(float lng, float ltt) //construct UnitVector with Polar expression.    [methods]  <group #0 - Generator>  static Loc newLoc(float x, float y, float z)//same as 'new Loc(x,y,z)'  static Loc newPolar(float r, float lng, float ltt)               //get the new Loc at (r,longitude,latitude)    <group #1 - Scalar result - without Side Effect>  float longitude()                  //get longitude of me  float latitude()                   //get latitude of me  float dist(float tx, float ty, float tz)              //measure the distance to (xtx,ty,tz). (euclid distance)   float dist(Loc loc)       //measure the distance to loc. (euclid distance)  float dist1(Loc loc)      //measure the distance to loc. (manhattan distance)  float dist2(Loc loc       //measure square of the distance. (euclid distance)  float norm()        //get measure the norm of me. = sqrt(sq(x)+sq(y)+sq(z))  float innerP(Loc l)       //get the inner production of l, same to dot().  float dot(Loc to)         //dot operator, = norm(me)*norm(l)*cos(angle)  float cosine(Loc l)  //get cosine between l and me. = dot/(norm(me)+norm(l))  float angle(Loc l)   //get angle(-PI~PI) between me&l, = acos(me.cosine(l))  boolean isSameGrid(Loc to) //Am "I" on the same Grid Point to "to"?  boolean isEqualTo(Loc to)  //Am "I" the same location to "to"?  boolean isNearTo(Loc to)   //Am "I" near to "to"? (based on euclid distance)  boolean isNearTo(Loc to, float tol)             // Am "I" near to "to"? (based on euclid distance)  boolean isNear1To(Loc to)//Am "I" near to "to"? (based on manhattan distance)  boolean isNear1To(Loc to, float tol)              // Am "I" near to "to"? (based on manhattan distance)  boolean isWithin(Loc another, float tol)               // Is "another" in the range "tol" from me?(fast)  String toString()                //get the string expression by axis.    <group #2 - Vector result - without Side Effect>  Loc clone()             //newLoc having same location of me  Loc getPlar()           //newLoc having a polar coord of me (r,lg,lt)  Loc getPlarDiff(Loc to)//newLoc having a polar coord diff bet "me" to "to"  Loc getPlarDiff(float dx, float dy, float dz)             //newLoc having a polar coord diff  Loc add(Loc off)    //newLoc equl to me + ofst (elementwise - Loc ver.)  Loc add(float dx, float dy, float dz)               //newLoc equl to me + ofst (elementwise - float ver.)  Loc sub(Loc off)    //newLoc equl to me - ofst (elementwise - Loc ver.)  Loc sub(float dx, float dy, float dz)               //newLoc equl to me - ofst (elementwise - float ver.)  Loc inv()           //newLoc equl to inverse direction of me.   Loc mul(float fact)   //newLoc equl to scalar production of me.  Loc mul(Loc fact)   //newLoc equl to elementwise scalar production of me.  Loc div(float fact)   //newLoc equl to scalar division of me.  Loc div(Loc fact)   //newLoc equl to elementwise scalar division of me.  Loc projection(Loc dirX, Loc dirY, Loc dirZ)              //newLoc projected to the space spaned by given 3-dir's  Loc outerP(Loc l)    //newLoc equl to outer production, same to cross().  Loc cross(Loc to)    //cross operator,  get newLoc orthogonal to me and l  Loc unit()        //newLoc equl to unit vector allong to me.( norm(v)=1 )   Loc dir(Loc l)       //newLoc equl to direction vector from me to Loc l.  Loc ortho(Loc l)     //newLoc orthogonal unit vector from l to me.  Loc turned(Loc shaft, float angle)              //newLoc turned arround the direction of 'shaft' vector  Loc turned(float pan, float swing, float tilt)               //newLoc turned to pan(Zax)->swing(Yax)->tilt(Xax).  Loc turnedZ(float pan) //newLoc turned arround Zax of the World coordinate.  Loc turnedY(float swing)//newLoc turned arround Yax of the World coordinate.  Loc turnedX(float tilt) //newLoc turned arround Xax of the World coordinate.   <group #3 - Vector result - with Self Side Effect>  Loc movePolar(float r, float lng, float ltt)              //move me to Polar loc at (r,longi,latti)  Loc shiftPolar(float r, float lng, float ltt)              //shift me to Polar dir with (r,longi,latti)  Loc move(float dx, float dy, float dz)              //move me to another location. (float ver.)  Loc move(Loc pos)         //move me to another location. (Loc ver.)  Loc shift(float dx, float dy, float dz)              //shift me from current to offset location.  Loc shift(Loc dlt)    //shift me from current to offset location.  Loc scale(Loc fact)   //scale me based vector.(multipled elementwise)  Loc scale(float fact) //scale me based scalar.(same for each coordinates)  Loc shiftI(Loc dlt)   //inverse shift me from current to offset location.   Loc scaleI(Loc fact)  //inverse scale me based vector.(devided elementwise)  Loc rotate(Loc shaft, float angle)               //rotate me arround the direction of 'shaft' vector  Loc rotate(float pan, float swing, float tilt)               //rotate me to pan(Zax)->swing(Yax)->tilt(Xax).  Loc rotateZ(float pan) //rotate me to pan(arround Z of the World coordinate).  Loc rotateY(float swing)//rotate me to swing(arround Y of the World coord.).  Loc rotateX(float tilt) //rotate me to tilt(arround X of the World coord.).`