@@ -451,27 +451,45 @@ class TestScene extends Scene {
451451 const p = axes . point ( [ 0.5 , fn ( 0.5 ) ] ) ;
452452 const q = axes . point ( [ 0.69 , fn ( 0.69 ) ] ) ;
453453
454- const pText = new Text ( { text : 'P' } ) . nextTo ( p , [ - 1 , 1 ] ) ;
455- const qText = new Text ( { text : 'Q' } ) . nextTo ( q , LEFT ( 1.5 ) ) ;
454+ const pText = new Tex ( { text : 'P' } ) . nextTo ( p , [ - 1 , 1 ] ) ;
455+ const qText = new Tex ( { text : 'Q' } ) . nextTo ( q , RIGHT ( 1.5 ) ) ;
456456 const qDot = new Dot ( { center : q , color : Colors . blue ( ) } ) ;
457457 const secant = new Line ( { from : p , to : q , length : 6 , lineColor : Colors . blue ( ) } ) ;
458+ const tangent = new TangentLine ( { plot, x : 0.5 , length : 4 , color : Colors . pink ( ) } ) ;
459+ const tangentText = new Tex ( `m` ) . changeColor ( Colors . pink ( ) ) . nextTo ( tangent . to ( ) ) ;
460+ const secantText = new Tex ( `m_{\sec}` ) . nextTo ( secant . to ( ) ) . changeColor ( Colors . blue ( ) ) ;
461+ // const secantText = new Text(`m_{\\sec}`).nextTo(secant.to()).changeColor(Colors.blue());
458462
459463 this . add (
460464 axes , plot ,
461465
462466 secant ,
463- new TangentLine ( { plot , x : 0.5 , length : 4 , color : Colors . pink ( ) } ) ,
467+ tangent ,
464468 new Dot ( { center : p , color : Colors . pink ( ) } ) ,
465469
466470 qDot ,
467- pText , qText
471+ pText , qText ,
472+ tangentText ,
473+ secantText ,
468474 ) ;
469475
476+ const updateText = utils . throttle ( text => secantText . changeText ( text ) , 200 ) ;
477+
470478 this . add ( new Updater ( ( pctComplete : number , starting : boolean ) => {
471- const x = math . lerp ( 0.5 , 0.69 , 1 - pctComplete ) ;
479+ const rx = math . lerp ( 0.5 , 0.75 , 1 - pctComplete ) ;
480+ const m = ( 25 * rx * rx - 25 * 0.5 * 0.5 ) / ( rx - 0.5 ) ;
481+
482+ const x = math . lerp ( 0.51 , 0.69 , 1 - pctComplete ) ;
472483 qDot . moveTo ( plot . pointAtX ( x ) ) ;
473484 secant . changeEndpoints ( p , qDot , true ) ;
474- } , { duration : 3000 , easing : Easing . linear , repeat : true , yoyo : true , } ) ) ;
485+ qText . nextTo ( qDot . center ( ) , RIGHT ( ) , 0.3 ) ;
486+ secantText . nextTo ( secant . to ( ) ) //.changeText(`m_{\\sec} = ${m.toFixed(2)}`);
487+
488+ // console.log(m, pctComplete)
489+ updateText ( `m_{\\sec} = ${ m . toFixed ( 2 ) } ` ) ;
490+
491+ } , { duration : 5000 , easing : Easing . linear , repeat : true , yoyo : true , } ) ) ;
492+ // }, { duration: 5000, easing: x => Easing.easeStep(x, 10), repeat: true, yoyo: true, }));
475493 }
476494}
477495
0 commit comments