1 /* 2 Copyright 2008-2024 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 dual licensed under the GNU LGPL or MIT License. 13 14 You can redistribute it and/or modify it under the terms of the 15 16 * GNU Lesser General Public License as published by 17 the Free Software Foundation, either version 3 of the License, or 18 (at your option) any later version 19 OR 20 * MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT 21 22 JSXGraph is distributed in the hope that it will be useful, 23 but WITHOUT ANY WARRANTY; without even the implied warranty of 24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 GNU Lesser General Public License for more details. 26 27 You should have received a copy of the GNU Lesser General Public License and 28 the MIT License along with JSXGraph. If not, see <https://www.gnu.org/licenses/> 29 and <https://opensource.org/licenses/MIT/>. 30 */ 31 32 /*global JXG: true, define: true*/ 33 /*jslint nomen: true, plusplus: true*/ 34 35 /** 36 * @fileoverview In this file the geometry object Arc is defined. Arc stores all 37 * style and functional properties that are required to draw an arc on a board. 38 */ 39 40 import JXG from "../jxg.js"; 41 import Geometry from "../math/geometry.js"; 42 import Mat from "../math/math.js"; 43 import Coords from "../base/coords.js"; 44 import Circle from "../base/circle.js"; 45 import Type from "../utils/type.js"; 46 import Const from "../base/constants.js"; 47 48 /** 49 * @class An arc is a segment of the circumference of a circle. It is defined by a center, one point that 50 * defines the radius, and a third point that defines the angle of the arc. 51 * 52 * @pseudo 53 * @name Arc 54 * @augments Curve 55 * @constructor 56 * @type JXG.Curve 57 * @throws {Error} If the element cannot be constructed with the given parent objects an exception is thrown. 58 * @param {JXG.Point_JXG.Point_JXG.Point} p1,p2,p3 The result will be an arc of a circle around p1 through p2. The arc is drawn 59 * counter-clockwise from p2 to p3. 60 * @example 61 * // Create an arc out of three free points 62 * var p1 = board.create('point', [2.0, 2.0]); 63 * var p2 = board.create('point', [1.0, 0.5]); 64 * var p3 = board.create('point', [3.5, 1.0]); 65 * 66 * var a = board.create('arc', [p1, p2, p3]); 67 * board.create('text',[1,6,function(){return 'arclength: '+Math.round(a.Value()*100)/100}]) 68 * </pre><div class="jxgbox" id="JXG114ef584-4a5e-4686-8392-c97501befb5b" style="width: 300px; height: 300px;"></div> 69 * <script type="text/javascript"> 70 * (function () { 71 * var board = JXG.JSXGraph.initBoard('JXG114ef584-4a5e-4686-8392-c97501befb5b', {boundingbox: [-1, 7, 7, -1], axis: true, showcopyright: false, shownavigation: false}), 72 * p1 = board.create('point', [2.0, 2.0]), 73 * p2 = board.create('point', [1.0, 0.5]), 74 * p3 = board.create('point', [3.5, 1.0]), 75 * 76 * a = board.create('arc', [p1, p2, p3]); 77 * board.create('text',[1,6,function(){return 'arclength: '+Math.round(a.Value()*100)/100}]) 78 * })(); 79 * </script><pre> 80 * 81 * @example 82 * var t = board.create('transform', [2, 1.5], {type: 'scale'}); 83 * var a1 = board.create('arc', [[1, 1], [0, 1], [1, 0]], {strokeColor: 'red'}); 84 * var a2 = board.create('curve', [a1, t], {strokeColor: 'red'}); 85 * 86 * </pre><div id="JXG1949da46-6339-11e8-9fb9-901b0e1b8723" class="jxgbox" style="width: 300px; height: 300px;"></div> 87 * <script type="text/javascript"> 88 * (function() { 89 * var board = JXG.JSXGraph.initBoard('JXG1949da46-6339-11e8-9fb9-901b0e1b8723', 90 * {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false}); 91 * var t = board.create('transform', [2, 1.5], {type: 'scale'}); 92 * var a1 = board.create('arc', [[1, 1], [0, 1], [1, 0]], {strokeColor: 'red'}); 93 * var a2 = board.create('curve', [a1, t], {strokeColor: 'red'}); 94 * 95 * })(); 96 * 97 * </script><pre> 98 * 99 */ 100 JXG.createArc = function (board, parents, attributes) { 101 var el, attr, points; 102 103 // attributes.radiusPoint = {visible: false}; 104 points = Type.providePoints(board, parents, attributes, "arc", [ 105 "center", 106 "radiuspoint", 107 "anglepoint" 108 ]); 109 if (points === false || points.length < 3) { 110 throw new Error( 111 "JSXGraph: Can't create Arc with parent types '" + 112 typeof parents[0] + 113 "' and '" + 114 typeof parents[1] + 115 "' and '" + 116 typeof parents[2] + 117 "'." + 118 "\nPossible parent types: [point,point,point], [arc, transformation]" 119 ); 120 } 121 122 attr = Type.copyAttributes(attributes, board.options, "arc"); 123 el = board.create("curve", [[0], [0]], attr); 124 125 el.elType = "arc"; 126 el.setParents(points); 127 128 /** 129 * documented in JXG.GeometryElement 130 * @ignore 131 */ 132 el.type = Const.OBJECT_TYPE_ARC; 133 134 /** 135 * Center of the arc. 136 * @memberOf Arc.prototype 137 * @name center 138 * @type JXG.Point 139 */ 140 el.center = points[0]; 141 142 /** 143 * Point defining the arc's radius. 144 * @memberOf Arc.prototype 145 * @name radiuspoint 146 * @type JXG.Point 147 */ 148 el.radiuspoint = points[1]; 149 el.point2 = el.radiuspoint; 150 151 /** 152 * The point defining the arc's angle. 153 * @memberOf Arc.prototype 154 * @name anglepoint 155 * @type JXG.Point 156 */ 157 el.anglepoint = points[2]; 158 el.point3 = el.anglepoint; 159 160 // Add arc as child to defining points 161 // or vice versa if the points are provided as coordinates 162 if (Type.exists(el.center._is_new)) { 163 el.addChild(el.center); 164 delete el.center._is_new; 165 } else { 166 el.center.addChild(el); 167 } 168 if (Type.exists(el.radiuspoint._is_new)) { 169 el.addChild(el.radiuspoint); 170 delete el.radiuspoint._is_new; 171 } else { 172 el.radiuspoint.addChild(el); 173 } 174 if (Type.exists(el.anglepoint._is_new)) { 175 el.addChild(el.anglepoint); 176 delete el.anglepoint._is_new; 177 } else { 178 el.anglepoint.addChild(el); 179 } 180 181 // This attribute is necessary for circumCircleArcs 182 el.useDirection = attr.usedirection; // This makes the attribute immutable 183 184 // documented in JXG.Curve 185 /** 186 * @class 187 * @ignore 188 */ 189 el.updateDataArray = function () { 190 var ar, phi, det, 191 p0c, p1c, p2c, 192 sgn = 1, 193 A = this.radiuspoint, 194 B = this.center, 195 C = this.anglepoint, 196 ev_s = this.evalVisProp('selection'); 197 198 phi = Geometry.rad(A, B, C); 199 if ((ev_s === "minor" && phi > Math.PI) || (ev_s === "major" && phi < Math.PI)) { 200 sgn = -1; 201 } 202 203 // This is true for circumCircleArcs. In that case there is 204 // a fourth parent element: [center, point1, point3, point2] 205 if (this.useDirection) { 206 p0c = points[1].coords.usrCoords; 207 p1c = points[3].coords.usrCoords; 208 p2c = points[2].coords.usrCoords; 209 det = (p0c[1] - p2c[1]) * (p0c[2] - p1c[2]) - (p0c[2] - p2c[2]) * (p0c[1] - p1c[1]); 210 211 if (det < 0) { 212 this.radiuspoint = points[1]; 213 this.anglepoint = points[2]; 214 } else { 215 this.radiuspoint = points[2]; 216 this.anglepoint = points[1]; 217 } 218 } 219 220 A = A.coords.usrCoords; 221 B = B.coords.usrCoords; 222 C = C.coords.usrCoords; 223 224 ar = Geometry.bezierArc(A, B, C, false, sgn); 225 226 this.dataX = ar[0]; 227 this.dataY = ar[1]; 228 229 this.bezierDegree = 3; 230 231 this.updateStdform(); 232 this.updateQuadraticform(); 233 }; 234 235 /** 236 * Determines the arc's current radius. I.e. the distance between {@link Arc#center} and {@link Arc#radiuspoint}. 237 * @memberOf Arc.prototype 238 * @name Radius 239 * @function 240 * @returns {Number} The arc's radius 241 */ 242 el.Radius = function () { 243 return this.radiuspoint.Dist(this.center); 244 }; 245 246 /** 247 * @deprecated Use {@link Arc#Radius} 248 * @memberOf Arc.prototype 249 * @name getRadius 250 * @function 251 * @returns {Number} 252 */ 253 el.getRadius = function () { 254 JXG.deprecated("Arc.getRadius()", "Arc.Radius()"); 255 return this.Radius(); 256 }; 257 258 /** 259 * Returns the length of the arc or the value of the angle spanned by the arc. 260 * @memberOf Arc.prototype 261 * @name Value 262 * @function 263 * @param {String} [unit='length'] Unit of the returned values. Possible units are 264 * <ul> 265 * <li> 'length' (default): length of the arc line 266 * <li> 'radians': angle spanned by the arc in radians 267 * <li> 'degrees': angle spanned by the arc in degrees 268 * <li> 'semicircle': angle spanned by the arc in radians as a multiple of π, e.g. if the angle is 1.5π, 1.5 will be returned. 269 * <li> 'circle': angle spanned by the arc in radians as a multiple of 2π 270 * </ul> 271 * It is sufficient to supply the first three characters of the unit, e.g. 'len'. 272 * @param {Number} [rad=undefined] Value of angle which can be used instead of the generic one. 273 * @returns {Number} The arc length or the angle value in various units. 274 */ 275 el.Value = function (unit, rad) { 276 var val; 277 278 rad = rad || Geometry.rad(this.radiuspoint, this.center, this.anglepoint); 279 280 unit = unit || 'length'; 281 unit = unit.toLocaleLowerCase(); 282 if (unit === '' || unit.indexOf('len') === 0) { 283 val = rad * this.Radius(); 284 } else if (unit.indexOf('rad') === 0) { 285 val = rad; 286 } else if (unit.indexOf('deg') === 0) { 287 val = rad * 180 / Math.PI; 288 } else if (unit.indexOf('sem') === 0) { 289 val = rad / Math.PI; 290 } else if (unit.indexOf('cir') === 0) { 291 val = rad * 0.5 / Math.PI; 292 } 293 294 return val; 295 }; 296 297 /** 298 * Arc length. 299 * @memberOf Arc.prototype 300 * @name L 301 * @returns {Number} Length of the arc. 302 * @see Arc#Value 303 */ 304 el.L = function() { 305 return this.Value('length'); 306 }; 307 308 // documented in geometry element 309 el.hasPoint = function (x, y) { 310 var dist, 311 checkPoint, 312 has, 313 invMat, 314 c, 315 prec, 316 type, 317 r = this.Radius(); 318 319 if (this.evalVisProp('hasinnerpoints')) { 320 return this.hasPointSector(x, y); 321 } 322 323 if (Type.isObject(this.evalVisProp('precision'))) { 324 type = this.board._inputDevice; 325 prec = this.evalVisProp('precision.' + type); 326 } else { 327 // 'inherit' 328 prec = this.board.options.precision.hasPoint; 329 } 330 prec /= Math.min(Math.abs(this.board.unitX), Math.abs(this.board.unitY)); 331 checkPoint = new Coords(Const.COORDS_BY_SCREEN, [x, y], this.board); 332 333 if (this.transformations.length > 0) { 334 // Transform the mouse/touch coordinates 335 // back to the original position of the curve. 336 this.updateTransformMatrix(); 337 invMat = Mat.inverse(this.transformMat); 338 c = Mat.matVecMult(invMat, checkPoint.usrCoords); 339 checkPoint = new Coords(Const.COORDS_BY_USER, c, this.board); 340 } 341 342 dist = this.center.coords.distance(Const.COORDS_BY_USER, checkPoint); 343 has = Math.abs(dist - r) < prec; 344 345 /** 346 * At that point we know that the user has touched the circle line. 347 * Now, we have to check, if the user has hit the arc path. 348 */ 349 if (has) { 350 has = Geometry.coordsOnArc(this, checkPoint); 351 } 352 return has; 353 }; 354 355 /** 356 * Checks whether (x,y) is within the sector defined by the arc. 357 * @memberOf Arc.prototype 358 * @name hasPointSector 359 * @function 360 * @param {Number} x Coordinate in x direction, screen coordinates. 361 * @param {Number} y Coordinate in y direction, screen coordinates. 362 * @returns {Boolean} True if (x,y) is within the sector defined by the arc, False otherwise. 363 */ 364 el.hasPointSector = function (x, y) { 365 var checkPoint = new Coords(Const.COORDS_BY_SCREEN, [x, y], this.board), 366 r = this.Radius(), 367 dist = this.center.coords.distance(Const.COORDS_BY_USER, checkPoint), 368 has = dist < r; 369 370 if (has) { 371 has = Geometry.coordsOnArc(this, checkPoint); 372 } 373 return has; 374 }; 375 376 // documented in geometry element 377 el.getTextAnchor = function () { 378 return this.center.coords; 379 }; 380 381 // documented in geometry element 382 /** 383 * @class 384 * @ignore 385 */ 386 el.getLabelAnchor = function () { 387 var coords, 388 vec, 389 vecx, 390 vecy, 391 len, 392 angle = Geometry.rad(this.radiuspoint, this.center, this.anglepoint), 393 dx = 10 / this.board.unitX, 394 dy = 10 / this.board.unitY, 395 p2c = this.point2.coords.usrCoords, 396 pmc = this.center.coords.usrCoords, 397 bxminusax = p2c[1] - pmc[1], 398 byminusay = p2c[2] - pmc[2], 399 ev_s = this.evalVisProp('selection'), 400 l_vp = this.label ? this.label.visProp : this.visProp.label; 401 402 // If this is uncommented, the angle label can not be dragged 403 //if (Type.exists(this.label)) { 404 // this.label.relativeCoords = new Coords(Const.COORDS_BY_SCREEN, [0, 0], this.board); 405 //} 406 407 if ((ev_s === "minor" && angle > Math.PI) || (ev_s === "major" && angle < Math.PI)) { 408 angle = -(2 * Math.PI - angle); 409 } 410 411 coords = new Coords( 412 Const.COORDS_BY_USER, 413 [ 414 pmc[1] + Math.cos(angle * 0.5) * bxminusax - Math.sin(angle * 0.5) * byminusay, 415 pmc[2] + Math.sin(angle * 0.5) * bxminusax + Math.cos(angle * 0.5) * byminusay 416 ], 417 this.board 418 ); 419 420 vecx = coords.usrCoords[1] - pmc[1]; 421 vecy = coords.usrCoords[2] - pmc[2]; 422 423 len = Mat.hypot(vecx, vecy); 424 vecx = (vecx * (len + dx)) / len; 425 vecy = (vecy * (len + dy)) / len; 426 vec = [pmc[1] + vecx, pmc[2] + vecy]; 427 428 l_vp.position = Geometry.calcLabelQuadrant(Geometry.rad([1, 0], [0, 0], vec)); 429 430 return new Coords(Const.COORDS_BY_USER, vec, this.board); 431 }; 432 433 // documentation in jxg.circle 434 el.updateQuadraticform = Circle.prototype.updateQuadraticform; 435 436 // documentation in jxg.circle 437 el.updateStdform = Circle.prototype.updateStdform; 438 439 el.methodMap = JXG.deepCopy(el.methodMap, { 440 getRadius: "getRadius", 441 radius: "Radius", 442 Radius: "Radius", 443 center: "center", 444 radiuspoint: "radiuspoint", 445 anglepoint: "anglepoint", 446 Value: "Value", 447 L: "L" 448 }); 449 450 el.prepareUpdate().update(); 451 return el; 452 }; 453 454 JXG.registerElement("arc", JXG.createArc); 455 456 /** 457 * @class A semicircle is a special arc defined by two points. The arc hits both points. 458 * @pseudo 459 * @name Semicircle 460 * @augments Arc 461 * @constructor 462 * @type Arc 463 * @throws {Error} If the element cannot be constructed with the given parent objects an exception is thrown. 464 * @param {JXG.Point_JXG.Point} p1,p2 The result will be a composition of an arc drawn clockwise from <tt>p1</tt> and 465 * <tt>p2</tt> and the midpoint of <tt>p1</tt> and <tt>p2</tt>. 466 * @example 467 * // Create an arc out of three free points 468 * var p1 = board.create('point', [4.5, 2.0]); 469 * var p2 = board.create('point', [1.0, 0.5]); 470 * 471 * var a = board.create('semicircle', [p1, p2]); 472 * </pre><div class="jxgbox" id="JXG5385d349-75d7-4078-b732-9ae808db1b0e" style="width: 300px; height: 300px;"></div> 473 * <script type="text/javascript"> 474 * (function () { 475 * var board = JXG.JSXGraph.initBoard('JXG5385d349-75d7-4078-b732-9ae808db1b0e', {boundingbox: [-1, 7, 7, -1], axis: true, showcopyright: false, shownavigation: false}), 476 * p1 = board.create('point', [4.5, 2.0]), 477 * p2 = board.create('point', [1.0, 0.5]), 478 * 479 * sc = board.create('semicircle', [p1, p2]); 480 * })(); 481 * </script><pre> 482 */ 483 JXG.createSemicircle = function (board, parents, attributes) { 484 var el, mp, attr, points; 485 486 // we need 2 points 487 points = Type.providePoints(board, parents, attributes, "point"); 488 if (points === false || points.length !== 2) { 489 throw new Error( 490 "JSXGraph: Can't create Semicircle with parent types '" + 491 typeof parents[0] + 492 "' and '" + 493 typeof parents[1] + 494 "'." + 495 "\nPossible parent types: [point,point]" 496 ); 497 } 498 499 attr = Type.copyAttributes(attributes, board.options, "semicircle", "center"); 500 mp = board.create("midpoint", points, attr); 501 mp.dump = false; 502 503 attr = Type.copyAttributes(attributes, board.options, "semicircle"); 504 el = board.create("arc", [mp, points[1], points[0]], attr); 505 el.elType = "semicircle"; 506 el.setParents([points[0].id, points[1].id]); 507 el.subs = { 508 midpoint: mp 509 }; 510 el.inherits.push(mp); 511 512 /** 513 * The midpoint of the two defining points. 514 * @memberOf Semicircle.prototype 515 * @name midpoint 516 * @type Midpoint 517 */ 518 el.midpoint = el.center = mp; 519 520 return el; 521 }; 522 523 JXG.registerElement("semicircle", JXG.createSemicircle); 524 525 /** 526 * @class A circumcircle arc is an {@link Arc} defined by three points. All three points lie on the arc. 527 * @pseudo 528 * @name CircumcircleArc 529 * @augments Arc 530 * @constructor 531 * @type Arc 532 * @throws {Error} If the element cannot be constructed with the given parent objects an exception is thrown. 533 * @param {JXG.Point_JXG.Point_JXG.Point} p1,p2,p3 The result will be a composition of an arc of the circumcircle of 534 * <tt>p1</tt>, <tt>p2</tt>, and <tt>p3</tt> and the midpoint of the circumcircle of the three points. The arc is drawn 535 * counter-clockwise from <tt>p1</tt> over <tt>p2</tt> to <tt>p3</tt>. 536 * @example 537 * // Create a circum circle arc out of three free points 538 * var p1 = board.create('point', [2.0, 2.0]); 539 * var p2 = board.create('point', [1.0, 0.5]); 540 * var p3 = board.create('point', [3.5, 1.0]); 541 * 542 * var a = board.create('circumcirclearc', [p1, p2, p3]); 543 * </pre><div class="jxgbox" id="JXG87125fd4-823a-41c1-88ef-d1a1369504e3" style="width: 300px; height: 300px;"></div> 544 * <script type="text/javascript"> 545 * (function () { 546 * var board = JXG.JSXGraph.initBoard('JXG87125fd4-823a-41c1-88ef-d1a1369504e3', {boundingbox: [-1, 7, 7, -1], axis: true, showcopyright: false, shownavigation: false}), 547 * p1 = board.create('point', [2.0, 2.0]), 548 * p2 = board.create('point', [1.0, 0.5]), 549 * p3 = board.create('point', [3.5, 1.0]), 550 * 551 * cca = board.create('circumcirclearc', [p1, p2, p3]); 552 * })(); 553 * </script><pre> 554 */ 555 JXG.createCircumcircleArc = function (board, parents, attributes) { 556 var el, mp, attr, points; 557 558 // We need three points 559 points = Type.providePoints(board, parents, attributes, "point"); 560 if (points === false || points.length !== 3) { 561 throw new Error( 562 "JSXGraph: create Circumcircle Arc with parent types '" + 563 typeof parents[0] + 564 "' and '" + 565 typeof parents[1] + 566 "' and '" + 567 typeof parents[2] + 568 "'." + 569 "\nPossible parent types: [point,point,point]" 570 ); 571 } 572 573 attr = Type.copyAttributes(attributes, board.options, "circumcirclearc", "center"); 574 mp = board.create("circumcenter", points, attr); 575 mp.dump = false; 576 577 attr = Type.copyAttributes(attributes, board.options, "circumcirclearc"); 578 attr.usedirection = true; 579 el = board.create("arc", [mp, points[0], points[2], points[1]], attr); 580 581 el.elType = "circumcirclearc"; 582 el.setParents([points[0].id, points[1].id, points[2].id]); 583 el.subs = { 584 center: mp 585 }; 586 el.inherits.push(mp); 587 588 /** 589 * The midpoint of the circumcircle of the three points defining the circumcircle arc. 590 * @memberOf CircumcircleArc.prototype 591 * @name center 592 * @type Circumcenter 593 */ 594 el.center = mp; 595 596 return el; 597 }; 598 599 JXG.registerElement("circumcirclearc", JXG.createCircumcircleArc); 600 601 /** 602 * @class A minor arc is a segment of the circumference of a circle having measure less than or equal to 603 * 180 degrees (pi radians). It is defined by a center, one point that 604 * defines the radius, and a third point that defines the angle of the arc. 605 * @pseudo 606 * @name MinorArc 607 * @augments Curve 608 * @constructor 609 * @type JXG.Curve 610 * @throws {Error} If the element cannot be constructed with the given parent objects an exception is thrown. 611 * @param {JXG.Point_JXG.Point_JXG.Point} p1,p2,p3 . Minor arc is an arc of a circle around p1 having measure less than or equal to 612 * 180 degrees (pi radians) and starts at p2. The radius is determined by p2, the angle by p3. 613 * @example 614 * // Create an arc out of three free points 615 * var p1 = board.create('point', [2.0, 2.0]); 616 * var p2 = board.create('point', [1.0, 0.5]); 617 * var p3 = board.create('point', [3.5, 1.0]); 618 * 619 * var a = board.create('arc', [p1, p2, p3]); 620 * </pre><div class="jxgbox" id="JXG64ba7ca2-8728-45f3-96e5-3c7a4414de2f" style="width: 300px; height: 300px;"></div> 621 * <script type="text/javascript"> 622 * (function () { 623 * var board = JXG.JSXGraph.initBoard('JXG64ba7ca2-8728-45f3-96e5-3c7a4414de2f', {boundingbox: [-1, 7, 7, -1], axis: true, showcopyright: false, shownavigation: false}), 624 * p1 = board.create('point', [2.0, 2.0]), 625 * p2 = board.create('point', [1.0, 0.5]), 626 * p3 = board.create('point', [3.5, 1.0]), 627 * 628 * a = board.create('minorarc', [p1, p2, p3]); 629 * })(); 630 * </script><pre> 631 */ 632 633 JXG.createMinorArc = function (board, parents, attributes) { 634 attributes.selection = "minor"; 635 return JXG.createArc(board, parents, attributes); 636 }; 637 638 JXG.registerElement("minorarc", JXG.createMinorArc); 639 640 /** 641 * @class A major arc is a segment of the circumference of a circle having measure greater than or equal to 642 * 180 degrees (pi radians). It is defined by a center, one point that 643 * defines the radius, and a third point that defines the angle of the arc. 644 * @pseudo 645 * @name MajorArc 646 * @augments Curve 647 * @constructor 648 * @type JXG.Curve 649 * @throws {Error} If the element cannot be constructed with the given parent objects an exception is thrown. 650 * @param {JXG.Point_JXG.Point_JXG.Point} p1,p2,p3 . Major arc is an arc of a circle around p1 having measure greater than or equal to 651 * 180 degrees (pi radians) and starts at p2. The radius is determined by p2, the angle by p3. 652 * @example 653 * // Create an arc out of three free points 654 * var p1 = board.create('point', [2.0, 2.0]); 655 * var p2 = board.create('point', [1.0, 0.5]); 656 * var p3 = board.create('point', [3.5, 1.0]); 657 * 658 * var a = board.create('majorarc', [p1, p2, p3]); 659 * </pre><div class="jxgbox" id="JXG17a10d38-5629-40a4-b150-f41806edee9f" style="width: 300px; height: 300px;"></div> 660 * <script type="text/javascript"> 661 * (function () { 662 * var board = JXG.JSXGraph.initBoard('JXG17a10d38-5629-40a4-b150-f41806edee9f', {boundingbox: [-1, 7, 7, -1], axis: true, showcopyright: false, shownavigation: false}), 663 * p1 = board.create('point', [2.0, 2.0]), 664 * p2 = board.create('point', [1.0, 0.5]), 665 * p3 = board.create('point', [3.5, 1.0]), 666 * 667 * a = board.create('majorarc', [p1, p2, p3]); 668 * })(); 669 * </script><pre> 670 */ 671 JXG.createMajorArc = function (board, parents, attributes) { 672 attributes.selection = "major"; 673 return JXG.createArc(board, parents, attributes); 674 }; 675 676 JXG.registerElement("majorarc", JXG.createMajorArc); 677