= #JxnPortable\docs\gallery\Bremsweg.jxn

#ifndef owner
owner = @java.awt.Frame( "Bremsweg | Braking Distance" )
#endif
#JXN:include/SliderInclude.jxn
!
t0a = slider.add( "to-a / s", 0.5, 0., 2.5 )
v0a = slider.add( "vo-a / km/h", 50.01, 0., 100. )
t0b = slider.add( "to-b / s", 1.0, 0., 2.5 )
v0b = slider.add( "vo-b / km/h", 30., 0., 100. )
a = slider.add( "a / m/sē", 6., 0., 10. )
!
t0 = { t0a, t0b }
v0 = { v0a, v0b } / 3.6
tmax = t0 + v0 / a
tt = @JxnRealArrayAlgebra( 0., tmax, 0.01 )
! v(t) = v0   -     a t
! s(t) = v0 t - 0.5 a t^2
vt = max( 0 tt, v0    - sw( tt - t0, 0 tt,     a ( tt - t0 ) ) )
st =            v0 tt - sw( tt - t0, 0 tt, 0.5 a ( tt - t0 )^2 )
!
pf1 = plot( tt[0], 3.6 vt[0] ).add( curve( tt[1], 3.6 vt[1], B ) )
pf1.setXYLabels( "t / s", "v / km/h, s / m" ).setAutoScale(2)
pf1.add( curve( tt[0], st[0], R ) ).add( curve( tt[1], st[1], B ) )
pf2 = plot( st[0], 3.6 vt[0] ).add( curve( st[1], 3.6 vt[1], B ) )
! Einzelpunkte mit Beschriftung
ti = JxnRealArraySample.sample( tt, -50 )
vi = JxnRealArraySample.sample( vt, -50 )
si = JxnRealArraySample.sample( st, -50 )
txt0 = @JxnTextPainter( format( @JxnUnroll ti[0].getValue(), 1 ) + "s", si[0].getValue(), 3.6 vi[0].getValue() ).setAnchor( KmgGraphicsScaler.NORTHEAST ).setSpace(0.2)
txt1 = @JxnTextPainter( format( @JxnUnroll ti[1].getValue(), 1 ) + "s", si[1].getValue(), 3.6 vi[1].getValue() ).setAnchor( KmgGraphicsScaler.NORTHEAST ).setSpace(0.2)
pf2.add( curve( si, 3.6 vi, { R, B }, 11 ) ).add(txt0).add(txt1)
pf2.setXYLabels( "s / m", "v / km/h" ).setAutoScale(2)
!
#JXN:include/Grid2Include.jxn
#JXN:include/FrameInclude.jxn