1 package org.lcsim.recon.tracking.spacegeom; 2 /** A differential path element vector ds in Cartesian, 3 * cylindrical or spherical coordinates. It is constructed using a 4 * subclass and then elements can be fetched for any of these coordinate 5 * systems. The stored vector can also include scalar quantities. 6 * Typical applications include velocity ds/dt and direction ds/d|s|. 7 *<p> 8 * Transformations (translations, rotations, etc) are not provided. 9 * It is expected these will be carried out by external functions which 10 * return new SpacePath objects. 11 * 12 *<p> 13 * Three orthogonal coordinate systems are: 14 *<ul> 15 *<li> Cartesian: (x, y, z) 16 *<li> Cylindrical: (rxy, phi, z) 17 *<li> Spherical: (rxyz, theta, phi) . 18 *</ul> 19 * These coordinates may be obtained via the space point interface. 20 * 21 *<p> 22 * The corresponding path element vectors are: 23 *<ul> 24 *<li> Cartesian: (dx, dy, dz) 25 *<li> Cylindrical: (drxy, rxy*dphi, dz) 26 *<li> Spherical: (drxyz, rxyz*dtheta, rxy*dphi) . 27 *</ul> 28 * These elements may be accessed via the usual space vector interface 29 * (v_x(), v_y(), ...) or via the methods defined here. 30 *<p> 31 *@author Norman A. Graf 32 *@version 1.0 33 * 34 */ 35 public class SpacePath extends SpacePointVector 36 { 37 38 // methods 39 40 /** Default constructor. 41 * 42 */ 43 public SpacePath( ) 44 { 45 super(); 46 } 47 48 /** Copy onstructor from a space point. 49 * @param spt the Spacepoint to replicate 50 */ 51 public SpacePath( SpacePoint spt ) 52 { 53 super(spt); 54 } 55 56 /** Constructor from a space vector. 57 * @param svec the SpacePointVector from which to contruct 58 */ 59 public SpacePath( SpacePointVector svec ) 60 { 61 super(svec); 62 } 63 64 /** 65 * Sets the origin of the path 66 * @param p point in space 67 */ 68 public void setOrigin(SpacePoint p) { 69 _x = p._x; 70 _y = p._y; 71 _z = p._z; 72 _xy = p._xy; 73 _xyz = p._xyz; 74 _phi = p._phi; 75 _theta = p._theta; 76 } 77 78 /** 79 * Sets the end point of the path 80 * @param p point in space 81 */ 82 public void setEndPoint(SpacePoint p) { 83 _vx = p._x - _x; 84 _vy = p._y - _y; 85 _vz = p._z - _z; 86 } 87 88 /** 89 * Returns the origin of the path 90 * @return a new SpacePoint object at the origin 91 */ 92 public SpacePoint origin() { 93 return new CartesianPoint(_x, _y, _z); 94 } 95 96 /** 97 * Returns the end point of the path 98 * @return a new SpacePoint object at the end of the path 99 */ 100 public SpacePoint endPoint() { 101 return new CartesianPoint(_x+_vx, _y+_vy, _z+_vz); 102 } 103 104 105 /** Cartesian dx. 106 * @return delta x 107 */ 108 public double dx( ) 109 { 110 return v_x(); 111 } 112 113 /** Cartesian dy. 114 * @return delta y 115 */ 116 public double dy( ) 117 { 118 return v_y(); 119 } 120 121 /** Cartesian or cylindrical dz. 122 * @return Cartesian or cylindrical dz. 123 */ 124 public double dz( ) 125 { 126 return v_z(); 127 } 128 129 /** Cylindrical drxy. 130 * Can be well defined at rxy=0. 131 * @return Cylindrical dradius 132 */ 133 public double drxy( ) 134 { 135 return v_rxy(); 136 } 137 138 /** Cylindrical or spherical rxy*dphi. 139 * Can be well defined at rxy=0. 140 * @return radius*dphi (2d radius) 141 */ 142 public double rxy_dphi( ) 143 { 144 return v_phi(); 145 } 146 147 /** Cylindrical or spherical dphi. 148 * Not well defined at rxy=0. 149 * @return dphi (not well defined at r=0) 150 */ 151 public double dphi( ) 152 { 153 return v_phi()/v_rxy(); 154 } 155 156 /** Spherical rxyz. 157 * Can be well defined at rxyz=0. 158 * @return spherical radius 159 */ 160 public double drxyz( ) 161 { return v_rxyz(); } 162 163 /** Spherical rxyz*dtheta. 164 * Can be well defined at rxyz=0. 165 * @return spherical radius*dtheta 166 */ 167 public double rxyz_dtheta( ) 168 { 169 return v_theta(); 170 } 171 172 /** Spherical dtheta. 173 * Not well defined at rxyz=0; 174 * @return Spherical dtheta. 175 */ 176 public double dtheta( ) 177 { 178 return v_theta()/v_rxyz(); 179 } 180 181 182 /** Output stream 183 * 184 * 185 * @return String representation of the object 186 */ 187 public String toString() 188 { 189 return super.toString() 190 + "SpacePath: " + "\n" 191 + " dx: " + dx() + "\n" 192 + " dy: " + dy() + "\n" 193 + " dz: " + dz() + "\n" 194 + " drxy: " + drxy() + "\n" 195 + " drxyz: " + drxyz() + "\n" 196 + " rt*dphi: " + rxy_dphi() + "\n" 197 + " r*dtheta: " + rxyz_dtheta() + "\n" 198 + "Magnitude: " + magnitude() + "\n"; 199 } 200 201 } 202