Latest test 18 Aug 2023

by aaronamran

HTML

<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jsxgraph/distrib/jsxgraphcore.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jsxgraph/distrib/jsxgraph.css">
<div id="jxgbox" class="jxgbox" style="width:500px; height:500px">
</div>
 <!---->
<p id="init">[
  [ "grid", "x","y",-1, 15,-1,11, 40],
  [ "label", "grid", [-0.8, -0.5]],  
  [ "rope", "1", [3,8], 0.5, [5,8], 0.3 ],
  [ "circle", " ", [3,8], 0.5, 0, "hide" ],
  [ "circle", " ", [5,8], 0.3, 0, "hide" ]
  ]
</p>
<p id="data"></p>
<p id="fbd_names"></p>

JavaScript

// Start of jsfiddle header.
var mode = "jsfiddle";
var divid = "jxgbox";
var fbd_names = "fbd_names";
var stateRef = "data";
var initstring = document.getElementById("init").innerHTML;
const centeredLabelStyle = {
  size: 0,
  showInfobox: false,
  label: {
    offset: [0, 0],
    anchorX: 'middle',
    anchorY: 'middle'
  }
};

/* 
Fixed GitHub Issues that are implemented in this JS code: 
#11 : Option to lock objects in hidden state (bar, beam, circle, dashpot, fix1, fix12, fix123, fix13, polygon, q, rope, springc, springt, wall)
#12 : Make the beam object clickable
#13 : Suppress infobox at "rot" points
#28 : Move "force" by dragging the vector
#30 : "force": Prevent forces to have zero length
#35 : Make toStack() more robust (cleanupName())
#37 : Grid lines to the background

Animated the following objects:
- circle
- fix1, fix12, fix123, fix13
- label
- mass
- node
- point
- polygon
- rot
- springc
- springt
*/

// https://github.com/mkraska/meclib/wiki
// version info
const versionText= "JXG "+JXG.version+" Meclib 2023 08 16";
const highlightColor = "orange";
const movableLineColor = "blue";
const loadColor = "blue";
const defaultMecLayer = 6;
var pxunit = 1/40; // is reset by "grid"
var a = 16*pxunit; // is reset by "grid"
const deg2rad = Math.PI/180, rad2deg = 180/Math.PI;
const tolPointLine = 0.001;
var xscale = 1, yscale = 1; // default scale for infobox, can be modified by "grid"
var dpx = 1, dpy = 1; // default decimal precision for infobox, can be modified by "grid"
// infobox settings, further settings after board initiation
JXG.Options.infobox.layer = defaultMecLayer+5;
JXG.Options.infobox.strokeColor = 'black';
JXG.Options.infobox.cssStyle = 'background-color: #ffffffdd;'
// snap settings. Interactive objects are handled explicity
JXG.Options.point.snapToGrid = false; // grid snap spoils rotated static objects
JXG.Options.point.snapSizeX = 0.1;
JXG.Options.point.snapSizeY = 0.1;
// interactive objects are released...