Skip to content

Moving objects by scripts

mkraska edited this page Aug 2, 2023 · 63 revisions

The objective is to add scripts to Meclib widgets, which allow the control of the sketch by interactively dragging control points. Here is a jsfiddle example

Interactivity legend:

  • "Switch": object can be activated or deactivated by double-click.
  • "Move": object or it's control points can be dragged around with the mouse.
  • "Delete": object can be deleted by double-click (if active)
  • "Generate": object can generate "force" or "moment" objects by dragging sample objects with the mouse.

Return value: only relevant for interactive input

Not all objects are meant to be animated, as it depends on the purpose of their functionalities.

The input for the images in the table are found here

Object Interactivity Return value in names Example moveTo( ) points
"angle", "angle1", "angle2" label string image
"axes"
"bar" Switch "show" or list of load indices if hidden image p1, p2
"beam" Switch state image
"circle" Switch state image p1 (circle midpoint)
"circle2p" Move [x1,y1],[x2,y2] image
"crosshair" Move [x,y] (scaled) image
"dashpot" Switch "show" or list of load indices if hidden image
"dim" label string image
"dir" label string image
"disp" label string image
"fix1", "fix12", "fix123", "fix13" Switch "show" or list of load indices if hidden image p1
"force" Move, delete expression image p1, p2
"forceGen" Generate 0 image
"frame" 0 Bildschirmfoto 2023-06-27 um 16 26 09
"grid" 0 image
"label" 0 image p1
"line" 0 image
"line2p" Move [x1,y1],[x2,y2] image
"mass" 0 image p1
"moment" Move, delete expression image
"momentGen" Generate 0 image
"node" label string image p1
"point" label string image p1
"polygon" Switch state image p1 (polygon midpoint)
"q" Switch "show" or list of load indices if hidden image
"rope" Switch "show" or list of load indices if hidden image
"rot" label string image
"spline" Move expression f(x) image
"springc" Switch "show" or list of load indices if hidden image p2
"springt" Switch "show" or list of load indices if hidden image p2
"wall" Switch "show" or list of load indices if hidden image

Tryout Space

In order to try code snippets in jsfiddle,

  1. copy the code from the wiki page to the clipboard
  2. follow the link for the JSXGraph version you want to try
  3. Replace the code in the HTML section (contents of <p hidden id="init">) with the content of the clipboard
Clone this wiki locally