Hyperbola III: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(41 intermediate revisions by the same user not shown)
Line 1: Line 1:
Example and visualization for principal axis transformation
<jsxgraph width="500" height="500">
<jsxgraph width="500" height="500">
JXG.Options.label.autoPosition = true;
JXG.Options.label.autoPosition = true;
Line 9: Line 10:
const sq5 = Math.sqrt(5);
const sq5 = Math.sqrt(5);


var f1 = board.create('point', [0, -sq5], {name:"f'"});
// Start with the Euclidean normal form of the quadric,
var f2 = board.create('point', [0, sq5], {name:"f"});
// because we easily can read off the focal points.
var p  = board.create('point', [2, Math.sqrt(2)], {name:"p"}); //-0.9428
var f1 = board.create('point', [0, -sq5], {name:"f'", fixed: true});
var o = board.create('point', [0, 0], {withLabel:false, color: 'blue', size:1});
var f2 = board.create('point', [0, sq5], {name:"f", fixed: true});
var e1 = board.create('point', [1, 0], {withLabel:false, color: 'blue', size:1});
var p  = board.create('point', [2, Math.sqrt(2)], {name:"p", fixed: true});
var e2 = board.create('point', [0, 1], {withLabel:false, color: 'blue', size:1});


var phi = board.create('transform', [-Math.PI * 0.25], {type: 'rotate'});
var o = board.create('point', [0, 0], {withLabel:false, color: 'blue', fixed: true, trace:true});
var t = board.create('transform', [-2, 1], {type: 'translate'});
var e1 = board.create('point', [1, 0], {withLabel:false, color: 'blue', fixed: true});
t.applyOnce([f1, f2, p]);
var e2 = board.create('point', [0, 1], {withLabel:false, color: 'blue', fixed: true});
phi.applyOnce([f1, f2, p]);


// Undo the principal axis transformation to recompute the original form of the quadric
var phi0 = board.create('transform', [-Math.PI * 0.25], {type: 'rotate'});
var t0 = board.create('transform', [-2, 1], {type: 'translate'});
t0.bindTo([f1, f2, p, o, e1, e2]);
phi0.bindTo([f1, f2, p, o, e1, e2]);


var hyp = board.create('hyperbola', [f1, f2, p]);
var hyp = board.create('hyperbola', [f1, f2, p]);


var ax_z1 = board.create('line', [[-2, 1], [-1, 2]], {lastArrow: true, strokeColor:'black'});
// Create transformed axes
var ax_z2 = board.create('line', [[-2, 1], [-3, 2]], {firstArrow: true, strokeColor:'black'});
var ax_z1 = board.create('line', [o, e1], {lastArrow: true, strokeColor:'black'});
var ax_z2 = board.create('line', [o, e2], {lastArrow: true, strokeColor:'black'});
board.update();
board.update();


// Visualization of the principal axis transformation
var alpha = board.create('slider', [[1,4], [3,4], [0, 0, 45]], {name:'&alpha;', unitLabel:'°'});
var f = board.create('slider', [[1,3.5], [3,3.5], [0, 0, 1]], {name:'f'});


var phi = board.create('transform', [function(){ return alpha.Value() * Math.PI / 180; }], {type: 'rotate'});
var t = board.create('transform', [function(){ return 2*f.Value(); }, function(){ return -f.Value(); }], {type: 'translate'});
phi.bindTo([f1, f2, p, e1, e2, o]);
t.bindTo([f1, f2, p, e1, e2, o]);
</jsxgraph>
</jsxgraph>


