|
|
Line 15: |
Line 15: |
|
| |
|
| How do we visualize or predict using this topic. Consider embedding some vpython code here [https://trinket.io/glowscript/31d0f9ad9e Teach hands-on with GlowScript] | | How do we visualize or predict using this topic. Consider embedding some vpython code here [https://trinket.io/glowscript/31d0f9ad9e Teach hands-on with GlowScript] |
|
| |
|
| |
| <div id="glowscript" class="glowscript">
| |
| <link type="text/css" href="http://www.glowscript.org/css/redmond/1.1/jquery-ui.custom.css" rel="stylesheet" />
| |
| <link href="http://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css">
| |
| <link type="text/css" href="http://www.glowscript.org/css/ide.css" rel="stylesheet" />
| |
| <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
| |
| <script type="text/javascript" src="http://www.glowscript.org/lib/jquery/1.1/jquery.min.js"></script>
| |
| <script type="text/javascript" src="http://www.glowscript.org/lib/jquery/1.1/jquery-ui.custom.min.js"></script>
| |
| <script type="text/javascript" src="http://www.glowscript.org/package/glow.1.1.min.js"></script>
| |
| <script type="text/javascript" src="http://www.glowscript.org/package/RSrun.1.1.min.js"></script>
| |
| <script type="text/javascript">
| |
| ;(function() {
| |
| var __g=typeof global!=='undefined'?global:window;__g=(__g.__streamline||(__g.__streamline={}));__g.setEF=__g.setEF||function(e,f){e.__frame = e.__frame||f};var __srcName='undefined_.js';
| |
| function __func(_,__this,__arguments,fn,index,frame,body){if(!_){return __future.call(__this,fn,__arguments,index)}frame.file=__srcName;frame.prev=__g.frame;__g.frame=frame;try{body()}catch(e){__g.setEF(e,frame.prev);__propagate(_,e)}finally{__g.frame=frame.prev}}
| |
| function __future(fn,args,i){var done,err,result;var cb=function(e,r){done=true;err=e,result=r};args=Array.prototype.slice.call(args);args[i]=function ___(e,r){cb(e,r)};fn.apply(this,args);return function ___(_){if(done)_.call(this,err,result);else cb=_.bind(this)}.bind(this)}
| |
| function __propagate(_,err){try{_(err)}catch(ex){__trap(ex)}}
| |
| function __trap(err){if(err){if(__g.context&&__g.context.errorHandler)__g.context.errorHandler(err);else console.error("UNCAUGHT EXCEPTION: "+err.message+"\n"+err.stack)}}
| |
| /* 1 */ function main(wait) {
| |
| var version, box, sphere, cylinder, pyramid, cone, helix, ellipsoid, ring, arrow, display, vector, _$GS_$END, scene, _$rapyd$_Temp, _$rapyd$_print, arange, oofpez, qproton, scalefactor, particle, obslocation, obslocation1, obslocation2, obslocation3, obslocation4, obslocation5, obslocation6, r, r1, r2, r3, r4, r5, r6, ra, rmag, rhat, rhat1, rhat2, rhat3, rhat4, rhat5, rhat6, E, E1, E2, E3, E4, E5, E6, ea, ea1, ea2, ea3, ea4, ea5, ea6;
| |
| var __frame = {
| |
| name: "main",
| |
| line: 1
| |
| };
| |
| return __func(wait, this, arguments, main, 0, __frame, function __$main() {
| |
| /* 3 */ version = ["1.1","glowscript",];
| |
| /* 4 */ window.__GSlang = "vpython";
| |
| /* 5 */ box = vp_box;
| |
| /* 6 */ sphere = vp_sphere;
| |
| /* 7 */ cylinder = vp_cylinder;
| |
| /* 8 */ pyramid = vp_pyramid;
| |
| /* 9 */ cone = vp_cone;
| |
| /* 10 */ helix = vp_helix;
| |
| /* 11 */ ellipsoid = vp_ellipsoid;
| |
| /* 12 */ ring = vp_ring;
| |
| /* 13 */ arrow = vp_arrow;
| |
| /* 14 */ display = canvas;
| |
| /* 15 */ vector = vec;
| |
| /* 16 */ _$GS_$END = 0;
| |
| /* 17 */ scene = canvas();
| |
| /* 18 */ _$rapyd$_Temp = 0;
| |
| /* 19 */ _$rapyd$_print = print;
| |
| /* 20 */ arange = range;
| |
| /* 22 */ oofpez = 9000000000;
| |
| /* 24 */ qproton = 1.6e-19;
| |
| /* 26 */ scalefactor = 1e-20;
| |
| /* 28 */ particle = sphere({
| |
| /* 28 */ pos: vector(1e-10, 0, 0),
| |
| /* 28 */ radius: 2e-11,
| |
| /* 28 */ color: color.blue
| |
| });
| |
| /* 30 */ obslocation = vector(3.1e-10, 2.1e-10["-u"](), 0);
| |
| /* 32 */ obslocation1 = vector(4e-10, 0, 0);
| |
| /* 34 */ obslocation2 = vector(2e-10["-u"](), 0, 0);
| |
| /* 36 */ obslocation3 = vector(1e-10, 3e-10, 0);
| |
| /* 38 */ obslocation4 = vector(1e-10, 3e-10["-u"](), 0);
| |
| /* 40 */ obslocation5 = vector(1e-10, 0, 3e-10);
| |
| /* 42 */ obslocation6 = vector(1e-10, 0, 3e-10["-u"]());
| |
| /* 44 */ r = obslocation["-"](particle.pos);
| |
| /* 46 */ r1 = obslocation1["-"](particle.pos);
| |
| /* 48 */ r2 = obslocation2["-"](particle.pos);
| |
| /* 50 */ r3 = obslocation3["-"](particle.pos);
| |
| /* 52 */ r4 = obslocation4["-"](particle.pos);
| |
| /* 54 */ r5 = obslocation5["-"](particle.pos);
| |
| /* 56 */ r6 = obslocation6["-"](particle.pos);
| |
| /* 58 */ print;
| |
| /* 59 */ ["relative position vector is",r,];
| |
| /* 61 */ ra = arrow({
| |
| /* 61 */ pos: particle.pos,
| |
| /* 61 */ axis: r,
| |
| /* 61 */ color: color.green
| |
| });
| |
| /* 63 */ label({
| |
| /* 63 */ pos: particle.pos["+"](0.5["*"](r)),
| |
| /* 63 */ text: "r"
| |
| });
| |
| /* 65 */ rmag = sqrt(Math.pow(r.x, 2)["+"](Math.pow(r.y, 2))["+"](Math.pow(r.z, 2)));
| |
| /* 67 */ print;
| |
| /* 68 */ ["magnitude of r is",rmag,];
| |
| /* 70 */ rhat = norm(r);
| |
| /* 72 */ rhat1 = norm(r1);
| |
| /* 74 */ rhat2 = norm(r2);
| |
| /* 76 */ rhat3 = norm(r3);
| |
| /* 78 */ rhat4 = norm(r4);
| |
| /* 80 */ rhat5 = norm(r5);
| |
| /* 82 */ rhat6 = norm(r6);
| |
| /* 84 */ print;
| |
| /* 85 */ ["unit vector rhat is",rhat,];
| |
| /* 87 */ E = oofpez["*"](qproton)["*"](rhat)["/"](Math.pow(rmag, 2));
| |
| /* 89 */ E1 = oofpez["*"](qproton)["*"](rhat1)["/"](Math.pow(rmag, 2));
| |
| /* 91 */ E2 = oofpez["*"](qproton)["*"](rhat2)["/"](Math.pow(rmag, 2));
| |
| /* 93 */ E3 = oofpez["*"](qproton)["*"](rhat3)["/"](Math.pow(rmag, 2));
| |
| /* 95 */ E4 = oofpez["*"](qproton)["*"](rhat4)["/"](Math.pow(rmag, 2));
| |
| /* 97 */ E5 = oofpez["*"](qproton)["*"](rhat5)["/"](Math.pow(rmag, 2));
| |
| /* 99 */ E6 = oofpez["*"](qproton)["*"](rhat6)["/"](Math.pow(rmag, 2));
| |
| /* 101 */ print;
| |
| /* 102 */ ["Electric field vector is",E,];
| |
| /* 104 */ ea = arrow({
| |
| /* 104 */ pos: obslocation,
| |
| /* 104 */ axis: scalefactor["*"](E),
| |
| /* 104 */ color: color.orange
| |
| });
| |
| /* 106 */ label({
| |
| /* 106 */ pos: obslocation["+"](scalefactor["*"](E))["-"](0.5["*"](E)["*"](scalefactor)),
| |
| /* 106 */ text: "E"
| |
| });
| |
| /* 108 */ ea1 = arrow({
| |
| /* 108 */ pos: obslocation1,
| |
| /* 108 */ axis: scalefactor["*"](E1),
| |
| /* 108 */ color: color.orange
| |
| });
| |
| /* 110 */ ea2 = arrow({
| |
| /* 110 */ pos: obslocation2,
| |
| /* 110 */ axis: scalefactor["*"](E2),
| |
| /* 110 */ color: color.orange
| |
| });
| |
| /* 112 */ ea3 = arrow({
| |
| /* 112 */ pos: obslocation3,
| |
| /* 112 */ axis: scalefactor["*"](E3),
| |
| /* 112 */ color: color.orange
| |
| });
| |
| /* 114 */ ea4 = arrow({
| |
| /* 114 */ pos: obslocation4,
| |
| /* 114 */ axis: scalefactor["*"](E4),
| |
| /* 114 */ color: color.orange
| |
| });
| |
| /* 116 */ ea5 = arrow({
| |
| /* 116 */ pos: obslocation5,
| |
| /* 116 */ axis: scalefactor["*"](E5),
| |
| /* 116 */ color: color.orange
| |
| });
| |
| /* 118 */ ea6 = arrow({
| |
| /* 118 */ pos: obslocation6,
| |
| /* 118 */ axis: scalefactor["*"](E6),
| |
| /* 118 */ color: color.orange
| |
| });
| |
| wait();
| |
| });
| |
| };
| |
| /* 120 */ main;
| |
|
| |
| ;$(function(){ window.__context = { glowscript_container: $("#glowscript").removeAttr("id") }; main() })})()
| |
| </script>
| |
| </div>
| |
|
| |
|
| ==Examples== | | ==Examples== |