@@ -231,7 +231,6 @@ export class GraphParametric2D extends GObject {
231231
232232 //TODO : only update linePath to increase performance
233233 update ( xeqn : any , yeqn : any ) {
234-
235234 const plot = this . graphObject . getElementById ( 'plot' ) ;
236235
237236 this . xeqn = xeqn ;
@@ -348,15 +347,11 @@ export class GraphParametric2D extends GObject {
348347 let tick ;
349348 //x axis
350349 //+ve axis
351- for (
352- let i = 0 ;
353- i <
350+ let veEnd =
354351 abs (
355352 int ( this . svgWidth / ( 2 * this . config . scaleX ) - this . config . originX )
356- ) /
357- this . config . stepX ;
358- i ++
359- ) {
353+ ) / this . config . stepX ;
354+ for ( let i = 0 ; i < veEnd ; i += 1 ) {
360355 let x =
361356 this . config . originX * this . config . scaleX +
362357 ( i + 1 ) * this . config . stepX * this . config . scaleX ;
@@ -380,13 +375,10 @@ export class GraphParametric2D extends GObject {
380375 //console.log(int(this.svgWidth / (2*this.config.scaleX)) + this.config.originX);
381376
382377 //-ve axis
383- for (
384- let i = abs (
385- int ( this . svgWidth / ( 2 * this . config . scaleX ) ) + this . config . originX
386- ) ;
387- i >= 0 ;
388- i --
389- ) {
378+ veEnd = abs (
379+ int ( this . svgWidth / ( 2 * this . config . scaleX ) ) + this . config . originX
380+ ) ;
381+ for ( let i = veEnd ; i >= 0 ; i -= 1 ) {
390382 let x =
391383 this . config . originX * this . config . scaleX -
392384 ( i + 1 ) * this . config . stepX * this . config . scaleX ;
@@ -427,15 +419,10 @@ export class GraphParametric2D extends GObject {
427419 let tick ;
428420 //y axis
429421 //+ve axis
430- for (
431- let i = 0 ;
432- i <=
433- abs (
434- - int ( this . svgHeight / ( 2 * this . config . scaleY ) ) +
435- this . config . originY
436- ) ;
437- i ++
438- ) {
422+ let veEnd = abs (
423+ - int ( this . svgHeight / ( 2 * this . config . scaleY ) ) + this . config . originY
424+ ) ;
425+ for ( let i = 0 ; i <= veEnd ; i += 1 ) {
439426 let y =
440427 - this . config . originY * this . config . scaleY -
441428 ( i + 1 ) * this . config . stepY * this . config . scaleY ;
@@ -456,14 +443,10 @@ export class GraphParametric2D extends GObject {
456443 this . coordinate . appendChild ( tick ) ;
457444 }
458445 //-ve axis
459- for (
460- let i = abs (
461- - int ( this . svgHeight / ( 2 * this . config . scaleY ) ) -
462- this . config . originY
463- ) ;
464- i >= 0 ;
465- i --
466- ) {
446+ veEnd = abs (
447+ - int ( this . svgHeight / ( 2 * this . config . scaleY ) ) - this . config . originY
448+ ) ;
449+ for ( let i = veEnd ; i >= 0 ; i -= 1 ) {
467450 let y =
468451 - this . config . originY * this . config . scaleY +
469452 ( i + 1 ) * this . config . stepY * this . config . scaleY ;
@@ -588,24 +571,20 @@ export function createParametricSVGPath(
588571 //let minX = parameterRange[0];
589572 // let scaleX = 100;
590573 // let scaleY = 100;
591- let SVG_path = `M${
574+ let svgPath = `M${
592575 config . scaleX * xeqn ( parameterRange [ 0 ] ) + config . originX * config . scaleX
593576 } ,${
594577 - config . scaleY * yeqn ( parameterRange [ 0 ] ) - config . originY * config . scaleY
595578 } `;
596- for (
597- let parameter = parameterRange [ 0 ] ;
598- parameter <= parameterRange [ 1 ] ;
599- parameter += stepSize
600- ) {
601- // SVG_path = SVG_path.concat(` L${1000*i},${1000*Math.sin(Math.PI / 2 * Math.pow(i, 1.5))/i}`);
602- SVG_path = SVG_path . concat (
603- ` L${ config . scaleX * xeqn ( parameter ) + config . originX * config . scaleX } ,${
604- - config . scaleY * yeqn ( parameter ) - config . originY * config . scaleY
579+ for ( let p = parameterRange [ 0 ] ; p <= parameterRange [ 1 ] ; p += stepSize ) {
580+ // svgPath = svgPath.concat(` L${1000*i},${1000*Math.sin(Math.PI / 2 * Math.pow(i, 1.5))/i}`);
581+ svgPath = svgPath . concat (
582+ ` L${ config . scaleX * xeqn ( p ) + config . originX * config . scaleX } ,${
583+ - config . scaleY * yeqn ( p ) - config . originY * config . scaleY
605584 } `
606585 ) ;
607586 }
608- return SVG_path ;
587+ return svgPath ;
609588}
610589
611590export function create2DParametricGraph (
0 commit comments