=== The underlying JavaScript code ===
=== The underlying JavaScript code ===
<source lang="javascript">
<source lang="javascript">
JXG.Options.label.autoPosition = true;
JXG.Options.text.fontSize = 16;
JXG.Options.line.strokeWidth = 0.8;
JXG.Options.point.size = 1;
var board = JXG.JSXGraph.initBoard('jxgbox', { boundingbox: [-5, 5, 5, -5], axis: true, showClearTraces: true});
const sq5 = Math.sqrt(5);
// Start with the Euclidean normal form of the quadric,
// because we easily can read off the focal points.
var f1 = board.create('point', [0, -sq5], {name:"f'", fixed: true});
var f2 = board.create('point', [0, sq5], {name:"f", fixed: true});
var p  = board.create('point', [2, Math.sqrt(2)], {name:"p", fixed: true});
var o = board.create('point', [0, 0], {withLabel:false, color: 'blue', fixed: true, trace:true});
var e1 = board.create('point', [1, 0], {withLabel:false, color: 'blue', fixed: true});
var e2 = board.create('point', [0, 1], {withLabel:false, color: 'blue', fixed: true});
// Undo the principal axis transformation to recompute the original form of the quadric
var phi0 = board.create('transform', [-Math.PI * 0.25], {type: 'rotate'});
var t0 = board.create('transform', [-2, 1], {type: 'translate'});
t0.bindTo([f1, f2, p, o, e1, e2]);
phi0.bindTo([f1, f2, p, o, e1, e2]);
var hyp = board.create('hyperbola', [f1, f2, p]);
// Create transformed axes
var ax_z1 = board.create('line', [o, e1], {lastArrow: true, strokeColor:'black'});
var ax_z2 = board.create('line', [o, e2], {lastArrow: true, strokeColor:'black'});
board.update();
// Visualization of the principal axis transformation
var alpha = board.create('slider', [[1,4], [3,4], [0, 0, 45]], {name:'&alpha;', unitLabel:'°'});
var f = board.create('slider', [[1,3.5], [3,3.5], [0, 0, 1]], {name:'f'});
var phi = board.create('transform', [function(){ return alpha.Value() * Math.PI / 180; }], {type: 'rotate'});
var t = board.create('transform', [function(){ return 2*f.Value(); }, function(){ return -f.Value(); }], {type: 'translate'});
phi.bindTo([f1, f2, p, e1, e2, o]);
t.bindTo([f1, f2, p, e1, e2, o]);
</source>
</source>


[[Category:Examples]]
[[Category:Examples]]
[[Category:Geometry]]
[[Category:Geometry]]

Latest revision as of 15:45, 6 July 2021

Example and visualization for principal axis transformation

The underlying JavaScript code

JXG.Options.label.autoPosition = true;
JXG.Options.text.fontSize = 16;
JXG.Options.line.strokeWidth = 0.8;
JXG.Options.point.size = 1;

var board = JXG.JSXGraph.initBoard('jxgbox', { boundingbox: [-5, 5, 5, -5], axis: true, showClearTraces: true});

const sq5 = Math.sqrt(5);

// Start with the Euclidean normal form of the quadric,
// because we easily can read off the focal points.
var f1 = board.create('point', [0, -sq5], {name:"f'", fixed: true});
var f2 = board.create('point', [0, sq5], {name:"f", fixed: true});
var p  = board.create('point', [2, Math.sqrt(2)], {name:"p", fixed: true});

var o = board.create('point', [0, 0], {withLabel:false, color: 'blue', fixed: true, trace:true});
var e1 = board.create('point', [1, 0], {withLabel:false, color: 'blue', fixed: true});
var e2 = board.create('point', [0, 1], {withLabel:false, color: 'blue', fixed: true});

// Undo the principal axis transformation to recompute the original form of the quadric
var phi0 = board.create('transform', [-Math.PI * 0.25], {type: 'rotate'});
var t0 = board.create('transform', [-2, 1], {type: 'translate'});
t0.bindTo([f1, f2, p, o, e1, e2]);
phi0.bindTo([f1, f2, p, o, e1, e2]);

var hyp = board.create('hyperbola', [f1, f2, p]);

// Create transformed axes
var ax_z1 = board.create('line', [o, e1], {lastArrow: true, strokeColor:'black'});
var ax_z2 = board.create('line', [o, e2], {lastArrow: true, strokeColor:'black'});
board.update();

// Visualization of the principal axis transformation
var alpha = board.create('slider', [[1,4], [3,4], [0, 0, 45]], {name:'&alpha;', unitLabel:'°'});
var f = board.create('slider', [[1,3.5], [3,3.5], [0, 0, 1]], {name:'f'});

var phi = board.create('transform', [function(){ return alpha.Value() * Math.PI / 180; }], {type: 'rotate'});
var t = board.create('transform', [function(){ return 2*f.Value(); }, function(){ return -f.Value(); }], {type: 'translate'});

phi.bindTo([f1, f2, p, e1, e2, o]);
t.bindTo([f1, f2, p, e1, e2, o]);