<iframe src="https://jsxgraph.org/share/iframe/approximate-circular-arc-by-a-b-zier-curve" style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" name="JSXGraph example: Approximate circular arc by a Bézier curve" allowfullscreen ></iframe>
<div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; "> <div id="board-0" class="jxgbox" style="aspect-ratio: 1 / 1; width: 100%;" data-ar="1 / 1"></div> </div> <script type = "text/javascript"> /* This example is licensed under a Creative Commons Attribution 4.0 International License. https://creativecommons.org/licenses/by/4.0/ Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits. */ const BOARDID = 'board-0'; const board = JXG.JSXGraph.initBoard(BOARDID, { axis: false, boundingbox: [-2, 2, 2, -2], keepaspectratio: true }); // Create circle through D with center M and to gliders A and B var M = board.create('point', [0, 0], { name: 'M' }); var C = board.create('point', [0, -1], { name: 'D' }); var c = board.create('circle', [M, C], { strokeWidth: 1 }); var A = board.create('glider', [1, 0, c], { name: 'A' }); var B = board.create('glider', [0, 1, c], { name: 'B' }); // Determine two optimal control points var k = function(M, A, B) { var ax = A.X() - M.X(), ay = A.Y() - M.Y(), bx = B.X() - M.X(), by = B.Y() - M.Y(), d, r; r = M.Dist(A); d = Math.sqrt((ax + bx) * (ax + bx) + (ay + by) * (ay + by)); if (JXG.Math.Geometry.rad(A, M, B) > Math.PI) { d *= -1; } if (Math.abs(by - ay) > JXG.Math.eps) { return (ax + bx) * (r / d - 0.5) * 8.0 / 3.0 / (by - ay); } else { return (ay + by) * (r / d - 0.5) * 8.0 / 3.0 / (ax - bx); } }; var P1 = board.create('point', [ () => A.X() - k(M, A, B) * (A.Y() - M.Y()), () => A.Y() + k(M, A, B) * (A.X() - M.X()) ], { color: 'blue' }); var P2 = board.create('point', [ () => B.X() + k(M, A, B) * (B.Y() - M.Y()), () => B.Y() - k(M, A, B) * (B.X() - M.X()) ], { color: 'blue' }); // Create the Bezier segment var b = board.create('curve', JXG.Math.Numerics.bezier([A, P1, P2, B]), { strokecolor: 'black', strokeOpacity: 1, strokeWidth: 3 }); var l1 = board.create('segment', [A, P1], { dash: 2 }); var l2 = board.create('segment', [B, P2], { dash: 2 }); </script>
/* This example is licensed under a Creative Commons Attribution 4.0 International License. https://creativecommons.org/licenses/by/4.0/ Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits. */ const BOARDID = 'your_div_id'; // Insert your id here! const board = JXG.JSXGraph.initBoard(BOARDID, { axis: false, boundingbox: [-2, 2, 2, -2], keepaspectratio: true }); // Create circle through D with center M and to gliders A and B var M = board.create('point', [0, 0], { name: 'M' }); var C = board.create('point', [0, -1], { name: 'D' }); var c = board.create('circle', [M, C], { strokeWidth: 1 }); var A = board.create('glider', [1, 0, c], { name: 'A' }); var B = board.create('glider', [0, 1, c], { name: 'B' }); // Determine two optimal control points var k = function(M, A, B) { var ax = A.X() - M.X(), ay = A.Y() - M.Y(), bx = B.X() - M.X(), by = B.Y() - M.Y(), d, r; r = M.Dist(A); d = Math.sqrt((ax + bx) * (ax + bx) + (ay + by) * (ay + by)); if (JXG.Math.Geometry.rad(A, M, B) > Math.PI) { d *= -1; } if (Math.abs(by - ay) > JXG.Math.eps) { return (ax + bx) * (r / d - 0.5) * 8.0 / 3.0 / (by - ay); } else { return (ay + by) * (r / d - 0.5) * 8.0 / 3.0 / (ax - bx); } }; var P1 = board.create('point', [ () => A.X() - k(M, A, B) * (A.Y() - M.Y()), () => A.Y() + k(M, A, B) * (A.X() - M.X()) ], { color: 'blue' }); var P2 = board.create('point', [ () => B.X() + k(M, A, B) * (B.Y() - M.Y()), () => B.Y() - k(M, A, B) * (B.X() - M.X()) ], { color: 'blue' }); // Create the Bezier segment var b = board.create('curve', JXG.Math.Numerics.bezier([A, P1, P2, B]), { strokecolor: 'black', strokeOpacity: 1, strokeWidth: 3 }); var l1 = board.create('segment', [A, P1], { dash: 2 }); var l2 = board.create('segment', [B, P2], { dash: 2 });
<jsxgraph width="100%" aspect-ratio="1 / 1" title="Approximate circular arc by a Bézier curve" description="This construction was copied from JSXGraph examples database: BTW HERE SHOULD BE A GENERATED LINKuseGlobalJS="false"> /* This example is licensed under a Creative Commons Attribution 4.0 International License. https://creativecommons.org/licenses/by/4.0/ Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits. */ const board = JXG.JSXGraph.initBoard(BOARDID, { axis: false, boundingbox: [-2, 2, 2, -2], keepaspectratio: true }); // Create circle through D with center M and to gliders A and B var M = board.create('point', [0, 0], { name: 'M' }); var C = board.create('point', [0, -1], { name: 'D' }); var c = board.create('circle', [M, C], { strokeWidth: 1 }); var A = board.create('glider', [1, 0, c], { name: 'A' }); var B = board.create('glider', [0, 1, c], { name: 'B' }); // Determine two optimal control points var k = function(M, A, B) { var ax = A.X() - M.X(), ay = A.Y() - M.Y(), bx = B.X() - M.X(), by = B.Y() - M.Y(), d, r; r = M.Dist(A); d = Math.sqrt((ax + bx) * (ax + bx) + (ay + by) * (ay + by)); if (JXG.Math.Geometry.rad(A, M, B) > Math.PI) { d *= -1; } if (Math.abs(by - ay) > JXG.Math.eps) { return (ax + bx) * (r / d - 0.5) * 8.0 / 3.0 / (by - ay); } else { return (ay + by) * (r / d - 0.5) * 8.0 / 3.0 / (ax - bx); } }; var P1 = board.create('point', [ () => A.X() - k(M, A, B) * (A.Y() - M.Y()), () => A.Y() + k(M, A, B) * (A.X() - M.X()) ], { color: 'blue' }); var P2 = board.create('point', [ () => B.X() + k(M, A, B) * (B.Y() - M.Y()), () => B.Y() - k(M, A, B) * (B.X() - M.X()) ], { color: 'blue' }); // Create the Bezier segment var b = board.create('curve', JXG.Math.Numerics.bezier([A, P1, P2, B]), { strokecolor: 'black', strokeOpacity: 1, strokeWidth: 3 }); var l1 = board.create('segment', [A, P1], { dash: 2 }); var l2 = board.create('segment', [B, P2], { dash: 2 }); </jsxgraph>
// Define the id of your board in BOARDID const board = JXG.JSXGraph.initBoard(BOARDID, { axis: false, boundingbox: [-2, 2, 2, -2], keepaspectratio: true }); // Create circle through D with center M and to gliders A and B var M = board.create('point', [0, 0], { name: 'M' }); var C = board.create('point', [0, -1], { name: 'D' }); var c = board.create('circle', [M, C], { strokeWidth: 1 }); var A = board.create('glider', [1, 0, c], { name: 'A' }); var B = board.create('glider', [0, 1, c], { name: 'B' }); // Determine two optimal control points var k = function(M, A, B) { var ax = A.X() - M.X(), ay = A.Y() - M.Y(), bx = B.X() - M.X(), by = B.Y() - M.Y(), d, r; r = M.Dist(A); d = Math.sqrt((ax + bx) * (ax + bx) + (ay + by) * (ay + by)); if (JXG.Math.Geometry.rad(A, M, B) > Math.PI) { d *= -1; } if (Math.abs(by - ay) > JXG.Math.eps) { return (ax + bx) * (r / d - 0.5) * 8.0 / 3.0 / (by - ay); } else { return (ay + by) * (r / d - 0.5) * 8.0 / 3.0 / (ax - bx); } }; var P1 = board.create('point', [ () => A.X() - k(M, A, B) * (A.Y() - M.Y()), () => A.Y() + k(M, A, B) * (A.X() - M.X()) ], { color: 'blue' }); var P2 = board.create('point', [ () => B.X() + k(M, A, B) * (B.Y() - M.Y()), () => B.Y() - k(M, A, B) * (B.X() - M.X()) ], { color: 'blue' }); // Create the Bezier segment var b = board.create('curve', JXG.Math.Numerics.bezier([A, P1, P2, B]), { strokecolor: 'black', strokeOpacity: 1, strokeWidth: 3 }); var l1 = board.create('segment', [A, P1], { dash: 2 }); var l2 = board.create('segment', [B, P2], { dash: 2 });
This example is licensed under a Creative Commons Attribution 4.0 International License. Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits.