Golf Math4U

by pedritomelenas

HTML

<!-- Include JSXGraph -->
<script src="https://cdn.jsdelivr.net/npm/jsxgraph/distrib/jsxgraphcore.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/jsxgraph/distrib/jsxgraph.css">
<!-- Include MathJax -->
<script defer src="https://cdn.jsdelivr.net/npm/mathjax@4/tex-svg.js"></script>

<!-- JSXGraph div -->
<div id="jxgbox" class="jxgbox" style="width:75%;height:auto; min-height: 300px; cursor: crosshair; ">

JavaScript

// Enable MathJax for all JSXGraph elements!
// Use '\\( ... \\)' or '\\[ ... \\]` for LaTeX math text
JXG.Options.text.useMathJax = true;

const board = JXG.JSXGraph.initBoard('jxgbox', {
    boundingbox: [-1, 12, 12, -1],
    axis: true,
    keepaspectratio: true,
    pan: { enabled: true },      // Disable pan for 3D view
    zoom: { enabled: true }      // Disable zoom for 3D view
});

const zero = board.create('point', [0, 0], { name: 'O', size: 3, color: 'black', visible: false });

const p1 = board.create('point',[3,0],{visible:false});
const p2 = board.create('point',[0,3],{visible:false});
var arc = board.create('arc', [zero, p1, p2],{visible:false});

//const A = board.create('point', [1, 1], { name: 'A', size: 3, color: 'green' });
const A=board.create('glider',[3,2,arc]);
const vector = board.create('arrow', [zero, A], { strokeColor: 'red', strokeWidth: 2, name: 'v', fixed: true });
const B = board.create('point', [Math.sqrt(A.X()**2+A.Y()**2), 0], { name: 'B', size: 3, color: 'blue' , visible: false});
const alpha = board.create('angle', [B, zero, A] );
const  t = board.create('text', [2, 1, function() { return JXG.toFixed(alpha.Value(), 2); }]);

let alphaValue = alpha.Value();
let cosAlpha = Math.cos(alpha.Value());
let sinAlpha = Math.sin(alpha.Value());
let v0 = Math.sqrt(A.X()**2 + A.Y()**2);

//let f=() => -9.8/(2*v0**2*cosAlpha**2)*x**2+sinAlpha/cosAlpha*x;

const amplifier = 15;

const parabola1 = board.create("functiongraph",[(x)=>-9.8/(2*amplifier*(A.X()**2+A.Y()**2)*Math.cos(alpha.Value())**2)*x**2+Math.sin(alpha.Value())/Math.cos(alpha.Value())*x,0,100], {strokeColor:'blue', strokeWidth:2,dash:2,visible:false});

const xaxis = board.create('line', [[0, 0], [20, 0]], {visible: false });


const cut = board.create('intersection', [parabola1, xaxis, 1], { name: 'F', size: 3, color: 'purple' });

const parabola =...