-
Notifications
You must be signed in to change notification settings - Fork 6
/
cvt_main.html
775 lines (674 loc) · 25.9 KB
/
cvt_main.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
<!-- Can Update with the equations as used in Acceleration Analysis File -->
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>SOLVE - Mechanics of Machines Lab - CVT</title>
<!-- DND-Required css and js files -->
<link rel="stylesheet" href="sins/MOMstyle.css" />
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'></script>
<script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js'></script>
<script type="text/javascript" src= "sins/MOMscript.js"></script>
<script type="text/javascript" >
//Script specific to simulation
//program variables
//controls section
var simstatus=0;
var rotstatus=1;
//comments section
var commenttext="Some Text";
var commentloc=0;
//computing section
var trans= new point(100,250);
var o= new point(0,0,"");
var a= new point(0,0,"");
var b= new point(0,0,"");
var c=new point(380,125,"")
var c1=new point(380,325,"")
var d=new point(0,0,"");
var d1=new point(0,0,"");
var a1=new point(0,0,"")
var o1=new point(0,0,"")
var b1=new point(0,0,"")
//var d= new point(0,0,"D");
var theta2=0;
var theta1=0; // all angles to be defined either in degrees only or radians only throughout the program and convert as and when required
var phi=0;
var phi1=0;// All angles in Degrees. (mention the specification in the script like here)
var omega2=1;
var omega1=1;
var R2=0;
var k1=0;
var k2=0;
// angular velocity in rad/s
//var omega3=0, omega4=0;
var r=0,l=0,r1=0,r2=0,rad1,rad2;
var flaggrashof=true;
//graphics section
var canvas;
var ctx;
//timing section
var simTimeId = setInterval("",'1000');
var pauseTime = setInterval("",'1000');
var time=0;
//point tracing section
var ptx = [];
var pty = [];
//click status of legend and quick reference
var legendCS = false;
var quickrefCS = false;
//temporary or dummy variables
var temp=0;
var offset=0;
/*
// for trials during development
function trythis()
{ alert();}
*/
//change simulation specific css content. e.g. padding on top of variable to adjust appearance in variables window
function editcss()
{
$('.variable').css('padding-top','40px');
//$('#legend').css("width",document.getElementById('legendimg').width+"px");
//$('#quickref').css("height",document.getElementById('quickrefimg').height+"px");
}
//start of simulation here; starts the timer with increments of 0.1 seconds
function startsim()
{
simTimeId=setInterval("time=time+0.1; varupdate(); ",'100');
}
// switches state of simulation between 0:Playing & 1:Paused
function simstate()
{
var imgfilename=document.getElementById('playpausebutton').src;
imgfilename = imgfilename.substring(imgfilename.lastIndexOf('/') + 1, imgfilename.lastIndexOf('.'));
if (imgfilename=="bluepausedull")
{
document.getElementById('playpausebutton').src="sins/blueplaydull.png";
clearInterval(simTimeId);
simstatus=1;
$('#theta2spinner').spinner("value",theta2);
$('#theta1spinner').spinner("value",theta1);
//to set simulation parameters on pause
pauseTime=setInterval("varupdate();",'100');
}
if (imgfilename=="blueplaydull")
{
time=0;
clearInterval(pauseTime);
document.getElementById('playpausebutton').src="sins/bluepausedull.png";
simTimeId=setInterval("time=time+0.1; varupdate(); ",'100');
simstatus=0;
}
}
// switches state of rotation between 1:CounterClockWise & -1:Clockwise
function rotstate()
{
var imgfilename=document.getElementById('rotationbutton').src;
imgfilename = imgfilename.substring(imgfilename.lastIndexOf('/') + 1, imgfilename.lastIndexOf('.'));
if (imgfilename=="bluecwdull")
{
document.getElementById('rotationbutton').src="sins/blueccwdull.png";
rotstatus=-1;
}
if (imgfilename=="blueccwdull")
{
document.getElementById('rotationbutton').src="sins/bluecwdull.png";
rotstatus=1;
}
}
/*
//Displaying Equations for Quick Reference
function showEquations()
{
if(quickrefCS)
{
$('#quickreficon').css('border', 'double');
$('#quickref').css('width', '0px');
$('#quickref').css('left', '600px');
$('#quickref').css('border', '0px');
quickrefCS=false;
}
else
{
$('#quickreficon').css('border', 'inset red');
$('#quickref').css('width', document.getElementById('quickrefimg').width+"px");
$('#quickref').css("left", 599-document.getElementById('quickrefimg').width+"px");
$('#quickref').css('border', 'solid 1px');
quickrefCS=true;
}
}
//Displaying Legend
function showLegend()
{
if(legendCS)
{
$('#legendicon').css('border', 'double');
$('#legend').css('height', '0px');
$('#legend').css('border', '0px');
legendCS=false;
}
else
{
$('#legendicon').css('border', 'inset red');
$('#legend').css("height", document.getElementById('legendimg').height+"px");
$('#legend').css('border', 'solid 1px');
legendCS=true;
}
}
*/
//Initialise system parameters here
function varinit()
{
varchange();
//Variable r1 slider and number input types
$('#r1slider').slider("value", 38.2478);
$('#r1spinner').spinner("value",38.2478);
//Variable r2 slider and number input types
$('#r2slider').slider("value", 38.2478);
$('#r2spinner').spinner("value",38.2478);
//Variable r3 slider and number input types
$('#r3slider').slider("value", 100);
$('#r3spinner').spinner("value", 100);
//Variable r4 slider and number input types
//$('#r4slider').slider("value", 60);
//$('#r4spinner').spinner("value", 60);
//Variable theta2 slider and number input types
$('#theta2slider').slider("value", 40);
$('#theta2spinner').spinner("value", 40);
//Variable theta1 slider and number of input types
$('#theta1slider').slider("value", 40);
$('#theta1spinner').spinner("value", 40);
//Variable omega2 slider and number input types
$('#omega2slider').slider("value", 1);
$('#omega2spinner').spinner("value", 1);
}
// Initialise and Monitor variable containing user inputs of system parameters.
//change #id and repeat block for new variable. Make sure new <div> with appropriate #id is included in the markup
function varchange()
{
//Variable r1 slider and number input types
$('#r1slider').slider({ max : 100, min : 25, step : 0.0001 }); // slider initialisation : jQuery widget
$('#r1spinner').spinner({ max : 100, min : 25, step : 0.0001 }); // number initialisation : jQuery widget
// monitoring change in value and connecting slider and number
// setting trace point coordinate arrays to empty on change of link length
$( "#r1slider" ).on( "slide", function( e, ui ) { $('#r1spinner').spinner("value",ui.value); ptx=[]; pty=[]; } );
$( "#r1spinner" ).on( "spin", function( e, ui ) { $('#r1slider').slider("value",ui.value); ptx=[]; pty=[]; } );
$( "#r1spinner" ).on( "change", function() { varchange() } );
//Variable r2 slider and number input types
$('#r2slider').slider({ max : 100, min : 25, step : 0.0001 }); // slider initialisation : jQuery widget
$('#r2spinner').spinner({ max : 100, min : 25, step : 0.0001 }); // number initialisation : jQuery widget
// monitoring change in value and connecting slider and number
// setting trace point coordinate arrays to empty on change of link length
$( "#r2slider" ).on( "slide", function( e, ui ) { $('#r2spinner').spinner("value",ui.value); ptx=[]; pty=[]; } );
$( "#r2spinner" ).on( "spin", function( e, ui ) { $('#r2slider').slider("value",ui.value); ptx=[]; pty=[]; } );
$( "#r2spinner" ).on( "change", function() { varchange() } );
//Variable r3 slider and number input types
$('#r3slider').slider({ max : 240, min : 80, step : 2 }); // slider initialisation : jQuery widget
$('#r3spinner').spinner({ max : 240, min : 80, step : 2 }); // number initialisation : jQuery widget
// monitoring change in value and connecting slider and number
// setting trace point coordinate arrays to empty on change of link length
$( "#r3slider" ).on( "slide", function( e, ui ) { $('#r3spinner').spinner("value",ui.value); ptx=[]; pty=[]; } );
$( "#r3spinner" ).on( "spin", function( e, ui ) { $('#r3slider').slider("value",ui.value); ptx=[]; pty=[]; } );
$( "#r3spinner" ).on( "change", function() { varchange() } );
/*//Variable r4 slider and number input types
$('#r4slider').slider({ max : 100, min : 20, step : 2 }); // slider initialisation : jQuery widget
$('#r4spinner').spinner({ max : 100, min : 20, step : 2 }); // number initialisation : jQuery widget
// monitoring change in value and connecting slider and number
// setting trace point coordinate arrays to empty on change of link length
$( "#r4slider" ).on( "slide", function( e, ui ) { $('#r4spinner').spinner("value",ui.value); ptx=[]; pty=[]; } );
$( "#r4spinner" ).on( "spin", function( e, ui ) { $('#r4slider').slider("value",ui.value); ptx=[]; pty=[]; } );
$( "#r4spinner" ).on( "change", function() { varchange() } );
*/
//Variable theta2 slider and number input types
$('#theta2slider').slider({ max : 360, min : 0, step : 2 }); // slider initialisation : jQuery widget
$('#theta2spinner').spinner({ max : 360, min : 0, step : 2 }); // number initialisation : jQuery widget
// monitoring change in value and connecting slider and number
// setting trace point coordinate arrays to empty on change of link length
$( "#theta2slider" ).on( "slide", function( e, ui ) { $('#theta2spinner').spinner("value",ui.value); ptx=[]; pty=[]; } );
$( "#theta2spinner" ).on( "spin", function( e, ui ) { $('#theta2slider').slider("value",ui.value); ptx=[]; pty=[]; } );
$( "#theta2spinner" ).on( "change", function() { varchange() } );
$('#theta1slider').slider({ max : 360, min : 0, step : 2 }); // slider initialisation : jQuery widget
$('#theta1spinner').spinner({ max : 360, min : 0, step : 2 }); // number initialisation : jQuery widget
// monitoring change in value and connecting slider and number
// setting trace point coordinate arrays to empty on change of link length
$( "#theta1slider" ).on( "slide", function( e, ui ) { $('#theta1spinner').spinner("value",ui.value); ptx=[]; pty=[]; } );
$( "#theta1spinner" ).on( "spin", function( e, ui ) { $('#theta1slider').slider("value",ui.value); ptx=[]; pty=[]; } );
$( "#theta1spinner" ).on( "change", function() { varchange() } );
//Variable omega2 slider and number input types
$('#omega2slider').slider({ max :4, min : 0.25, step : 0.05 }); // slider initialisation : jQuery widget
$('#omega2spinner').spinner({ max : 4, min : 0.25, step : 0.05 }); // number initialisation : jQuery widget
// monitoring change in value and connecting slider and number
// setting trace point coordinate arrays to empty on change of link length
$( "#omega2slider" ).on( "slide", function( e, ui ) { $('#omega2spinner').spinner("value",ui.value); ptx=[]; pty=[]; } );
$( "#omega2spinner" ).on( "spin", function( e, ui ) { $('#omega2slider').slider("value",ui.value); ptx=[]; pty=[]; } );
$( "#omega2spinner" ).on( "change", function() { varchange() } );
varupdate();
}
//Computing of various system parameters
function varupdate()
{
$('#r1slider').slider("value", $('#r1spinner').spinner('value')); //updating slider location with change in spinner(debug)
//$('#r3slider').slider("value", $('#r3spinner').spinner('value'));
$('#theta1slider').slider("value", $('#theta1spinner').spinner('value'));
$('#r2slider').slider("value", $('#r2spinner').spinner('value'));; //updating slider location with change in spinner(debug)
$('#r3slider').slider("value", $('#r3spinner').spinner('value'));
$('#theta2slider').slider("value", $('#theta2spinner').spinner('value'));
//r1=$('#r1spinner').spinner("value");
//r2=$('#r2spinner').spinner("value");
//r2=$()
//r=60;
//l=$('#r3spinner').spinner("value");
//$('#omega2set').hide();
$('#r3slider').slider({max: 6*$('#r2slider').slider('value')});
$('#r3slider').slider({min: 2.5*$('#r2slider').slider('value')});
$('#r3spinner').spinner({max: 6*$('#r2slider').slider('value')});
$('#r3spinner').spinner({min:2.5*$('#r2slider').slider('value')});
if(!simstatus)
{
$('#omega2slider').slider("enable");
$('#omega2spinner').spinner("enable");
$('#r1slider').slider("enable");
$('#r1spinner').spinner("enable");
$('#r2slider').slider("enable");
$('#r2spinner').spinner("enable");
$('#theta2slider').slider("disable");
$('#theta2spinner').spinner("disable");
$('#theta1slider').slider("disable");
$('#theta1spinner').spinner("disable");
omega2=$('#omega2spinner').spinner("value");
R2=omega2/omega1;
R1=omega1/omega2;
k1=(-(1250*Math.PI*(R2+1))+Math.sqrt(1250*Math.PI*(R2+1)*1250*Math.PI*(R2+1)+4*358150*((Math.PI*Math.PI+4)*R2*R2+(Math.PI*Math.PI+4)+((2*Math.PI*Math.PI-8)*R2))))/(2*((Math.PI*Math.PI+4)*R2*R2+(Math.PI*Math.PI+4)+(2*Math.PI*Math.PI-8)*R2));
// k2=-(1250*Math.PI*(R+1))-Math.sqrt((((1250*Math.PI*(R+1))*(1250*Math.PI*(R+1)))+(4*406625*((Math.PI*Math.PI+4)*R*R+(Math.PI*Math.PI+4)+(2*Math.PI*Math.PI-8)*R)))/(2*((Math.PI*Math.PI+4)*R*R+(Math.PI*Math.PI+4)+(2*Math.PI*Math.PI-8)*R)));
// if(k1>0)
// r2=k1;
// else
// r2=k2;
r2=k1;
r1=(omega2/omega1)*r2;
rad1=100*r1/60;
rad2=100*r2/60;
// $('#r1slider').slider("value", rad1);
// $('#r1spinner').spinner("value",rad1);
// $('#r2slider').slider("value", rad2);
// $('#r2spinner').spinner("value",rad2);
// rad2=$('#r1spinner').spinner("value");
// r2=rad2*60/100;
// k2=(-(2*Math.PI*Math.PI-8+1250*Math.PI)*r2+Math.sqrt((2*Math.PI*Math.PI-8+1250*Math.PI)*r2*(2*Math.PI*Math.PI-8+1250*Math.PI)*r2-4*(Math.PI*Math.PI+4)*((Math.PI*Math.PI+4)*r2*r2+1250*Math.PI*r2*r2-358150)))/(2*(Math.PI*Math.PI+4));
// r1=k2;
// rad1=r1*100/60;
// omega2=omega1*r1/r2;
// $('#r1slider').slider("value", rad1);
// $('#r1spinner').spinner("value",rad1);
// $('#omega2slider').slider("value", omega2);
// $('#omega2spinner').spinner("value",omega2);
// rad1=$('#r2spinner').spinner("value");
printcomment("",2);
theta2=theta2+(rotstatus*0.1*deg(omega2));
theta1=theta1+(rotstatus*0.1*deg(omega1));
theta2=theta2%360;
theta1=theta1%360;
if(theta2<0)theta2+=360;
if(theta1<0)theta1+=360;
}
r=60
if(simstatus)
{
$('#theta1slider').slider("enable");
$('#theta1spinner').spinner("enable");
// /*$('#omega2slider').slider("disable");
// $('#omega2spinner').spinner("disable"); */
theta1=$('#theta1spinner').spinner("value");
$('#theta2slider').slider("enable");
$('#theta2spinner').spinner("enable");
$('#omega2slider').slider("disable");
$('#omega2spinner').spinner("disable");
$('#r1slider').slider("disable");
$('#r1spinner').spinner("disable");
$('#r2slider').slider("disable");
$('#r2spinner').spinner("disable");
theta2=$('#theta2spinner').spinner("value");
}
phi1=deg(Math.asin((r*Math.sin(rad(theta1)))));
o.xcoord=d.xcoord-trans.xcoord;
o.ycoord=trans.ycoord-d.ycoord;
a.xcoord=o.xcoord+r*Math.cos(rad(theta1));
a.ycoord=o.ycoord+r*Math.sin(rad(theta1));
b.xcoord=a.xcoord+l*Math.cos(rad(phi1));
b.ycoord=o.ycoord;
phi=deg(Math.asin((r*Math.sin(rad(theta2)))));
o1.xcoord=d1.xcoord-trans.xcoord;
o1.ycoord=trans.ycoord-d1.ycoord;
a1.xcoord=o1.xcoord+r*Math.cos(rad(theta2));
a1.ycoord=o1.ycoord+r*Math.sin(rad(theta2));
b1.xcoord=a1.xcoord+l*Math.cos(rad(phi));
b1.ycoord=o1.ycoord;
r1=(Math.round(r1*100)-Math.round(r1)*100)/100+Math.round(r1);
r2=(Math.round(r2*100)-Math.round(r2)*100)/100+Math.round(r2);
rad1=(Math.round(rad1*100)-Math.round(rad1)*100)/100+Math.round(rad1);
rad2=(Math.round(rad2*100)-Math.round(rad2)*100)/100+Math.round(rad2);
printcomment("<b><u>Output:</u></b>\n r1=" +rad1+"mm , r2="+rad2+"mm ",1);
R1=(Math.round(R1*100)-Math.round(R1)*100)/100+Math.round(R1);
printcomment("gear ratio is : " +R1,2);
draw();
}
//Simulation graphics
function draw()
{
canvas = document.getElementById("simscreen");
ctx = canvas.getContext("2d");
ctx.clearRect(0,0,550,400); //clears the complete canvas#simscreen everytime
pointtrans(o,trans);
pointtrans(a,trans);
pointtrans(b,trans);
pointtrans(o1,trans);
pointtrans(a1,trans);
pointtrans(b1,trans);
ctx.arc(125,120 ,60, 0, 2 * Math.PI);
ctx.strokeStyle= "#000000";
ctx.fillStyle = "#666666";
ctx.fill();
ctx.stroke();
d.xcoord=125;
d.ycoord=120;
pointjoin(d,a,ctx,"#ff0000",12);
pointdisp(d,ctx,15,"#000000","#003366",'','','');
ctx.arc(125,320 ,60, 0, 2 * Math.PI);
ctx.strokeStyle= "#000000";
ctx.fillStyle = "#666666";
ctx.fill();
ctx.stroke();
d1.xcoord=125;
d1.ycoord=320;
pointjoin(d1,a1,ctx,"#CCCC00",12);
pointdisp(d1,ctx,15,"#000000","#003366",'','','');
ctx.closePath();
drawrect(c,200,30,10,ctx,"#003366","#003366",1);
drawrect(c1,200,30,10,ctx,"#003366","#003366",1);
ctx.fillStyle = '#666666';
ctx.strokeStyle= "#000000";
ctx.beginPath();
ctx.moveTo(c.xcoord-(2*r2/3-10),c.ycoord-15);
ctx.lineTo(c.xcoord-30-(2*r2/3-10),c.ycoord-60);
ctx.lineTo(c.xcoord-40-(2*r2/3-10),c.ycoord-60);
ctx.lineTo(c.xcoord-40-(2*r2/3-10),c.ycoord+60);
ctx.lineTo(c.xcoord-30-(2*r2/3-10),c.ycoord+60);
ctx.lineTo(c.xcoord-(2*r2/3-10),c.ycoord+15);
ctx.closePath();
ctx.stroke();
ctx.fill();
ctx.fillStyle = '#666666';
ctx.strokeStyle= "#000000";
ctx.beginPath();
ctx.moveTo(c.xcoord+(2*r2/3-10),c.ycoord-15);
ctx.lineTo(c.xcoord+30+(2*r2/3-10),c.ycoord-60);
ctx.lineTo(c.xcoord+40+(2*r2/3-10),c.ycoord-60);
ctx.lineTo(c.xcoord+40+(2*r2/3-10),c.ycoord+60);
ctx.lineTo(c.xcoord+30+(2*r2/3-10),c.ycoord+60);
ctx.lineTo(c.xcoord+(2*r2/3-10),c.ycoord+15);
ctx.closePath();
ctx.stroke();
ctx.fill();
ctx.fillStyle = '#666666';
ctx.strokeStyle= "#000000";
ctx.beginPath();
ctx.moveTo(c.xcoord+(2*r1/3-10),c.ycoord+185);
ctx.lineTo(c.xcoord+30+(2*r1/3-10),c.ycoord+140);
ctx.lineTo(c.xcoord+40+(2*r1/3-10),c.ycoord+140);
ctx.lineTo(c.xcoord+40+(2*r1/3-10),c.ycoord+260);
ctx.lineTo(c.xcoord+30+(2*r1/3-10),c.ycoord+260);
ctx.lineTo(c.xcoord+(2*r1/3-10),c.ycoord+215);
ctx.closePath();
ctx.stroke();
ctx.fill();
ctx.fillStyle = '#666666';
ctx.strokeStyle= "#000000";
ctx.beginPath();
ctx.moveTo(c.xcoord-(2*r1/3-10),c.ycoord+185);
ctx.lineTo(c.xcoord-30-(2*r1/3-10),c.ycoord+140);
ctx.lineTo(c.xcoord-40-(2*r1/3-10),c.ycoord+140);
ctx.lineTo(c.xcoord-40-(2*r1/3-10),c.ycoord+260);
ctx.lineTo(c.xcoord-30-(2*r1/3-10),c.ycoord+260);
ctx.lineTo(c.xcoord-(2*r1/3-10),c.ycoord+215);
ctx.closePath();
ctx.stroke();
ctx.fill();
ctx.lineWidth=3;
ctx.beginPath();
ctx.moveTo(125+60,120);
ctx.closePath();
ctx.beginPath();
ctx.moveTo(125+r1,120);
ctx.lineTo(125+r2,320);
ctx.stroke()
ctx.moveTo(125-r1,120);
ctx.lineTo(125-r2,320);
ctx.stroke();
ctx.closePath();
ctx.stroke();
ctx.fill();
ctx.lineWidth=3;
ctx.beginPath();
ctx.arc(125,120,r1,-Math.PI,0);
ctx.stroke();
ctx.closePath();
ctx.moveTo(125,320);
ctx.lineWidth=3;
ctx.beginPath();
ctx.arc(125,320,r2,0,Math.PI);
ctx.stroke();
ctx.closePath();
ctx.lineWidth=1;
ctx.beginPath();
ctx.moveTo(125+60,120);
ctx.closePath();
ctx.beginPath();
ctx.stroke();
ctx.fillStyle="#000000";
ctx.moveTo(c.xcoord+30,c.ycoord-75+r2);
ctx.lineTo(c.xcoord-30,c.ycoord-75+r2);
ctx.lineTo(c.xcoord-30,c.ycoord+75-r1+200);
ctx.lineTo(c.xcoord+30,c.ycoord+75-r1+200);
ctx.fill();
ctx.closePath();
ctx.strokeStyle="#123456";
ctx.beginPath();
ctx.stroke();
ctx.moveTo(c.xcoord+60,c.ycoord-a.ycoord);
ctx.lineTo(c.xcoord+75,c.ycoord-a.ycoord);
ctx.fill();
ctx.closePath();
ctx.beginPath();
ctx.moveTo(125+60,120);
ctx.closePath();
drawrem(ctx);
/* if(document.getElementById("trace").checked==true)
{
pointtrace(ptx,pty,ctx,"blue",2);
pointdisp(p,ctx,2,'','','',true,1);
}
else
{
ptx=[];
pty=[];
}*/
}
function drawrem(context)
{
// positioning dimension display
// if(theta2%360<=180)
// offset=-45;
// else
// offset=20;
// dimension line
context.beginPath();
context.moveTo(o.xcoord+80,o.ycoord);
context.lineTo(o.xcoord+80,o.ycoord-r1);
context.closePath();
drawArrow(o.xcoord+80,o.ycoord,context,270,5,40,'#000','',"#000");
drawArrow(o.xcoord+80,o.ycoord-r1,context,90,5,40,'#000','',"#000");
context.beginPath();
context.moveTo(o.xcoord+80,o.ycoord+200);
context.lineTo(o.xcoord+80,o.ycoord+r2+200);
context.closePath();
drawArrow(o.xcoord+80,o.ycoord+200,context,90,5,40,'#000','',"#000");
drawArrow(o.xcoord+80,o.ycoord+r2+200,context,270,5,40,'#000','',"#000");
// context.lineTo(o.xcoord,o.ycoord-offset-5);
// context.moveTo(b.xcoord,o.ycoord-offset+5);
// context.lineTo(b.xcoord,o.ycoord-offset-5);
// context.stroke();
// // arrows at dimension
drawArrow(o.xcoord+80,o.ycoord,context,270,5,40,'#000','',"#000");
drawArrow(o.xcoord+80,o.ycoord-r1,context,90,5,40,'#000','',"#000");
context.beginPath();
context.moveTo(125+60,120);
context.closePath();
// // Position Analysis Title
// context.save();
// context.lineWidth=1;
// context.font="12px 'Comic Sans MS'";
// context.fillStyle="#000000";
// context.fillText("Position Analysis", 15,15);
// context.restore();
// // r, l, d display
context.save();
context.lineWidth=1;
context.strokeStyle="#000000";
context.font = "15px Arial";
context.strokeText('r1', o.xcoord+90,o.ycoord-r1/2);
context.strokeText('r2', o.xcoord+90,o.ycoord+200+r2/2);
context.strokeText('INPUT', o.xcoord-20,o.ycoord-70);
context.strokeText('OUTPUT',o.xcoord-30,o.ycoord+200+75);
//context.strokeText('r1',(o.xcoord+a.xcoord)/2-2,(o.ycoord+a.ycoord)/2+1);
//context.strokeText('r2',(o.xcoord+a.xcoord)/2-2,(o.ycoord+a.ycoord+400)/2+3);
context.restore();
}
// prints comments passed as 'commenttext' in location specified by 'commentloc' in the comments box;
// 0 : Single comment box, 1 : Left comment box, 2 : Right comment box
function printcomment(commenttext,commentloc)
{
if(commentloc==0)
{
document.getElementById('commentboxright').style.visibility='hidden';
document.getElementById('commentboxleft').style.width='570px';
document.getElementById('commentboxleft').innerHTML = commenttext;
}
else if(commentloc==1)
{
document.getElementById('commentboxright').style.visibility='visible';
document.getElementById('commentboxleft').style.width='285px';
document.getElementById('commentboxleft').innerHTML = commenttext;
}
else if(commentloc==2)
{
document.getElementById('commentboxright').style.visibility='visible';
document.getElementById('commentboxleft').style.width='285px';
document.getElementById('commentboxright').innerHTML = commenttext;
}
else
{
document.getElementById('commentboxright').style.visibility='hidden';
document.getElementById('commentboxleft').style.width='570px';
document.getElementById('commentboxleft').innerHTML = "<center>please report this issue to adityaraman@gmail.com</center>";
// ignore use of deprecated tag <center> . Code is executed only if printcomment function receives inappropriate commentloc value
}
}
</script>
</head>
<body onload="editcss(); startsim(); varinit();">
<!-- DND-Verifying JavaScript is enabled in browser -->
<noscript>
The simulation requires JavaScript to be enabled.
</noscript>
<!--
Author : Sai Aditya Raman
send an email to adityaraman09@gmail.com for any communication
-->
<!-- Defining Container for Simulation -->
<div id="container">
<!-- Replace TITLE with simulation title to be displayed next to logo-->
<div id="simtitle">Continuously Variable Transmission</div>
<!-- Region for simulation display -->
<canvas id="simscreen" height="400px" width="550px"></canvas>
<div id="titleincanvas"></div>
<div id="datatable1" class="datatable"></div>
<div id="datatable2" class="datatable"></div>
<!-- Equation Reference and Legend for Graphs etc
<div id="quickreficon" title="Equations" onclick="showEquations();"></div>
<div id="quickref"><img id="quickrefimg" src="sins/tick.png"></img></div>
<div id="legendicon" title="Legend" onclick="showLegend();"></div>
<div id="legend"><img id="legendimg" src="sins/tick.png"></img></div>
-->
<!-- Region for comment / question prompts -->
<div id="commentboxleft"></div>
<div id="commentboxright"></div>
<!-- DND-Title of region for variables display -->
<div id="vartitle">VARIABLES(INPUT)</div>
<!-- Region for Input parameters of simulation -->
<div id="variables" >
<!-- System variable input from user through slider and spinner jQuery widgets
repeat block with new variable name and new id for widgets-->
<!-- <div class="variable">
<div class="varname"><p title="Link Length">r1 (cm)</p>
<input id="r2spinner"></input></div>
<div id="r2slider"></div>
</div>
<div class="variable">
<div class="varname"><p title="Link Length">r2 (cm)</p>
<input id="r1spinner"></input></div>
<div id="r1slider"></div>
</div>
<div class="variable">
<div class="varname"><p title="Link Length">l (cm)</p>
<input id="r3spinner"></input></div>
<div id="r3slider"></div>
</div> -->
<div id = "omega2set" class="variable">
<div class="varname"><p title='Input Angular Velocity'>ω2 (rad/s) </p>
<input id="omega2spinner"></input></div>
<div id="omega2slider"></div>
</div>
<!-- <div id = "r1set" class="variable">
<div class="varname"><p title='Input Radius'>r1; (mm) </p>
<input id="r1spinner"></input></div>
<div id="r1slider"></div>
</div>
<div id = "r2set" class="variable">
<div class="varname"><p title='Input Radius'>r2; (mm) </p>
<input id="r2spinner"></input></div>
<div id="r2slider"></div>
</div> -->
<div id = "theta1set" class="variable">
<div class="varname"><p title='Input Angle'>theta1; (°) </p>
<input id="theta1spinner"></input></div>
<div id="theta1slider"></div>
</div>
<div id = "theta2set" class="variable">
<div class="varname"><p title='Input Angle'>theta2; (°) </p>
<input id="theta2spinner"></input></div>
<div id="theta2slider"></div>
</div>
</div>
<!-- DND-Title of region for controls display -->
<div id="ctrltitle">CONTROLS</div>
<!-- Region for User controls of simulation -->
<div id="controls">
<img id="playpausebutton" onclick="simstate()" src="sins/bluepausedull.png" />
<img id="rotationbutton" onclick="rotstate()" src="sins/bluecwdull.png" />
<!--
<div class="usercheck">
<!-- Point tracing
<input type="checkbox" id="trace" ></input> <p>Trace Mid Point</p>
<!-- Reset Parameters
<input type="button" id="resetparams" value="Reset" onclick="varinit();"></input> -->
</div>
<!-- DND-Copyright display-->
<div id="copyright" title="Developer : Supreeth Dev"> Copyright © SOLVE The Virtual Lab @ NITK Surathkal </div>
</div><!-- Container div close -->
<!-- For trials during development
write in trythis() function the outputs that you want to check.
<input type='button' onclick='trythis()' value="try me"></input>
-->
</body>
</html>