struct Mass {
LabeledCircle lc;
real m;
-
+
void operator init(pair center=(0,0), real m=1, real radius=2mm,
pen outline=currentpen, pen fill=grey, Label L="") {
this.lc.operator init(center=center, radius=radius, outline=outline,
fill=fill, L=L);
this.m = m;
}
-
+
pair center() { return this.lc.center; }
void set_center(pair center) { this.lc.center = center; }
void draw(picture pic=currentpicture) = this.lc.draw;
pen outline;
pen fill;
Label L;
-
+
void operator init(pair center=(0,0), real m=1, real width=5mm, real height=-1, real direction=0, pen outline=currentpen, pen fill=grey, Label L="") {
this.center = center;
this.m = m;
this.fill = fill;
this.L = L;
}
-
+
void draw(picture pic=currentpicture) {
picture picF;
path c = rotate(direction)*scale(width,height)*shift(-.5,-.5)*unitsquare;
real scale;
pen outline;
Label label;
-
+
void operator init(pair pFrom=(0,0), pair pTo=(5mm,0), real offset=0, real scale=5mm, pen outline=currentpen, Label L="") {
this.pFrom = pFrom;
this.pTo = pTo;
this.fill = fill;
this.label = L;
}
-
+
void draw(picture pic=currentpicture) {
picture picF;
bool direction;
-
+
real ccw_angle = degrees(C-A)-degrees(B-A);
bool direction = CCW;
if (ccw_angle < 0) ccw_angle += 360.0;
pen filla;
pen fillb;
Label L;
-
+
void operator init(pair pFrom=(0,0), pair pTo=(5mm,0), real thickness=5mm, pen outline=currentpen, pen filla=rgb(.5,.5,.5), pen fillb=rgb(.7,.7,.7), Label L="") {
this.pFrom = pFrom;
this.pTo = pTo;
this.fillb = fillb;
this.L = L;
}
-
+
void draw(picture pic=currentpicture, bool rotateLabel=true) {
picture picF;
picture picL;
int nLoops;
pen outline;
Label L;
-
+
void operator init(pair pFrom=(0,0), pair pTo=(5mm,0), real k=1, real width=3mm, real dLength=1mm, real deadLength=3mm, real unstretchedLength=12mm, pen outline=currentpen, Label L="") {
this.pFrom = pFrom;
this.pTo = pTo;
this.nLoops = 1;
this.deadLength = (unstretchedLength-this.nLoops*dLength)/2;
}
-
+
void draw(picture pic=currentpicture, bool rotateLabel=true) {
picture picF;
picture picL;
label(picL, L);
pair pLabelSize = 1.2 * (max(picL)-min(picL));
pair pDiff = pTo - pFrom;
-
+
real working_dLength = (length(pDiff) - 2*deadLength) / nLoops;
path p = (0,0)--(deadLength,0);
path loop = (0,0)
loopStart = point(p, length(p));
p = p--(loopStart+(deadLength,0));
p = rotate(degrees(pDiff)) * p;
-
+
pair label_rotate=pDiff;
if (rotateLabel == false)
label_rotate=(1,0);