pair uty; // unit vector pointing distally at the tip
pair utx; // unit vector pointing tip-side at the tip
-
+
pair base; // location of the cantilever base (chip attachment point)
pair uy; // unit vector pointing distally at the base
real theta; // in radians
real r_curve;
-
+
void align_tip(pair tip) {
// shift the whole cantilever setup so the tip rests on TIP.
pair offset = tip - this.tip;
} else {
real first_order_theta = 2.0*dx/this.arm_length;
this.theta = newton(this.dx_error, this.dx_prime,
- 0.1 * first_order_theta,
- min(3.0 * first_order_theta, pi/2.0));
+ 0.1 * first_order_theta,
+ min(3.0 * first_order_theta, pi/2.0));
/* because we ignored tip_height when we calculated theta, cheat a
* bit and pretend the tip is directly under our caculated
* tip_top. Then adjust tip_top accordingly. This throws off the
real arrow_length = this.piezo_height/3;
pair arrow_center = piezo_bot + (0, arrow_length/2 + 2pt);
arrow(b=arrow_center + dir*arrow_length/2, dir=-dir,
- length=this.piezo_height/3, Arrow(size=8pt),
- margin=NoMargin, L="");
+ length=this.piezo_height/3, Arrow(size=8pt),
+ margin=NoMargin, L="");
}
}
pair center;
real radius = 8pt;
real x_scale = 0.5;
-
+
void draw(pen fillpen=grey, pen drawpen=defaultpen) {
pair c = this.center;
pair y = (0, this.radius);
pair x = (this.x_scale*this.radius, 0);
filldraw(shift(this.center)*xscale(this.x_scale)*scale(this.radius)
- *unitcircle, fillpen, drawpen);
+ *unitcircle, fillpen, drawpen);
draw((c-x)--(c+x)--c--(c-y)--(c+y), drawpen);
}
// find direction of reflection post-cantilever
pair post_dir = reflect((0,0), this.cantilever.uty)*dir;
pair contact = extension(ref, ref+post_dir,
- this.photodiode.center,
- this.photodiode.center+N);
+ this.photodiode.center,
+ this.photodiode.center+N);
real contact_width = this.width; ///length(ref-this.start)*length(ref-contact);
pair cw = scale(contact_width)*rotate(90)*post_dir;
if (dot(cw, rw) < 0) cw = -cw; // ensure similar direction
}
void operator init(pair start, pair dir=S, Cantilever cantilever,
- Photodiode photodiode) {
+ Photodiode photodiode) {
this.start = start;
this.dir = unit(dir);
this.cantilever = cantilever;
triple up = (0, 1, 0.4); // up, but tilted out of the page
real theta = -20;
pair[][] pips;
-
+
int right() {
/* It is traditional to combine pairs of numbers that total seven
* to opposite faces; this implies that at one vertex the faces 1,
for (int i=0; i < length(face_coords); ++i) {
p = this.transform(point(face_coords, i), face_x, face_y);
if (i == 0) {
- g = g--p;
+ g = g--p;
} else {
- c = controlSpecifier(face_coords, i-1); // {outgoing, incoming)
- c[0] = this.transform(c[0], face_x, face_y);
- c[1] = this.transform(c[1], face_x, face_y);
- g = g..controls c[0] and c[1]..p;
+ c = controlSpecifier(face_coords, i-1); // {outgoing, incoming)
+ c[0] = this.transform(c[0], face_x, face_y);
+ c[1] = this.transform(c[1], face_x, face_y);
+ g = g..controls c[0] and c[1]..p;
}
}
if (cyclic(face_coords)) {
void draw_pip(pair z, triple face_x, triple face_y) {
fill(this.transform(shift(z)*scale(this.dot_ratio/2.0)*unitcircle,
- face_x, face_y));
+ face_x, face_y));
}
/* azimuth = 0, elevation=90 -> facing up
*/
void draw_face(int number, triple face_x, triple face_y) {
filldraw(this.transform(shift((-0.5,-0.5))*unitsquare, face_x, face_y),
- white);
+ white);
for (pair z : this.pips[number])
this.draw_pip(z, face_x, face_y);
}
}
Door L = Door((-2cm,0),
- L=minipage("\centering{\Large Unfold}\\$P=0.\bar{3}$\\(\epsdice{1}\epsdice{2})"));
+ L=minipage("\centering{\Large Unfold}\\$P=0.\bar{3}$\\(\epsdice{1}\epsdice{2})"));
Door R = Door((2cm,0),
- L=minipage("\centering{\Large Stay folded}\\$Q=1-P$\\(\epsdice{3}\epsdice{4}\epsdice{5}\epsdice{6})"),
- angle=30);
+ L=minipage("\centering{\Large Stay folded}\\$Q=1-P$\\(\epsdice{3}\epsdice{4}\epsdice{5}\epsdice{6})"),
+ angle=30);
Die d = Die((-0.3cm, -2.5cm), top=3, left=5);
L.draw();