As far as I can see, this is a mathematical problem:
The angle runs from 0 to 2
, but the function graph is defined in the interval [-![{\displaystyle \pi }](https://ci5.googleusercontent.com/proxy/Yavb_TgUR0XyxhZprVltI3EkApIBBY5nX3496nGpfL3tlz1LylqwA3XO0SRO2G5N6RT6rz9liich42xtWODc3Reak2wrf5pzMDgsHw0MdVrerf30Y2jTteea0WwdQNdCV_X9RTkUjHq29uxDot__JZB0zg=s0-d-e1-ft#https://wikimedia.org/api/rest_v1/media/math/render/svg/9be4ba0bb8df3af72e90a0535fabcc17431e540a)
,
![{\displaystyle \pi }](https://ci5.googleusercontent.com/proxy/Yavb_TgUR0XyxhZprVltI3EkApIBBY5nX3496nGpfL3tlz1LylqwA3XO0SRO2G5N6RT6rz9liich42xtWODc3Reak2wrf5pzMDgsHw0MdVrerf30Y2jTteea0WwdQNdCV_X9RTkUjHq29uxDot__JZB0zg=s0-d-e1-ft#https://wikimedia.org/api/rest_v1/media/math/render/svg/9be4ba0bb8df3af72e90a0535fabcc17431e540a)
].
If you insist on the function graph being defined in that interval, the angle has to be transformed accordingly.
There, I also exploited the dynamic nature of JSXGraph: the position of the point wg can be defined by functions
which calculate x-, and y-coordinates and the two boards can be connected with circle.addChild(circleWave):
Here is the code:
const circle = JXG.JSXGraph.initBoard('circle', {
boundingbox: [-1.5, 1.5, 1.5, -1.5], axis:true
});
const circleWave = JXG.JSXGraph.initBoard('wave', {
boundingbox: [-Math.PI, 1.5, Math.PI, -1.5], axis:true, keepAspectRatio: true
});
var cp, c1, cg, cs, angleStart, ca,
cWave, wg;
cp = circle.create('point', [0, 0], {name: '', fixed: true});
c1 = circle.create('circle', [cp, 1]);
cg = circle.create('glider', [0.5, 1, c1]);
cs = circle.create('segment', [cp, cg]);
angleStart = circle.create('point', [1, 0], {fixed: true, visible: false});
ca = circle.create('angle', [angleStart, cp, cg], {
name: () => JXG.toFixed(JXG.Math.Geometry.rad(angleStart, cp, cg), 2)
});
cWave = circleWave.create('functiongraph', (x) => Math.sin(x));
// Determine the position of wg dynmically from angle ca.
wg = circleWave.create('point', [
function() {
var alpha = ca.Value();
// Transform the angle to [-pi, pi]
return (alpha > Math.PI) ? (alpha - 2 * Math.PI) : alpha;
},
() => Math.sin(ca.Value())
]);
// Update circleWave if circle is updated
circle.addChild(circleWave);
Best wishes,
Alfred