1 /* 2 Copyright 2008,2009 3 Matthias Ehmann, 4 Michael Gerhaeuser, 5 Carsten Miller, 6 Bianca Valentin, 7 Alfred Wassermann, 8 Peter Wilfahrt 9 10 This file is part of JSXGraph. 11 12 JSXGraph is free software: you can redistribute it and/or modify 13 it under the terms of the GNU Lesser General Public License as published by 14 the Free Software Foundation, either version 3 of the License, or 15 (at your option) any later version. 16 17 JSXGraph is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU Lesser General Public License for more details. 21 22 You should have received a copy of the GNU Lesser General Public License 23 along with JSXGraph. If not, see <http://www.gnu.org/licenses/>. 24 */ 25 26 JXG.Board.prototype.angle = function(A, B, C){ return JXG.Math.Geometry.angle(A,B,C); }; 27 JXG.Board.prototype.rad = function(A, B, C){ return JXG.Math.Geometry.rad(A,B,C); }; 28 JXG.Board.prototype.distance = function(arr1, arr2){ return JXG.Math.Geometry.distance(arr1,arr2); }; 29 JXG.Board.prototype.pow = function(a, b){ return JXG.Math.pow(a,b); }; 30 JXG.Board.prototype.round = function(x, n){ return (x).toFixed(n); }; 31 JXG.Board.prototype.cosh = function(x){ return JXG.Math.cosh(x); }; 32 JXG.Board.prototype.sinh = function(x){ return JXG.Math.sinh(x); }; 33 JXG.Board.prototype.sgn = function(x) { return (x==0 ? 0 : x/(Math.abs(x))); }; 34 JXG.Board.prototype.D = function(f,obj){ return JXG.Math.Numerics.D(f,obj); }; 35 JXG.Board.prototype.I = function(interval,f){ return JXG.Math.Numerics.I(interval,f); }; 36 JXG.Board.prototype.root = function(f,x,obj){ return JXG.Math.Numerics.root(f,x,obj); }; 37 JXG.Board.prototype.lagrangePolynomial = function(p){ return JXG.Math.Numerics.lagrangePolynomial(p); }; 38 JXG.Board.prototype.neville = function(p){ return JXG.Math.Numerics.Neville(p); }; 39 JXG.Board.prototype.riemannsum = function(f,n,type,start,end){ return JXG.Math.Numerics.riemannsum(f,n,type,start,end); }; 40 41 JXG.Board.prototype.abs = Math.abs; 42 JXG.Board.prototype.acos = Math.acos; 43 JXG.Board.prototype.asin = Math.asin; 44 JXG.Board.prototype.atan = Math.atan; 45 JXG.Board.prototype.ceil = Math.ceil; 46 JXG.Board.prototype.cos = Math.cos; 47 JXG.Board.prototype.exp = Math.exp; 48 JXG.Board.prototype.floor = Math.floor; 49 JXG.Board.prototype.log = Math.log; 50 JXG.Board.prototype.max = Math.max; 51 JXG.Board.prototype.min = Math.min; 52 JXG.Board.prototype.random = Math.random; 53 JXG.Board.prototype.sin = Math.sin; 54 JXG.Board.prototype.sqrt = Math.sqrt; 55 JXG.Board.prototype.tan = Math.tan; 56 JXG.Board.prototype.trunc = Math.ceil; 57 58 JXG.Board.prototype.factorial = function(n){ return JXG.Math.factorial(n); }; 59 JXG.Board.prototype.binomial = function(n,k){ return JXG.Math.binomial(n,k); }; 60 61 // Some shortcuts 62 JXG.Point.prototype.setPositionX = function (method, x) { 63 var y = (method==JXG.COORDS_BY_USER)?this.coords.usrCoords[2]:this.coords.scrCoords[2]; 64 this.setPosition(method,x,y); 65 }; 66 JXG.Point.prototype.setPositionY = function (method, y) { 67 var x = (method==JXG.COORDS_BY_USER)?this.coords.usrCoords[1]:this.coords.scrCoords[1]; 68 this.setPosition(method,x,y); 69 }; 70 JXG.Board.prototype.getElement = function (el) {return JXG.getReference(this,el); }; 71 72 /** 73 * GUI interface 74 **/ 75 JXG.Board.prototype.intersectionOptions = ['point',[[JXG.OBJECT_CLASS_LINE,JXG.OBJECT_CLASS_LINE],[JXG.OBJECT_CLASS_LINE,JXG.OBJECT_CLASS_CIRCLE],[JXG.OBJECT_CLASS_CIRCLE,JXG.OBJECT_CLASS_CIRCLE]]]; 76 JXG.Board.prototype.intersection = function(el1,el2,i,j){ 77 el1 = JXG.getReference(this,el1); 78 el2 = JXG.getReference(this,el2); 79 if (el1.elementClass==JXG.OBJECT_CLASS_CURVE && el2.elementClass==JXG.OBJECT_CLASS_CURVE) { 80 return function(){return JXG.Math.Geometry.meetCurveCurve(el1,el2,i,j,el1.board); }; 81 } else if ((el1.elementClass==JXG.OBJECT_CLASS_CURVE && el2.elementClass==JXG.OBJECT_CLASS_LINE)|| 82 (el2.elementClass==JXG.OBJECT_CLASS_CURVE && el1.elementClass==JXG.OBJECT_CLASS_LINE)) { 83 return function(){return JXG.Math.Geometry.meetCurveLine(el1,el2,i,el1.board); }; 84 } else { 85 return function(){return JXG.Math.Geometry.meet(el1.stdform,el2.stdform,i,el1.board); }; 86 } 87 }; //returns a single point of intersection 88 JXG.Board.prototype.intersectionFunc = function(el1,el2,i,j){ return this.intersection(el1,el2,i,j); }; 89 90 /** 91 * Intersectionof circles and line 92 */ 93 JXG.Board.prototype.otherIntersection = function(el1,el2,el){ 94 el1 = JXG.getReference(this,el1); 95 el2 = JXG.getReference(this,el2); 96 return function(){ 97 var c = JXG.Math.Geometry.meet(el1.stdform,el2.stdform,0,el1.board); 98 if (Math.abs(el.X()-c.usrCoords[1])>JXG.Math.eps || 99 Math.abs(el.Y()-c.usrCoords[2])>JXG.Math.eps || 100 Math.abs(el.Z()-c.usrCoords[0])>JXG.Math.eps) { 101 return c; 102 } else { 103 return JXG.Math.Geometry.meet(el1.stdform,el2.stdform,1,el1.board); 104 } 105 }; 106 }; //returns a single point of intersection 107 108 109 JXG.Board.prototype.pointFunc = function(){return [null];}; 110 JXG.Board.prototype.pointOptions = ['point',[[JXG.OBJECT_CLASS_POINT]]]; 111 112 JXG.Board.prototype.lineFunc = function(){return arguments;}; 113 JXG.Board.prototype.lineOptions = ['line',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]]; 114 115 JXG.Board.prototype.linesegmentFunc = function(){return arguments;}; 116 JXG.Board.prototype.linesegmentOptions = ['line',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]]; 117 JXG.Board.prototype.linesegmentAtts = {straightFirst : false, straightLast : false }; 118 119 JXG.Board.prototype.arrowFunc = function(){return arguments;}; 120 JXG.Board.prototype.arrowOptions = ['arrow',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]]; 121 122 JXG.Board.prototype.circleFunc = function(){return arguments;}; 123 JXG.Board.prototype.circleOptions = ['circle',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT],[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE],[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_CIRCLE]]]; 124 125 JXG.Board.prototype.arrowparallelOptions = ['arrowparallel',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]]; 126 JXG.Board.prototype.arrowparallelFunc = function(){return arguments;}; 127 128 JXG.Board.prototype.bisectorOptions = ['bisector',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]]; 129 JXG.Board.prototype.bisectorFunc = function(){return arguments;}; 130 131 JXG.Board.prototype.circumcircleOptions = ['circumcircle',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]]; 132 JXG.Board.prototype.circumcircleFunc = function(){return arguments;}; 133 134 JXG.Board.prototype.circumcirclemidpointOptions = ['circumcirclemidpoint',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]]; 135 JXG.Board.prototype.circumcirclemidpointFunc = function(){return arguments;}; 136 137 JXG.Board.prototype.integralOptions = ['integral',[[]]]; 138 JXG.Board.prototype.integralFunc = function(){return arguments;}; 139 140 JXG.Board.prototype.midpointOptions = ['midpoint',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT],[JXG.OBJECT_CLASS_LINE]]]; 141 JXG.Board.prototype.midpointFunc = function(){return arguments;}; 142 143 JXG.Board.prototype.mirrorpointOptions = ['mirrorpoint',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]]; 144 JXG.Board.prototype.mirrorpointFunc = function(){return arguments;}; 145 146 JXG.Board.prototype.normalOptions = ['normal',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]]; 147 JXG.Board.prototype.normalFunc = function(){return arguments;}; 148 149 JXG.Board.prototype.parallelOptions = ['parallel',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]]; 150 JXG.Board.prototype.parallelFunc = function(){return arguments;}; 151 152 JXG.Board.prototype.parallelpointOptions = ['parallelpoint',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_POINT]]]; 153 JXG.Board.prototype.parallelpointFunc = function(){return arguments;}; 154 155 JXG.Board.prototype.perpendicularOptions = ['perpendicular',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]]; 156 JXG.Board.prototype.perpendicularFunc = function(){return arguments;}; 157 158 JXG.Board.prototype.perpendicularpointOptions = ['perpendicularpoint',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]]; 159 JXG.Board.prototype.perpendicularpointFunc = function(){return arguments;}; 160 161 JXG.Board.prototype.reflectionOptions = ['reflection',[[JXG.OBJECT_CLASS_POINT,JXG.OBJECT_CLASS_LINE]]]; 162 JXG.Board.prototype.reflectionFunc = function(){return arguments;}; 163 164 // Wrapper for not-singleton-pstricks. this could be removed after the next release 165 // and adjusting examples/pstricks.html and pstricks example in the wiki 166 // (http://jsxgraph.uni-bayreuth.de/wiki/index.php/PsTricks_export) 167 JXG.Board.prototype.pstricks = {}; 168 JXG.Board.prototype.pstricks.givePsTricksToDiv = function(divId, board) { 169 JXG.PsTricks.givePsTricksToDiv(divId, board); 170 }; 171