{"id":5035,"date":"2026-11-08T22:49:27","date_gmt":"2026-11-09T02:49:27","guid":{"rendered":"https:\/\/faculty.fiu.edu\/~theobald\/?page_id=5035"},"modified":"2026-11-08T22:52:50","modified_gmt":"2026-11-09T02:52:50","slug":"muscle-arm","status":"publish","type":"page","link":"https:\/\/faculty.fiu.edu\/~theobald\/muscle-arm\/","title":{"rendered":"Muscle arm"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"5035\" class=\"elementor elementor-5035\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-7040430 elementor-section-full_width elementor-section-stretched elementor-section-height-default elementor-section-height-default\" data-id=\"7040430\" data-element_type=\"section\" data-settings=\"{&quot;stretch_section&quot;:&quot;section-stretched&quot;}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-1d2d917\" data-id=\"1d2d917\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-05ab5f8 elementor-widget__width-inherit elementor-widget elementor-widget-html\" data-id=\"05ab5f8\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"utf-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  <meta name=\"theme-color\" content=\"#0b111b\">\n  <title>Muscles and Levers<\/title>\n  \n  \n  \n<style>\n:root { color-scheme:dark; font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,\"Segoe UI\",sans-serif; background:#0b111b; color:#e8edf4; font-size:14px; }\n* { box-sizing:border-box; }\nbody { margin:0; background:#0b111b; }\nbutton,input { font:inherit; }\nbutton { cursor:pointer; border:1px solid #345064; border-radius:5px; padding:7px 10px; background:#203046; color:#d6e6f2; font-size:12px; font-weight:650; }\nbutton:hover { filter:brightness(1.13); }\nbutton:focus-visible,input:focus-visible { outline:2px solid #70e0d7; outline-offset:3px; }\n.shell { max-width:1510px; margin:0 auto; padding:12px; }\n.masthead { margin-bottom:10px; }\nh1 { font-size:21px; line-height:1.2; font-weight:650; letter-spacing:-.025em; margin:0; }\n.main-grid { display:grid; grid-template-columns:310px minmax(0,1fr); gap:10px; align-items:stretch; }\n.panel { background:#121d2b; border:1px solid #263548; border-radius:7px; }\n.control-panel { padding:10px; display:flex; flex-direction:column; }\n.control-section { padding:0 0 6px; margin-bottom:6px; border-bottom:1px solid #263548; }\n.control { margin-bottom:7px; }\n.control:last-child { margin-bottom:0; }\n.control-label { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:2px; }\n.control-label label { font-size:12px; color:#c7d3e1; }\n.control-label output { font:700 12px ui-monospace,SFMono-Regular,Consolas,monospace; color:#61d3c4; white-space:nowrap; }\ninput[type=\"range\"] { display:block; width:100%; height:15px; margin:0; accent-color:#61d3c4; cursor:pointer; background:transparent; }\n.range-ends { display:flex; justify-content:space-between; font-size:9px; line-height:11px; color:#8295ab; }\n.experiment-actions { margin-top:auto; }\n.button-row { display:grid; grid-template-columns:1fr 1fr; gap:6px; }\n.primary-btn { background:#62d3c3; border-color:#62d3c3; color:#0b2430; }\n.transport-row { margin-top:5px; }\n.right-column { min-width:0; }\n.visualization-panel { height:100%; display:flex; flex-direction:column; position:relative; }\n.viz-topbar { position:absolute; top:8px; right:8px; z-index:1; }\n.status { display:flex; align-items:center; gap:5px; padding:4px 6px; border:1px solid #294255; border-radius:4px; background:#182b39; color:#94c5c0; font:700 9px ui-monospace,monospace; }\n.status-dot { width:5px; height:5px; border-radius:50%; background:#7ca3b0; }\n.status.running { color:#64d7c7; }\n.status.running .status-dot { background:#64d7c7; }\n.stage { flex:1; min-height:0; display:flex; align-items:center; justify-content:center; background:#0d1724; border-radius:7px 7px 0 0; }\n#armSvg { display:block; width:100%; height:390px; }\n.svg-caption { fill:#8da4b9; font-family:ui-monospace,monospace; }\n.accent-label { fill:#78dbc9; font-size:14px; }\n.readouts { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); padding:8px 4px; border-top:1px solid #263548; }\n.readout { min-width:0; text-align:center; padding:0 4px; border-right:1px solid #2b3d52; }\n.readout:last-child { border:0; }\n.readouts.homework-readouts { grid-template-columns:repeat(2,minmax(0,1fr)); }\n.homework-readouts .readout-name { white-space:normal; }\n.readout-name { display:block; margin-bottom:3px; font-size:9px; color:#8499af; white-space:nowrap; }\n.readout strong { font-size:16px; font-variant-numeric:tabular-nums; white-space:nowrap; }\n.charts-section { margin-top:10px; padding:8px; }\n.charts-heading { display:flex; justify-content:flex-end; margin-bottom:6px; }\n.chart-actions { display:flex; align-items:center; gap:12px; }\n.tiny-btn { font-size:11px; padding:5px 8px; }\n.chart-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }\n.chart-card { min-width:0; padding:8px 5px 5px; background:#101b29; border:1px solid #2b3b50; border-radius:5px; }\n.chart-title { padding:0 6px 5px; font-size:12px; font-weight:700; }\n.chart-title span { float:right; color:#91a2b8; font-size:10px; font-weight:500; }\ncanvas { display:block; width:100%; height:178px; }\n.chart-legend { display:flex; justify-content:center; gap:14px; min-height:17px; font-size:10px; color:#a7b7c8; }\n.chart-legend span { display:flex; align-items:center; gap:5px; }\n.chart-legend i { display:inline-block; width:12px; height:3px; border-radius:1px; }\n.legend-muscle { background:#63d1c2; }\n.legend-gravity { background:#e3ae77; }\n@media (max-width:900px) {\n  .main-grid { grid-template-columns:290px minmax(0,1fr); }\n  .readouts { grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px 0; }\n  .readout { border:0; }\n  .readout strong { font-size:14px; }\n}\n@media (max-width:640px) {\n  .shell { padding:8px; }\n  .main-grid { grid-template-columns:minmax(0,1fr); }\n  .control-panel { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px 12px; }\n  .control-section { margin:0; }\n  .experiment-actions { grid-column:1\/-1; }\n  .control-label { flex-wrap:wrap; gap:2px 6px; }\n  .chart-grid { grid-template-columns:minmax(0,1fr); }\n  #armSvg { height:320px; }\n}\n<\/style>\n<\/head>\n<body>\n  <div class=\"shell\">\n    <header class=\"masthead\"><h1>Muscles and Levers<\/h1><\/header>\n\n    <main class=\"main-grid\">\n      <aside class=\"control-panel panel\" aria-label=\"Simulation parameters\">\n        <div class=\"control-section\">\n          <div class=\"control\"><div class=\"control-label\"><label for=\"insertionCm\">Muscle insertion<\/label><output id=\"insertionCmValue\">10 cm<\/output><\/div><input id=\"insertionCm\" type=\"range\" min=\"4\" max=\"18\" step=\"0.5\" value=\"10\"><\/div>\n          <div class=\"control\"><div class=\"control-label\"><label for=\"loadPositionCm\">Load position<\/label><output id=\"loadPositionCmValue\">29 cm<\/output><\/div><input id=\"loadPositionCm\" type=\"range\" min=\"12\" max=\"34\" step=\"1\" value=\"29\"><\/div>\n        <\/div>\n        <div class=\"control-section\">\n          <div class=\"control\"><div class=\"control-label\"><label for=\"loadMassKg\">Load mass<\/label><output id=\"loadMassKgValue\">0.75 kg<\/output><\/div><input id=\"loadMassKg\" type=\"range\" min=\"0\" max=\"5\" step=\"0.25\" value=\"0.75\"><div class=\"range-ends\"><span>0 kg<\/span><span>5 kg<\/span><\/div><\/div>\n        <\/div>\n        <div class=\"control-section\">\n          <div class=\"control\"><div class=\"control-label\"><label for=\"maxForceN\">Muscle strength<\/label><output id=\"maxForceNValue\">200 N<\/output><\/div><input id=\"maxForceN\" type=\"range\" min=\"40\" max=\"240\" step=\"5\" value=\"200\"><div class=\"range-ends\"><span>40 N<\/span><span>240 N<\/span><\/div><\/div>\n        <\/div>\n        <div class=\"control-section\">\n          <div class=\"control\"><div class=\"control-label\"><label for=\"recruitment\">Motor unit recruitment<\/label><output id=\"recruitmentValue\">100%<\/output><\/div><input id=\"recruitment\" type=\"range\" min=\"0.1\" max=\"1\" step=\"0.05\" value=\"1\"><div class=\"range-ends\"><span>10%<\/span><span>100%<\/span><\/div><\/div>\n          <div class=\"control\"><div class=\"control-label\"><label for=\"frequencyHz\">Pulse frequency \u00b7 train<\/label><output id=\"frequencyHzValue\">20 Hz<\/output><\/div><input id=\"frequencyHz\" type=\"range\" min=\"1\" max=\"50\" step=\"1\" value=\"20\"><div class=\"range-ends\"><span>1 Hz<\/span><span>50 Hz<\/span><\/div><\/div>\n          <div class=\"control\"><div class=\"control-label\"><label for=\"trainDuration\">Train duration<\/label><output id=\"trainDurationValue\">1.0 s<\/output><\/div><input id=\"trainDuration\" type=\"range\" min=\"0.2\" max=\"2\" step=\"0.1\" value=\"1\"><div class=\"range-ends\"><span>0.2 s<\/span><span>2 s<\/span><\/div><\/div>\n        <\/div>\n        <div class=\"experiment-actions\">\n          <div class=\"button-row\"><button id=\"singleButton\" class=\"primary-btn\" type=\"button\">Single pulse<\/button><button id=\"trainButton\" class=\"primary-btn\" type=\"button\">Pulse train<\/button><\/div>\n          <div class=\"button-row transport-row\"><button id=\"pauseButton\" class=\"secondary-btn\" type=\"button\">Resume<\/button><button id=\"resetButton\" class=\"secondary-btn\" type=\"button\">\u21bb Reset<\/button><\/div>\n        <\/div>\n      <\/aside>\n\n      <section class=\"right-column\" aria-label=\"Arm visualization and measurements\">\n        <div class=\"visualization-panel panel\">\n          <div class=\"viz-topbar\"><div class=\"status\" id=\"status\"><span class=\"status-dot\"><\/span><span id=\"statusText\">READY<\/span><\/div><\/div>\n          <div class=\"stage\">\n            <svg id=\"armSvg\" viewBox=\"205 90 310 370\" role=\"img\" aria-label=\"Animated forearm rotating about an elbow, pulled by a muscle and carrying a load\">\n              <defs>\n                <pattern id=\"stageGrid\" width=\"30\" height=\"30\" patternUnits=\"userSpaceOnUse\"><path d=\"M30 0 H0 V30\" fill=\"none\" stroke=\"#233348\" stroke-width=\"0.6\" opacity=\".6\" \/><\/pattern>\n                <marker id=\"gravityArrow\" markerWidth=\"8\" markerHeight=\"8\" refX=\"5\" refY=\"3\" orient=\"auto\"><path d=\"M0 0 L6 3 L0 6\" fill=\"none\" stroke=\"#e5b979\" stroke-width=\"1.5\"\/><\/marker>\n              <\/defs>\n              <rect x=\"205\" y=\"90\" width=\"310\" height=\"370\" fill=\"url(#stageGrid)\" \/>\n              <g opacity=\".44\"><line x1=\"260\" y1=\"32\" x2=\"260\" y2=\"378\" stroke=\"#526882\" stroke-width=\"1\" stroke-dasharray=\"5 6\"\/><line x1=\"30\" y1=\"350\" x2=\"706\" y2=\"350\" stroke=\"#526882\" stroke-width=\"1\" stroke-dasharray=\"5 6\"\/><\/g>\n              <path d=\"M 464 296 A 210 210 0 0 0 182 155\" fill=\"none\" stroke=\"#3c5b74\" stroke-width=\"1\" stroke-dasharray=\"4 7\" opacity=\".55\" \/>\n              <path d=\"M260 350 L260 139.7\" stroke=\"#34495d\" stroke-width=\"42\" stroke-linecap=\"round\" \/>\n              <path d=\"M260 350 L260 139.7\" stroke=\"#73899e\" stroke-width=\"26\" stroke-linecap=\"round\" \/>\n              <circle cx=\"260\" cy=\"139.7\" r=\"19\" fill=\"#34495d\" stroke=\"#637a90\" stroke-width=\"3\" \/>\n              <line id=\"boneShadow\" x1=\"235.6\" y1=\"350\" x2=\"467.4\" y2=\"350\" stroke=\"#34495d\" stroke-width=\"42\" stroke-linecap=\"round\" \/>\n              <line id=\"forearmBone\" x1=\"235.6\" y1=\"350\" x2=\"467.4\" y2=\"350\" stroke=\"#73899e\" stroke-width=\"26\" stroke-linecap=\"round\" \/>\n              <circle cx=\"260\" cy=\"350\" r=\"19\" fill=\"#152536\" stroke=\"#7e9bb1\" stroke-width=\"5\" \/>\n              <circle cx=\"260\" cy=\"350\" r=\"5\" fill=\"#afd6e3\" \/>\n              <line id=\"gravityLine\" x1=\"440\" y1=\"310\" x2=\"440\" y2=\"370\" stroke=\"#e5b979\" stroke-width=\"2\" marker-end=\"url(#gravityArrow)\" \/>\n              <line id=\"muscleLine\" x1=\"260\" y1=\"160.73\" x2=\"321\" y2=\"350\" stroke=\"#ef9985\" stroke-width=\"22.36\" stroke-linecap=\"round\" \/>\n              <circle id=\"originMarker\" cx=\"260\" cy=\"160.73\" r=\"5\" fill=\"#f5a59a\" stroke=\"#261a24\" stroke-width=\"2\" \/>\n              <g id=\"loadMarker\"><rect x=\"-15\" y=\"-15\" width=\"30\" height=\"30\" rx=\"5\" fill=\"#b9874e\" stroke=\"#f1c484\" stroke-width=\"2\"\/><path d=\"M-7 -5 V6 M0 -5 V6 M7 -5 V6\" stroke=\"#f5d2a5\" stroke-width=\"1.5\" stroke-linecap=\"round\" \/><\/g>\n              <circle id=\"handMarker\" r=\"10\" fill=\"#8eacc1\" stroke=\"#24384d\" stroke-width=\"3\"\/>\n              <circle id=\"insertionMarker\" cx=\"321\" cy=\"350\" r=\"7\" fill=\"#f19a85\" stroke=\"#fff1e8\" stroke-width=\"1.5\" \/>\n              <path id=\"angleArc\" d=\"\" stroke=\"#5fcabf\" stroke-width=\"2\" fill=\"none\" \/>\n              <text x=\"343\" y=\"380\" class=\"svg-caption accent-label\" id=\"angleLabel\">0\u00b0<\/text>\n            <\/svg>\n          <\/div>\n          <div class=\"readouts homework-readouts\" aria-live=\"off\">\n            <div class=\"readout\" title=\"Theoretical muscle torque at 0\u00b0, full activation and zero shortening velocity, for the selected strength and recruitment; independent of load.\"><span class=\"readout-name\">MAXIMUM STATIC MUSCLE TORQUE \u00b7 AT 0\u00b0<\/span><strong id=\"staticTorqueReadout\">0.0 N\u00b7m<\/strong><\/div>\n            <div class=\"readout\" title=\"Largest elbow angle since the most recent single pulse or pulse train; retained during relaxation.\"><span class=\"readout-name\">PEAK ELBOW ANGLE \u00b7 SINCE STIMULATION<\/span><strong id=\"peakAngleReadout\">0.0\u00b0<\/strong><\/div>\n          <\/div>\n          <div class=\"readouts\" aria-live=\"off\">\n            <div class=\"readout\"><span class=\"readout-name\">ELBOW ANGLE<\/span><strong id=\"angleReadout\">0.0\u00b0<\/strong><\/div>\n            <div class=\"readout\"><span class=\"readout-name\">ANGULAR SPEED<\/span><strong id=\"speedReadout\">0.0 \u00b0\/s<\/strong><\/div>\n            <div class=\"readout\"><span class=\"readout-name\">MUSCLE FORCE<\/span><strong id=\"forceReadout\">0 N<\/strong><\/div>\n            <div class=\"readout\"><span class=\"readout-name\">MOMENT ARM<\/span><strong id=\"momentReadout\">0.0 cm<\/strong><\/div>\n            <div class=\"readout\"><span class=\"readout-name\">SHORTENING<\/span><strong id=\"shorteningReadout\">0.00 cm<\/strong><\/div>\n            <div class=\"readout\"><span class=\"readout-name\">TIME<\/span><strong id=\"timeReadout\">0.00 s<\/strong><\/div>\n          <\/div>\n        <\/div>\n      <\/section>\n    <\/main>\n\n    <section class=\"charts-section panel\" aria-label=\"Time-dependent plots\">\n      <div class=\"charts-heading\"><div class=\"chart-actions\"><button type=\"button\" id=\"csvButton\" class=\"tiny-btn\" title=\"Export complete simulation history\">\u2193 Export CSV<\/button><\/div><\/div>\n      <div class=\"chart-grid\"><article class=\"chart-card\"><div class=\"chart-title\">Elbow angle <span>deg<\/span><\/div><canvas id=\"angleChart\" aria-label=\"Elbow angle over time\"><\/canvas><\/article><article class=\"chart-card\"><div class=\"chart-title\">Joint torque <span>N\u00b7m<\/span><\/div><canvas id=\"torqueChart\" aria-label=\"Muscle and gravitational torque over time\"><\/canvas><div class=\"chart-legend\"><span><i class=\"legend-muscle\"><\/i> Muscle<\/span><span><i class=\"legend-gravity\"><\/i> Gravity<\/span><\/div><\/article><article class=\"chart-card\"><div class=\"chart-title\">Angular velocity <span>deg\/s<\/span><\/div><canvas id=\"velocityChart\" aria-label=\"Angular velocity over time\"><\/canvas><\/article><article class=\"chart-card\"><div class=\"chart-title\">Muscle force <span>N<\/span><\/div><canvas id=\"forceChart\" aria-label=\"Muscle force over time with neural pulse markers\"><\/canvas><div class=\"chart-legend\"><span><i class=\"legend-muscle\"><\/i> Force<\/span><span><i class=\"legend-gravity\"><\/i> Neural pulses<\/span><\/div><\/article><\/div>\n    <\/section>\n  <\/div>\n<script>\n\/*\n * A deliberately small, inspectable rigid-arm model.\n *\n * Coordinates are in meters, with +x right and +y up. Angle is measured\n * counterclockwise from horizontal. Torque in the flexion direction is +.\n * A single straight-line muscle runs from a fixed origin on the upper arm\n * to a movable insertion on the forearm. It has no tendon elasticity.\n *\n * Activation sums difference-of-exponential twitches, capped at one.\n * Recruitment scales force independently; the proximal ulna is visual only.\n *\/\n(function (root) {\n  'use strict';\n\n  const C = Object.freeze({\n    gravity: 9.81,              \/\/ m \/ s^2\n    forearmLength: 0.34,       \/\/ m, elbow to hand\n    ulnaExtension: 0.04,       \/\/ m, proximal projection opposite the hand\n    forearmMass: 1.1,          \/\/ kg; uniform slender rod\n    muscleOriginX: 0,    \/\/ m, relative to elbow\n    muscleOriginY: 0.9 * (210.3 \/ 610), \/\/ m; 90% of the rendered elbow\u2013shoulder distance\n    maxSpeedMps: 0.45,        \/\/ m\/s; fixed maximum shortening velocity\n    maxShorteningM: 0.110,     \/\/ m; fixed contractile excursion across insertion positions\n    shorteningTaperFraction: 0.30,    \/\/ taper over the final 30% of available excursion\n    jointDamping: 0.14,       \/\/ N m s \/ rad\n    minAngleDeg: 0,\n    maxAngleDeg: 85,          \/\/ stay below vertical so gravity always returns the arm\n    startAngleDeg: 0,\n    contractionTime: 0.025,   \/\/ s, fast twitch rise\n    relaxationTime: 0.12,     \/\/ s, slower twitch decay\n    twitchPeak: 0.75,         \/\/ fraction of recruited isometric capacity\n    step: 1 \/ 240\n  });\n\n  const defaults = Object.freeze({\n    insertionCm: 10,\n    loadMassKg: 0.75,\n    loadPositionCm: 29,\n    maxForceN: 200,\n    recruitment: 1.0,\n    frequencyHz: 20,\n    trainDuration: 1.0\n  });\n\n  const rad = degrees => degrees * Math.PI \/ 180;\n  const deg = radians => radians * 180 \/ Math.PI;\n  const clamp = (value, lo, hi) => Math.max(lo, Math.min(hi, value));\n\n  function createState() {\n    return {\n      t: 0,\n      theta: rad(C.startAngleDeg),\n      omega: 0,\n      activation: 0,\n      pulseTimes: []\n    };\n  }\n\n  \/\/ Each train captures its settings and starts on the continuous clock.\n  \/\/ The train interval is half-open: [startTime, startTime + duration).\n  function pulseSchedule(mode, params, startTime) {\n    if (mode === 'single') return [startTime];\n    const count = Math.ceil(params.frequencyHz * params.trainDuration - 1e-9);\n    return Array.from({length:count}, (_, i) => startTime + i \/ params.frequencyHz);\n  }\n\n  const peakTime = Math.log(C.relaxationTime \/ C.contractionTime) \/\n    (1 \/ C.contractionTime - 1 \/ C.relaxationTime);\n  const peakKernel = Math.exp(-peakTime \/ C.relaxationTime) - Math.exp(-peakTime \/ C.contractionTime);\n\n  function activationAt(time, pulseTimes) {\n    let sum = 0;\n    for (const pulse of pulseTimes) {\n      const age = time - pulse;\n      if (age < 0) break;\n      sum += C.twitchPeak * (Math.exp(-age \/ C.relaxationTime) -\n        Math.exp(-age \/ C.contractionTime)) \/ peakKernel;\n    }\n    \/\/ Saturation limits temporal summation, not recruitment or the existing\n    \/\/ eccentric force\u2013velocity multiplier (which can exceed isometric force).\n    return clamp(sum, 0, 1);\n  }\n\n  function geometry(theta, params) {\n    const r = params.insertionCm \/ 100;\n    const ix = r * Math.cos(theta);\n    const iy = r * Math.sin(theta);\n    const dx = C.muscleOriginX - ix;\n    const dy = C.muscleOriginY - iy;\n    const length = Math.hypot(dx, dy);\n    \/\/ Torque from unit force at the insertion: r x Fhat.\n    const momentArm = (ix * dy - iy * dx) \/ length;\n    return { insertionX: ix, insertionY: iy, length, momentArm };\n  }\n\n  \/\/ Simplified Hill-like concentric force\/velocity relation. At vmax,\n  \/\/ the active force drops to zero; lengthening gives up to 1.5 x force.\n  function forceVelocityFactor(shorteningSpeed, vmax) {\n    const speed = shorteningSpeed \/ vmax;\n    if (speed >= 0) {\n      return clamp((1 - speed) \/ (1 + 4 * speed), 0, 1);\n    }\n    return 1 + 0.5 * (1 - Math.exp(Math.max(-30, speed \/ 0.2)));\n  }\n\n  function measure(state, params) {\n    const geo = geometry(state.theta, params);\n    \/\/ d(muscle length)\/d(theta) = -momentArm. Thus positive angular\n    \/\/ velocity shortens the muscle if its moment arm is positive.\n    const shorteningSpeed = geo.momentArm * state.omega;\n    const velocityFactor = forceVelocityFactor(shorteningSpeed, C.maxSpeedMps);\n    \/\/ Geometry sets the starting path length, not the contractile capacity.\n    \/\/ Effective fibers of about 28 cm shortening by 40% provide 11 cm.\n    \/\/ At 10 cm insertion, 70 degrees requires 10.7 cm of path shortening.\n    \/\/ The final 30% tapers smoothly, setting a load-dependent equilibrium.\n    \/\/ Changing insertion preserves this capacity, not the attainable angle.\n    const initialLength = geometry(rad(C.startAngleDeg), params).length;\n    const shortening = initialLength - geo.length;\n    const availableShortening = C.maxShorteningM;\n    const remaining = clamp((availableShortening - shortening) \/\n      (availableShortening * C.shorteningTaperFraction), 0, 1);\n    \/\/ Smoothstep: full force before the taper, zero at\/beyond the fixed shortening limit.\n    \/\/ No position or velocity clamp: inertia can carry the arm past the force-producing range.\n    const excursionFactor = remaining * remaining * (3 - 2 * remaining);\n    const muscleForce = params.maxForceN * params.recruitment * state.activation * velocityFactor * excursionFactor;\n    const muscleTorque = muscleForce * geo.momentArm;\n    const loadR = params.loadPositionCm \/ 100;\n    const gravitationalTorque = -C.gravity * (\n      C.forearmMass * C.forearmLength \/ 2 + params.loadMassKg * loadR\n    ) * Math.cos(state.theta);\n    const dampingTorque = -C.jointDamping * state.omega;\n    const inertia = C.forearmMass * C.forearmLength ** 2 \/ 3 +\n      params.loadMassKg * loadR ** 2;\n    return {\n      ...geo,\n      angleDeg: deg(state.theta),\n      angularVelocityDegS: deg(state.omega),\n      timeS: state.t,\n      activation: state.activation,\n      muscleForce,\n      muscleTorque,\n      gravitationalTorque,\n      dampingTorque,\n      netTorque: muscleTorque + gravitationalTorque + dampingTorque,\n      shorteningSpeed,\n      shortening,\n      availableShortening,\n      excursionFactor,\n      inertia\n    };\n  }\n\n  \/\/ Semi-implicit Euler at a fixed, small timestep is ample for this\n  \/\/ one-degree-of-freedom educational model.\n  function step(state, params, dt = C.step) {\n    state.activation = activationAt(state.t, state.pulseTimes);\n\n    const m = measure(state, params);\n    state.omega += (m.netTorque \/ m.inertia) * dt;\n    state.theta += state.omega * dt;\n    state.t += dt;\n    state.activation = activationAt(state.t, state.pulseTimes);\n\n    const minA = rad(C.minAngleDeg);\n    const maxA = rad(C.maxAngleDeg);\n    if (state.theta < minA) {\n      state.theta = minA;\n      if (state.omega < 0) state.omega = 0;\n    }\n    if (state.theta > maxA) {\n      state.theta = maxA;\n      if (state.omega > 0) state.omega = 0;\n    }\n    return state;\n  }\n\n  const api = { C, defaults, rad, deg, clamp, createState, geometry,\n    forceVelocityFactor, measure, step, pulseSchedule, activationAt };\n  root.ArmPhysics = api;\n  if (typeof module !== 'undefined' && module.exports) module.exports = api;\n})(typeof globalThis !== 'undefined' ? globalThis : this);\n\n<\/script>\n<script>\n\/* Browser-only, dependency-free view layer. *\/\n(function () {\n  'use strict';\n\n  const P = window.ArmPhysics;\n  const { C, defaults, rad, deg, clamp } = P;\n  const $ = id => document.getElementById(id);\n  const params = { ...defaults };\n  const state = P.createState();\n  const plotWindow = 10; \/\/ seconds; independent of the unbounded simulation clock\n  let running = false;\n  let started = false;\n  let elapsedAccumulator = 0;\n  let lastFrame = null;\n  let history = []; \/\/ Complete session, with absolute timestamps, for CSV export.\n  let visibleStart = 0;\n  let unrecordedPulses = [];\n  let drawTimer = 0;\n  let peakAngleDeg = 0;\n  let trackingPeak = false;\n\n  const controls = [\n    ['insertionCm', n => `${n.toFixed(1).replace('.0','')} cm`],\n    ['loadPositionCm', n => `${n.toFixed(0)} cm`],\n    ['loadMassKg', n => `${n.toFixed(2)} kg`],\n    ['maxForceN', n => `${n.toFixed(0)} N`],\n    ['recruitment', n => `${Math.round(n * 100)}%`],\n    ['frequencyHz', n => `${n.toFixed(0)} Hz`],\n    ['trainDuration', n => `${n.toFixed(1)} s`]\n  ];\n\n  const ui = {\n    bone: $('forearmBone'), boneShadow: $('boneShadow'),\n    hand: $('handMarker'), load: $('loadMarker'),\n    muscle: $('muscleLine'), insertion: $('insertionMarker'),\n    gravity: $('gravityLine'), angleArc: $('angleArc'), angleLabel: $('angleLabel'),\n    status: $('status'), statusText: $('statusText'), pause: $('pauseButton')\n  };\n\n  function record() {\n    const m = P.measure(state, params);\n    const pulseTimes = unrecordedPulses.filter(t => t <= state.t);\n    unrecordedPulses = unrecordedPulses.filter(t => t > state.t);\n    \/\/ A click at the latest sample time adds its event without duplicating data.\n    if (history.length && history[history.length - 1].timeS === state.t) {\n      pulseTimes.unshift(...history.pop().pulseTimes);\n    }\n    history.push({\n      timeS: m.timeS, angleDeg: m.angleDeg,\n      angularVelocityDegS: m.angularVelocityDegS,\n      muscleTorque: m.muscleTorque,\n      gravitationalTorque: m.gravitationalTorque,\n      muscleForce: m.muscleForce,\n      momentArmCm: m.momentArm * 100,\n      activation: m.activation,\n      shorteningCm: m.shortening * 100,\n      pulseTimes,\n      recruitment: params.recruitment,\n      frequencyHz: params.frequencyHz,\n      trainDuration: params.trainDuration\n    });\n    const left = state.t - plotWindow;\n    \/\/ Retain one sample beyond the boundary for a continuous clipped line.\n    while (visibleStart + 1 < history.length && history[visibleStart + 1].timeS < left) visibleStart++;\n    \/\/ Only the display cursor advances; older samples remain available to export.\n    \/\/ At 10 s the slow twitch tail is below 1e-35 of capacity per pulse.\n    \/\/ Dropping it bounds both computation and storage during indefinite runs.\n    state.pulseTimes = state.pulseTimes.filter(t => t >= left);\n  }\n\n  function reset() {\n    running = false;\n    started = false;\n    Object.assign(state, P.createState());\n    peakAngleDeg = 0;\n    trackingPeak = false;\n    elapsedAccumulator = 0;\n    drawTimer = 0;\n    lastFrame = null;\n    history = [];\n    visibleStart = 0;\n    unrecordedPulses = [];\n    record();\n    setRunningUI();\n    updateVisualization();\n    renderCharts();\n  }\n\n  function setRunningUI() {\n    ui.status.classList.toggle('running', running);\n    ui.statusText.textContent = running ? 'RUNNING' : started ? 'PAUSED' : 'READY';\n    ui.pause.textContent = running ? 'Pause' : 'Resume';\n  }\n\n  controls.forEach(([name, fmt]) => {\n    $(name).addEventListener('input', ev => {\n      const value = Number(ev.target.value);\n      if (value === params[name]) return;\n      params[name] = value;\n      $(name + 'Value').textContent = fmt(value);\n      updateVisualization();\n    });\n  });\n\n  function resume() {\n    running = true;\n    started = true;\n    lastFrame = null;\n    setRunningUI();\n  }\n\n  function stimulate(mode) {\n    \/\/ Start a new observation window without altering the physical state.\n    peakAngleDeg = deg(state.theta);\n    trackingPeak = true;\n    const pulses = P.pulseSchedule(mode, params, state.t);\n    \/\/ Merge overlapping trains chronologically; coincident pulses both count.\n    state.pulseTimes.push(...pulses);\n    state.pulseTimes.sort((a, b) => a - b);\n    unrecordedPulses.push(...pulses);\n    unrecordedPulses.sort((a, b) => a - b);\n    if (!started) resume();\n    if (running) { record(); renderCharts(); }\n    updateVisualization();\n  }\n  $('singleButton').addEventListener('click', () => stimulate('single'));\n  $('trainButton').addEventListener('click', () => stimulate('train'));\n  ui.pause.addEventListener('click', () => {\n    if (!running) { resume(); return; }\n    running = false;\n    lastFrame = null;\n    setRunningUI();\n    updateVisualization();\n    renderCharts();\n  });\n  $('resetButton').addEventListener('click', reset);\n  $('csvButton').addEventListener('click', exportCSV);\n\n  const scale = 610;\n  const elbow = { x:260, y:350 };\n  const project = (x, y) => ({ x: elbow.x + scale * x, y: elbow.y - scale * y });\n  const origin = project(C.muscleOriginX, C.muscleOriginY);\n  const forearmLengthPx = scale * C.forearmLength;\n  const attr = (element, attributes) => {\n    Object.entries(attributes).forEach(([key, value]) => element.setAttribute(key, String(value)));\n  };\n  const line = (element, a, b) => attr(element, {x1:a.x, y1:a.y, x2:b.x, y2:b.y});\n\n  attr($('originMarker'), {cx:origin.x, cy:origin.y});\n\n  function updateVisualization() {\n    const m = P.measure(state, params);\n    const hand = project(C.forearmLength * Math.cos(state.theta), C.forearmLength * Math.sin(state.theta));\n    const proximal = project(-C.ulnaExtension * Math.cos(state.theta), -C.ulnaExtension * Math.sin(state.theta));\n    const insertion = project(m.insertionX, m.insertionY);\n    const loadR = params.loadPositionCm \/ 100;\n    const load = project(loadR * Math.cos(state.theta), loadR * Math.sin(state.theta));\n    line(ui.boneShadow, proximal, hand);\n    line(ui.bone, proximal, hand);\n    attr(ui.hand, {cx:hand.x, cy:hand.y});\n    attr(ui.insertion, {cx:insertion.x,cy:insertion.y});\n    \/\/ Side length is proportional to sqrt(mass), so area represents mass.\n    const loadScale = Math.sqrt(params.loadMassKg \/ 0.75);\n    const loadHalfSize = 15 * loadScale;\n    attr(ui.load, {transform:`translate(${load.x} ${load.y}) scale(${loadScale})`});\n    ui.load.style.opacity = params.loadMassKg === 0 ? '0' : '1';\n    \/\/ Resting diameter scales with sqrt(strength): 10\u201324.5 px for 40\u2013240 N.\n    \/\/ Geometric shortening adds subtle thickening; neither width affects physics.\n    const restingLength = P.geometry(rad(C.startAngleDeg), params).length;\n    line(ui.muscle, origin, insertion);\n    const restingWidth = 10 * Math.sqrt(params.maxForceN \/ 40);\n    attr(ui.muscle, {'stroke-width':restingWidth + 6 * clamp(1 - m.length \/ restingLength, 0, 1)});\n    line(ui.gravity, {x:load.x,y:load.y + loadHalfSize + 6}, {x:load.x,y:load.y + loadHalfSize + 57});\n    ui.gravity.style.opacity = params.loadMassKg === 0 ? '0' : '1';\n    const rr = 43;\n    const a0 = -state.theta;\n    const startX = elbow.x + rr, startY = elbow.y;\n    const endX = elbow.x + rr * Math.cos(a0), endY = elbow.y + rr * Math.sin(a0);\n    ui.angleArc.setAttribute('d', `M ${startX} ${startY} A ${rr} ${rr} 0 0 0 ${endX} ${endY}`);\n    attr(ui.angleLabel,{x:elbow.x+75,y:elbow.y+31});\n    ui.angleLabel.textContent = `${m.angleDeg.toFixed(0)}\u00b0`;\n    const staticTorque = P.geometry(0, params).momentArm * params.maxForceN * params.recruitment;\n    $('staticTorqueReadout').textContent = `${staticTorque.toFixed(1)} N\u00b7m`;\n    $('peakAngleReadout').textContent = `${peakAngleDeg.toFixed(1)}\u00b0`;\n    $('angleReadout').textContent = `${m.angleDeg.toFixed(1)}\u00b0`;\n    $('speedReadout').textContent = `${m.angularVelocityDegS.toFixed(1)} \u00b0\/s`;\n    $('forceReadout').textContent = `${m.muscleForce.toFixed(1)} N`;\n    $('momentReadout').textContent = `${(m.momentArm*100).toFixed(1)} cm`;\n    $('shorteningReadout').textContent = `${(m.shortening * 100).toFixed(2)} cm`;\n    $('timeReadout').textContent = `${m.timeS.toFixed(2)} s`;\n  }\n\n  const chartConfigs = [\n    {id:'angleChart', min:0, max:120, tick:30, fields:[['angleDeg','#71d5c8']]},\n    {id:'torqueChart', min:-30, max:30, tick:15, fields:[['muscleTorque','#71d5c8'],['gravitationalTorque','#e8b77c']]},\n    {id:'velocityChart', min:-450, max:450, tick:225, fields:[['angularVelocityDegS','#8ab7f2']]},\n    {id:'forceChart', min:0, max:360, tick:90, fields:[['muscleForce','#71d5c8']]}\n  ];\n\n  function drawChart(conf, windowStart, windowEnd) {\n    const canvas = $(conf.id);\n    const width = Math.max(200,canvas.clientWidth);\n    const height = Math.max(110,canvas.clientHeight);\n    const pixelRatio = Math.max(1,window.devicePixelRatio || 1);\n    canvas.width = Math.round(width*pixelRatio);\n    canvas.height = Math.round(height*pixelRatio);\n    const ctx = canvas.getContext('2d');\n    ctx.scale(pixelRatio,pixelRatio);\n    const M = {l:39, r:13, t:10, b:29};\n    const pw = width - M.l - M.r;\n    const ph = height - M.t - M.b;\n    const relativeX = secondsAgo => M.l + (secondsAgo + plotWindow) \/ plotWindow * pw;\n    const x = time => relativeX(time - windowEnd);\n    const y = value => M.t + (conf.max - value)\/(conf.max-conf.min) * ph;\n    ctx.font = '10px ui-monospace, SFMono-Regular, Consolas, monospace';\n    ctx.textAlign='right';ctx.textBaseline='middle';\n    ctx.lineWidth=1;\n    for(let value=conf.min;value<=conf.max+.001;value+=conf.tick){\n      const yy=y(value);\n      ctx.strokeStyle=value===0?'#3c5266':'#233345';\n      ctx.beginPath();ctx.moveTo(M.l,yy);ctx.lineTo(width-M.r,yy);ctx.stroke();\n      ctx.fillStyle='#7e91a7'; ctx.fillText(String(value),M.l-8,yy);\n    }\n    ctx.textAlign='center';ctx.textBaseline='top';\n    for(let t=-plotWindow;t<=0;t+=2){\n      const xx=relativeX(t);\n      ctx.fillStyle='#7e91a7'; ctx.fillText(String(t),xx,height-M.b+8);\n    }\n    ctx.fillStyle='#7e91a7';ctx.fillText('Time (s)',M.l+pw\/2,height-11);\n    ctx.save();ctx.beginPath();ctx.rect(M.l,M.t,pw,ph);ctx.clip();\n    conf.fields.forEach(([field,color]) => {\n      if(history.length<2) return;\n      ctx.beginPath();\n      for (let i=visibleStart; i<history.length; i++) {\n        const entry=history[i];\n        const xx=x(entry.timeS), yy=y(entry[field]);\n        if (i === visibleStart) ctx.moveTo(xx,yy); else ctx.lineTo(xx,yy);\n      }\n      ctx.strokeStyle = color;\n      ctx.lineWidth = 2.2;\n      ctx.stroke();\n    });\n    if (conf.id === 'forceChart') {\n      ctx.strokeStyle = '#e8b77c';\n      ctx.lineWidth = 1;\n      ctx.beginPath();\n      state.pulseTimes.forEach(t => {\n        if (t < windowStart || t > windowEnd) return;\n        ctx.moveTo(x(t), M.t); ctx.lineTo(x(t), M.t + 10);\n      });\n      ctx.stroke();\n    }\n    ctx.restore();\n  }\n\n  function renderCharts() {\n    \/\/ Before 10 s, blank space precedes t=0; the newest sample is always rightmost.\n    const windowEnd = state.t;\n    const windowStart = windowEnd - plotWindow;\n    chartConfigs.forEach(conf => drawChart(conf, windowStart, windowEnd));\n  }\n\n  function exportCSV() {\n    const headers = ['time_s','angle_deg','angular_velocity_deg_s',\n      'muscle_torque_Nm','gravity_torque_Nm','muscle_force_N','moment_arm_cm','activation','neural_pulse_times_s','recruitment','frequency_hz','train_duration_s','shortening_cm'];\n    const rows = [headers.join(',')];\n    history.forEach(v => rows.push([\n      v.timeS, v.angleDeg,v.angularVelocityDegS,v.muscleTorque,\n      v.gravitationalTorque,v.muscleForce,v.momentArmCm,v.activation\n    ].map(num=>num.toFixed(5)).concat([v.pulseTimes.join(';'),v.recruitment,\n      v.frequencyHz,v.trainDuration,v.shorteningCm.toFixed(5)]).join(',')));\n    const blob = new Blob([rows.join('\\n')+'\\n'],{type:'text\/csv;charset=utf-8'});\n    const url=URL.createObjectURL(blob);\n    const a=document.createElement('a');a.href=url;a.download='motor_arm_history.csv';\n    document.body.appendChild(a);a.click();a.remove();\n    setTimeout(()=>URL.revokeObjectURL(url),1000);\n  }\n\n  function animate(timestamp) {\n    requestAnimationFrame(animate);\n    if(!running) return;\n    if(lastFrame === null) lastFrame=timestamp;\n    let dt=Math.min((timestamp-lastFrame)\/1000,0.06);\n    lastFrame=timestamp;\n    elapsedAccumulator+=dt;\n    while(elapsedAccumulator>=C.step){\n      P.step(state,params,C.step);\n      if (trackingPeak) peakAngleDeg = Math.max(peakAngleDeg, deg(state.theta));\n      elapsedAccumulator-=C.step;\n      record(); \/\/ 240 Hz sampling resolves twitches and 50 Hz pulse trains.\n    }\n    drawTimer+=dt;\n    if(drawTimer>=1\/30){\n      updateVisualization();renderCharts();drawTimer=0;\n    }\n\n  }\n\n  window.addEventListener('resize',renderCharts);\n  document.addEventListener('visibilitychange',()=>{lastFrame=null;});\n  reset();\n  requestAnimationFrame(animate);\n})();\n\n<\/script>\n<\/body>\n<\/html>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Muscles and Levers Muscles and Levers Muscle insertion10 cm Load position29 cm Load mass0.75 kg0 kg5 kg Muscle strength200 N40 N240 N Motor unit recruitment100%10%100% Pulse frequency \u00b7 train20 Hz1 Hz50 Hz Train duration1.0 s0.2 s2 s Single pulsePulse train Resume\u21bb Reset READY 0\u00b0 MAXIMUM STATIC MUSCLE TORQUE \u00b7 AT 0\u00b00.0 N\u00b7m PEAK ELBOW ANGLE [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5035","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/faculty.fiu.edu\/~theobald\/wp-json\/wp\/v2\/pages\/5035","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/faculty.fiu.edu\/~theobald\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/faculty.fiu.edu\/~theobald\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/faculty.fiu.edu\/~theobald\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/faculty.fiu.edu\/~theobald\/wp-json\/wp\/v2\/comments?post=5035"}],"version-history":[{"count":4,"href":"https:\/\/faculty.fiu.edu\/~theobald\/wp-json\/wp\/v2\/pages\/5035\/revisions"}],"predecessor-version":[{"id":5039,"href":"https:\/\/faculty.fiu.edu\/~theobald\/wp-json\/wp\/v2\/pages\/5035\/revisions\/5039"}],"wp:attachment":[{"href":"https:\/\/faculty.fiu.edu\/~theobald\/wp-json\/wp\/v2\/media?parent=5035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}