|
7 | 7 | import cnuphys.adaptiveSwim.geometry.Line; |
8 | 8 | import cnuphys.adaptiveSwim.geometry.Point; |
9 | 9 | import cnuphys.adaptiveSwim.geometry.Vector; |
| 10 | +import cnuphys.adaptiveSwim.geometry.Sphere; |
| 11 | +import cnuphys.adaptiveSwim.geometry.Cylinder; |
10 | 12 |
|
11 | 13 | import cnuphys.adaptiveSwim.AdaptiveSwimException; |
12 | 14 | import cnuphys.adaptiveSwim.AdaptiveSwimResult; |
13 | 15 | import cnuphys.adaptiveSwim.AdaptiveSwimmer; |
| 16 | +import cnuphys.adaptiveSwim.geometry.Plane; |
14 | 17 |
|
15 | 18 | import cnuphys.swim.SwimTrajectory; |
16 | 19 |
|
@@ -60,8 +63,8 @@ public double[] SwimGenCylinder(Point3D axisPoint1, Point3D axisPoint2, double r |
60 | 63 | Point a2 = new Point(axisPoint2.x()/100, axisPoint2.y()/100, axisPoint2.z()/100); |
61 | 64 | Line centerLine = new Line(a1, a2); |
62 | 65 |
|
63 | | - cnuphys.adaptiveSwim.geometry.Cylinder targetCylinder = new cnuphys.adaptiveSwim.geometry.Cylinder(centerLine, radius); |
64 | | - |
| 66 | + Cylinder targetCylinder = new Cylinder(centerLine, radius); |
| 67 | + |
65 | 68 | try { |
66 | 69 |
|
67 | 70 | AdaptiveSwimResult result = new AdaptiveSwimResult(false); |
@@ -98,7 +101,7 @@ public double[] SwimPlane(Vector3D n, Point3D p, double accuracy) { |
98 | 101 | Vector norm = new Vector(n.asUnit().x(), n.asUnit().y(), n.asUnit().z()); |
99 | 102 | Point point = new Point(p.x()/100, p.y()/100, p.z()/100); |
100 | 103 |
|
101 | | - cnuphys.adaptiveSwim.geometry.Plane targetPlane = new cnuphys.adaptiveSwim.geometry.Plane(norm, point); |
| 104 | + Plane targetPlane = new Plane(norm, point); |
102 | 105 |
|
103 | 106 | try { |
104 | 107 | AdaptiveSwimResult result = new AdaptiveSwimResult(false); |
@@ -128,22 +131,73 @@ public double[] SwimPlane(Vector3D n, Point3D p, double accuracy) { |
128 | 131 |
|
129 | 132 | @Override |
130 | 133 | public double[] SwimToSphere(double Rad) { |
131 | | - throw new UnsupportedOperationException("Not supported yet."); |
132 | | - } |
133 | 134 |
|
134 | | - @Override |
135 | | - public double[] SwimToPlaneBoundary(double d_cm, Vector3D n, int dir) { |
136 | | - throw new UnsupportedOperationException("Not supported yet."); |
137 | | - } |
| 135 | + double[] value = new double[8]; |
138 | 136 |
|
139 | | - @Override |
140 | | - public double[] SwimToBeamLine(double xB, double yB) { |
141 | | - throw new UnsupportedOperationException("Not supported yet."); |
| 137 | + // convert to meters: |
| 138 | + |
| 139 | + Sphere targetSphere = new Sphere(new Point(0,0,0), Rad/100); |
| 140 | + |
| 141 | + try { |
| 142 | + AdaptiveSwimResult result = new AdaptiveSwimResult(false); |
| 143 | + |
| 144 | + PC.AS.swimSphere(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, targetSphere, |
| 145 | + accuracy/100, _rMax, stepSize, cnuphys.swim.Swimmer.getEps(), result); |
| 146 | + |
| 147 | + if(result.getStatus() == AdaptiveSwimmer.SWIM_SUCCESS) { |
| 148 | + value[0] = result.getUf()[0] * 100; // convert back to cm |
| 149 | + value[1] = result.getUf()[1] * 100; // convert back to cm |
| 150 | + value[2] = result.getUf()[2] * 100; // convert back to cm |
| 151 | + value[3] = result.getUf()[3] * _pTot; // normalized values |
| 152 | + value[4] = result.getUf()[4] * _pTot; |
| 153 | + value[5] = result.getUf()[5] * _pTot; |
| 154 | + value[6] = result.getFinalS() * 100; |
| 155 | + value[7] = 0; // Conversion from kG.m to T.cm |
| 156 | + } |
| 157 | + else { |
| 158 | + return null; |
| 159 | + } |
| 160 | + |
| 161 | + } catch (AdaptiveSwimException e) { |
| 162 | + e.printStackTrace(); |
| 163 | + } |
| 164 | + return value; |
142 | 165 | } |
143 | 166 |
|
144 | 167 | @Override |
145 | 168 | public double[] SwimToLine(Line3D l) { |
146 | | - throw new UnsupportedOperationException("Not supported yet."); |
| 169 | + |
| 170 | + double[] value = new double[8]; |
| 171 | + |
| 172 | + // convert to meters: |
| 173 | + Point a1 = new Point(l.origin().x()/100, l.origin().y()/100, l.origin().z()/100); |
| 174 | + Point a2 = new Point(l.end().x()/100, l.end().y()/100, l.end().z()/100); |
| 175 | + Line targetLine = new Line(a1, a2); |
| 176 | + |
| 177 | + try { |
| 178 | + AdaptiveSwimResult result = new AdaptiveSwimResult(false); |
| 179 | + |
| 180 | + PC.AS.swimLine(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, targetLine, |
| 181 | + accuracy/100, _rMax, stepSize, cnuphys.swim.Swimmer.getEps(), result); |
| 182 | + |
| 183 | + if(result.getStatus() == AdaptiveSwimmer.SWIM_SUCCESS) { |
| 184 | + value[0] = result.getUf()[0] * 100; // convert back to cm |
| 185 | + value[1] = result.getUf()[1] * 100; // convert back to cm |
| 186 | + value[2] = result.getUf()[2] * 100; // convert back to cm |
| 187 | + value[3] = result.getUf()[3] * _pTot; // normalized values |
| 188 | + value[4] = result.getUf()[4] * _pTot; |
| 189 | + value[5] = result.getUf()[5] * _pTot; |
| 190 | + value[6] = result.getFinalS() * 100; |
| 191 | + value[7] = 0; // Conversion from kG.m to T.cm |
| 192 | + } |
| 193 | + else { |
| 194 | + return null; |
| 195 | + } |
| 196 | + |
| 197 | + } catch (AdaptiveSwimException e) { |
| 198 | + e.printStackTrace(); |
| 199 | + } |
| 200 | + return value; |
147 | 201 | } |
148 | 202 |
|
149 | 203 | @Override |
|
0 commit comments