Normand Briere
2019-08-12 b1d79b74514041a059b454a9f6fc3970773c0cb8
Torus.java
....@@ -2,6 +2,8 @@
22
33 class Torus extends Biparam implements java.io.Serializable
44 {
5
+ static final long serialVersionUID = -7637054329820073252L; // Old
6
+
57 Torus()
68 {
79 inPnt = new cVector();
....@@ -54,6 +56,11 @@
5456 buffer.append("}\n");
5557 }
5658
59
+ double uStretch()
60
+ {
61
+ return 6; // Actually 6.28 (I think)
62
+ }
63
+
5764 Vertex biparamFunction(double u, double v)
5865 {
5966 if (u == 1)
....@@ -62,7 +69,7 @@
6269 v = 0;
6370
6471 double uAng = u * 2 * Math.PI;
65
- double vAng = v * 2 * Math.PI;
72
+ double vAng = -v * 2 * Math.PI;
6673 double cosua = Math.cos(uAng);
6774 double sinua = Math.sin(uAng);
6875 double cosva = Math.cos(vAng);
....@@ -85,6 +92,9 @@
8592 //temp.pos = tPos; // useless new
8693 temp.norm = tNorm;
8794 LA.vecNormalize(temp.norm);
95
+
96
+ temp.y += minor;
97
+
8898 return temp;
8999 }
90100
....@@ -116,55 +126,59 @@
116126 return rad2 <= minor * minor;
117127 }
118128
119
- void drawEditHandles(ClickInfo info, int level)
129
+ void drawEditHandles(//ClickInfo info,
130
+ int level)
120131 {
121132 if (level == 0)
122133 {
123134 return;
124135 } else
125136 {
126
- super.drawEditHandles(info, level);
137
+ super.drawEditHandles(//info,
138
+ level);
127139 cVector temp = LA.newVector(0, 0, minor);
128140 LA.xformPos(temp, toParent, temp);
129
- Rectangle majorSpot = calcHotSpot(temp, info);
141
+ Rectangle majorSpot = calcHotSpot(temp); //, info);
130142 majorSpot.translate(4, 4);
131143 temp.x = major;
132144 temp.y = temp.z = 0;
133145 LA.xformPos(temp, toParent, temp);
134
- Rectangle minorSpot = calcHotSpot(temp, info);
146
+ Rectangle minorSpot = calcHotSpot(temp); //, info);
135147 minorSpot.translate(4, 4);
136
- info.g.setColor(Color.green);
137
- info.g.fillRect(majorSpot.x, majorSpot.y, majorSpot.width, majorSpot.height);
138
- info.g.fillRect(minorSpot.x, minorSpot.y, minorSpot.width, minorSpot.height);
148
+ clickInfo.g.setColor(Color.green);
149
+ clickInfo.g.fillRect(majorSpot.x, majorSpot.y, majorSpot.width, majorSpot.height);
150
+ clickInfo.g.fillRect(minorSpot.x, minorSpot.y, minorSpot.width, minorSpot.height);
139151 return;
140152 }
141153 }
142154
143
- boolean doEditClick(ClickInfo info, int level)
155
+ boolean doEditClick(//ClickInfo info,
156
+ int level)
144157 {
145158 if (level == 0)
146159 return false;
147160 hitSomething = 0;
148
- if (super.doEditClick(info, level))
161
+ if (super.doEditClick(//info,
162
+ level))
149163 {
150164 hitSomething = 1;
151165 return true;
152166 }
153167 cVector temp = LA.newVector(0, 0, minor);
154168 LA.xformPos(temp, toParent, temp);
155
- Rectangle majorSpot = calcHotSpot(temp, info);
169
+ Rectangle majorSpot = calcHotSpot(temp); //, info);
156170 majorSpot.translate(4, 4);
157171 temp.x = major;
158172 temp.y = temp.z = 0;
159173 LA.xformPos(temp, toParent, temp);
160
- Rectangle minorSpot = calcHotSpot(temp, info);
174
+ Rectangle minorSpot = calcHotSpot(temp); //, info);
161175 minorSpot.translate(4, 4);
162
- if (majorSpot.contains(info.x, info.y))
176
+ if (majorSpot.contains(clickInfo.x, clickInfo.y))
163177 {
164178 hitSomething = 2;
165179 startRad = major;
166180 } else
167
- if (minorSpot.contains(info.x, info.y))
181
+ if (minorSpot.contains(clickInfo.x, clickInfo.y))
168182 {
169183 hitSomething = 3;
170184 startRad = minor;
....@@ -172,23 +186,25 @@
172186 {
173187 return false;
174188 }
175
- startX = info.x;
189
+ startX = clickInfo.x;
176190 return true;
177191 }
178192
179
- void doEditDrag(ClickInfo info, boolean opposite)
193
+ void doEditDrag(//ClickInfo info,
194
+ boolean opposite)
180195 {
181196 if (hitSomething == 0)
182197 return;
183198 if (hitSomething == 1)
184199 {
185
- super.doEditDrag(info, opposite);
200
+ super.doEditDrag(//info,
201
+ opposite);
186202 return;
187203 }
188
- double deltaR = info.x - startX;
204
+ double deltaR = clickInfo.x - startX;
189205 //cVector delta = LA.newVector(info.x - startX, 0, 0);
190206 //LA.xformDir(delta, info.camera.fromScreen, delta);
191
- deltaR /= 100 * info.camera.SCALE / info.camera.Distance();
207
+ deltaR /= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
192208 double newRad = startRad + deltaR;
193209 if (newRad < 0)
194210 newRad = 0;
....@@ -197,7 +213,7 @@
197213 else
198214 minor = newRad;
199215 recalculate();
200
- info.pane.repaint();
216
+ clickInfo.pane.repaint();
201217 }
202218
203219 double major;