Professional Strawman Posted March 11, 2015 Posted March 11, 2015 (edited) Hi all. I am looking to plot a graph of the Parallelogram Law summations shown in the link below. I am not sure how to do this, since the vector g, needs to continuously point to the origin after each summation. Does anyone here know how to do this or on what platform to do this? Using the graph, one can determine the rate of precession per revolution. Also the vector, g, needs to incorporate the inverse square law. The initial velocity is something the user determines. The rest should be done by the software. Thanks in advance for the help. http://3.bp.blogspot.com/-tFDkItTrHWY/Ug-bh0x_NRI/AAAAAAAAE6U/PKx81419uBA/s1600/Kepler For some background on the question, please see the link below. http://www.scienceforums.net/topic/88054-parallelogram-law-summations-precession-of-orbits/ ------ The precession looks like the images in the following links. http://www.rkm.com.au/ANIMATIONS/animation-graphics/Black-Hole-Rosette-Orbit-label.png http://www.relativity.li/en/epstein2/read/i0_en/i1_en/ Edited March 11, 2015 by Goeton
fiveworlds Posted March 11, 2015 Posted March 11, 2015 (edited) <canvas id="myCanvas" width="578" height="700"></canvas> <script> function drawparallelogram(ax,ay,bx,by,cx,cy,dx,dy,canvasid,context){ var atob= Math.sqrt( (bx-ax)*(bx-ax) + (by-ay)*(by-ay) ); var atoc= Math.sqrt( (cx-ax)*(cx-ax) + (cy-ay)*(cy-ay) ); var ctod= Math.sqrt( (cx-dx)*(cx-dx) + (cy-dy)*(cy-dy) ); var dtob= Math.sqrt( (bx-dx)*(bx-dx) + (by-dy)*(by-dy) ); var ctob= Math.sqrt( (bx-cx)*(bx-cx) + (by-cy)*(by-cy) ); if (atob===ctod && atoc===dtob){ //only runs if points equal a paralleogram var canvas = document.getElementById(canvasid); var context = canvas.getContext(context); context.beginPath(); context.moveTo(cx, cy); context.lineTo(bx, by);//c>b context.moveTo(bx, by); context.lineTo(dx, dy);//d>b context.moveTo(dx, dy); context.lineTo(cx, cy);//c>d context.moveTo(ax, ay); context.lineTo(cx, cy);//a>c context.moveTo(ax, ay); context.lineTo(bx, by);//a > b context.fillText(atoc,((ax+cx)/2)-10,((ay+cy)/2)-10); context.fillText(dtob,((dx+bx)/2)-10,((dy+by)/2)-10); context.fillText(ctod,((dx+cx)/2)-10,((dy+cy)/2)-10); context.fillText(atob,((bx+ax)/2)-10,((by+ay)/2)-10); context.fillText(ctob,((bx+cx)/2)-10,((by+cy)/2)-10); context.stroke();} } var a=100; var b=50; var c=100; var d=150; while (a<400){ drawparallelogram(a,b,450,50,c,d,450,150,'myCanvas','2d'); a=a+10; b=b+10; c=c+10; d=d+10; } </script> If you wanted all parallelogram diagonals to be the same length you would need to use the formula to find a point on the circle Edited March 11, 2015 by fiveworlds
Professional Strawman Posted March 12, 2015 Author Posted March 12, 2015 (edited) Thanks fiveworlds, for your program. I tried on it an online html platform and I did not see an orbit/graph. How do I run this program? Also, the diagonals should not be of equal lengths and they won't since Kepler's 2nd law is inherent in this Summation method. That is, at the farther point in the orbit, relative to the origin, the diagonals will get smaller and become longer at the nearest points. So you can ignore the length of the diagonals. Edited March 12, 2015 by Goeton
Sensei Posted March 12, 2015 Posted March 12, 2015 (edited) Thanks fiveworlds, for your program. I tried on it an online html platform and I did not see an orbit/graph. How do I run this program? fiveworlds has habit of giving chunks of code that doesn't work to any post.. You need html body tags: <html> <body> <canvas id="myCanvas" width="578" height="700"></canvas> <script> function drawparallelogram(ax,ay,bx,by,cx,cy,dx,dy,canvasid,context){ var atob= Math.sqrt( (bx-ax)*(bx-ax) + (by-ay)*(by-ay) ); var atoc= Math.sqrt( (cx-ax)*(cx-ax) + (cy-ay)*(cy-ay) ); var ctod= Math.sqrt( (cx-dx)*(cx-dx) + (cy-dy)*(cy-dy) ); var dtob= Math.sqrt( (bx-dx)*(bx-dx) + (by-dy)*(by-dy) ); var ctob= Math.sqrt( (bx-cx)*(bx-cx) + (by-cy)*(by-cy) ); if (atob===ctod && atoc===dtob){ //only runs if points equal a paralleogram var canvas = document.getElementById(canvasid); var context = canvas.getContext(context); context.beginPath(); context.moveTo(cx, cy); context.lineTo(bx, by);//c>b context.moveTo(bx, by); context.lineTo(dx, dy);//d>b context.moveTo(dx, dy); context.lineTo(cx, cy);//c>d context.moveTo(ax, ay); context.lineTo(cx, cy);//a>c context.moveTo(ax, ay); context.lineTo(bx, by);//a > b context.fillText(atoc,((ax+cx)/2)-10,((ay+cy)/2)-10); context.fillText(dtob,((dx+bx)/2)-10,((dy+by)/2)-10); context.fillText(ctod,((dx+cx)/2)-10,((dy+cy)/2)-10); context.fillText(atob,((bx+ax)/2)-10,((by+ay)/2)-10); context.fillText(ctob,((bx+cx)/2)-10,((by+cy)/2)-10); context.stroke();} } var a=100; var b=50; var c=100; var d=150; while (a<400){ drawparallelogram(a,b,450,50,c,d,450,150,'myCanvas','2d'); a=a+10; b=b+10; c=c+10; d=d+10; } </script> </body></html> and save it as index.html Either in Firefox and Chrome it renders this image: I don't think so it's correct result. Edited March 12, 2015 by Sensei
fiveworlds Posted March 12, 2015 Posted March 12, 2015 (edited) Either in Firefox and Chrome it renders this image: It used to be that way update your other browsers internet explorer, opera etc support canvas now. while (a<400){ drawparallelogram(a,b,450,50,c,d,450,150,'myCanvas','2d'); a=a+10; b=b+10; c=c+10; d=d+10; } take this and use just var a=100; var b=50; var c=100; var d=150; drawparallelogram(a,b,450,50,c,d,450,150,'myCanvas','2d'); gives just one paralleogram on it's own. and if you just want one diagonal line pointing to origin use context.beginPath(); context.moveTo(cx, cy); context.lineTo(bx, by);//c>b context.fillText(ctob,((bx+cx)/2)-10,((by+cy)/2)-10); context.stroke();} I am using points a>b for the top of paralleogram and c>d for the bottom of the paralleogram which is I am also labeling the line lengths using context.fillText if you don't want the labels just delete that Further explained drawparallelogram(point ax,point ay,point bx,point by,point cx,point cy,point dx,point dy,'myCanvas','2d'); Edited March 12, 2015 by fiveworlds
Professional Strawman Posted March 13, 2015 Author Posted March 13, 2015 (edited) fiveworlds, many thanks for your explanation. You clearly misunderstood my drawing. The diagonals are the bold arrows in the drawing. Do you notice the black bold arrows in my drawing? [this drawing is also my profile picture] http://3.bp.blogspot.com/-tFDkItTrHWY/Ug-bh0x_NRI/AAAAAAAAE6U/PKx81419uBA/s1600/Kepler%27s+Second+Law_4.bmp At 1, you see the arms of the parallelogram: v and g. Therefore the diagonal is r. I use the resultant r, at 2, and point g towards the origin and get the diagonal again and so. Sensei, I think fiveworlds misunderstood my drawing. Edited March 13, 2015 by Goeton
Professional Strawman Posted March 13, 2015 Author Posted March 13, 2015 fiveworlds, this video helps you see the orbital prcession of a marble. See how the marble's orbit begins to precess? It traces a flower orbit, if you notice carefully.
swansont Posted March 13, 2015 Posted March 13, 2015 ! Moderator Note Discuss the computer/code aspect, and only that aspect, in this thread.
Professional Strawman Posted March 14, 2015 Author Posted March 14, 2015 (edited) fiveworlds has habit of giving chunks of code that doesn't work to any post.. Fiveworlds is not a physicist, and even if he were, he is not doing that bad. He will eventually get around to it, and did I mention the code for friction? Edited March 14, 2015 by Goeton
Professional Strawman Posted March 19, 2015 Author Posted March 19, 2015 Hi fiveworlds, I found an Excel program at the following link: http://www.phys.virginia.edu/classes/581/GeneralPlanet.xls The precession shown in Dan's video can be obtained by changing n to 0.5 [very strong gravitational field]. This is nearly what my drawing predicts. So many thanks for trying.
fiveworlds Posted March 20, 2015 Posted March 20, 2015 (edited) I am sorry I am quite busy at the moment can you show me how far you have gotten with canvas? below is a function to return the exact point of click <script> function show_coords(event) { var x,y; if (event.pageX != undefined && event.pageY != undefined) { x = event.pageX; y = event.pageY; } else { x = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; y = event.clientY + document.body.scrollTop + document.documentElement.scrollTop; } x=parseInt(x)- parseInt(document.getElementById('canvas').offsetLeft); y=parseInt(y)-parseInt(document.getElementById('canvas').offsetTop); document.getElementById("demo").innerHTML = "X= " + x + "<br>Y= " + y; } </script> </head> <body> <canvas id="canvas" style="margin-top:-9px;top:0px;left:0px;" onmousedown="show_coords(event)" width="1000px" height="1000px"></canvas> </body> this should give you an idea of some of the gravity simulations possible with canvas http://www.arachnoid.com/orbital_dynamics/index.html http://jarrodoverson.com/static/demos/particleSystem/#0,variable:Sv1%285000|1|0|0|1|E388,158:2,0:8:-1:0.10:4|F443,211:500%29 http://www.arachnoid.com/graphinity_online/index.html Edited March 20, 2015 by fiveworlds
Professional Strawman Posted March 21, 2015 Author Posted March 21, 2015 (edited) fiveworlds, I tried and learned a little canvas, but I was never going to automate this. But the Excel program works exactly right. My summation method is equivalent to the Leapfrog method, so that was just the program I was looking for. So I found what I was looking for. Many thanks for trying. If you want to see other Excel programs, here they are: http://galileo.phys.virginia.edu/classes/581/ Edited March 21, 2015 by Professional Strawman
fiveworlds Posted March 21, 2015 Posted March 21, 2015 fiveworlds, I tried and learned a little canvas, but I was never going to automate this. But the Excel program works exactly right. My summation method is equivalent to the Leapfrog method, so that was just the program I was looking for. So I found what I was looking for. Many thanks for trying. I need to learn excel too you know I am just teaching you something that I know. For instance I know that in order to map 2d equations onto a graph I need to be able to convert the canvas into the normal 2d axis. Like so <script> function show_coords(event) { var x,y; if (event.pageX != undefined && event.pageY != undefined) { x = event.pageX; y = event.pageY; } else { x = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; y = event.clientY + document.body.scrollTop + document.documentElement.scrollTop; } x=parseInt(x)- parseInt(document.getElementById('canvas').offsetLeft); y=parseInt(y)-parseInt(document.getElementById('canvas').offsetTop); x=x-parseInt(canvas.width)/2; y=parseInt(canvas.height)/2-y; document.getElementById("demo").innerHTML = "X= " + x + "<br>Y= " + y; } </script> </head> <body> <canvas id="canvas" style="margin-top:-9px;top:0px;left:0px;" onmousedown="show_coords(event)" width="1000px" height="1000px"></canvas> </body>
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now