Circles on circles

From JSXGraph Wiki
Revision as of 08:44, 30 June 2009 by A WASSERMANN (talk | contribs)

This is an example of a parametric curve plot. The curve is described by the function

[math]\displaystyle{ [0,2\pi]\to{\mathbf R}^2, \quad t\mapsto {\cos(t)\choose \sin(t)}+c_1{\cos(f_1t)\choose \sin(f_1t)}+c_2{\cos(f_2t)\choose \sin(f_2t)} }[/math]

The sliders to adjust the parameters of this curve are from the jQuery UI package, see This example shows the seamless integration of JSXGraph into the web page.

External references

Epicycloidal curves have been used by the ancient greeks to describe the orbits of the planets, see

The source code of this construction

This is the first experiment with the jQuery UI package. So, the code may not be optimized, yet. The main difficulty is to read the values of the sliders. This is done via four JavaScript variables [math]\displaystyle{ c1, c2, f1, f2 }[/math].

<link rel="stylesheet" type="text/css" href="" />
<link rel="Stylesheet" type="text/css" href=""/>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>

<style type="text/css">
		#slider-frame > div.sliders { padding: 10px !important; };
	<script type="text/javascript">
	$(function() {
			orientation: "horizontal",range: "min",min: 0,max: 100,value: 60,
			slide: function(event, ui) {
                                c1 = ui.value*0.01;
			orientation: "horizontal",range: "min",min: 1,max: 100,value: 7,
			slide: function(event, ui) {
                                f1 = ui.value;

			orientation: "horizontal",range: "min",min: 0,max: 100,value: 0,
			slide: function(event, ui) {
                                c2 = ui.value*0.01;
			orientation: "horizontal",range: "min",min: 1,max: 100,value: 17,
			slide: function(event, ui) {
                                f2 = ui.value;

<div class="sliders" style="margin:5px">
    <label for="c1">c1:</label>
    <input type="text" id="c1" style="border:0; color:#f6931f; font-weight:bold;" />
    <label for="f1">f1:</label>
    <input type="text" id="f1" style="border:0; color:#f6931f; font-weight:bold;" />
    <label for="c2">c2:</label>
    <input type="text" id="c2" style="border:0; color:#f6931f; font-weight:bold;" />
    <label for="f2">f2:</label>
    <input type="text" id="f2" style="border:0; color:#f6931f; font-weight:bold;" />
  <div id="sliderc1" style="width:300px;margin:10px;"></div>
  <div id="sliderf1" style="width:300px;margin:10px;"></div>
  <div id="sliderc2" style="width:300px;margin:10px;"></div>
  <div id="sliderf2" style="width:300px;margin:10px;"></div>
<div id="jsxgbox" class="jxgbox" style="width:500px; height:500px;"></div>
<script language="JavaScript"> 			
board = JXG.JSXGraph.initBoard('jsxgbox', {boundingbox:[-2.5,2.5,2.5,-2.5], keepaspectratio:true});
var c1 = 0.6;
var c2 = 0.0; 
var f1 = 7; 
var f2 = 17;
var c = board.createElement('curve', [
              function(t) { return Math.cos(t)+ c1*Math.cos(f1*t)+ c2*Math.cos(f2*t);},
              function(t) { return Math.sin(t)+ c1*Math.sin(f1*t)+ c2*Math.sin(f2*t);},