= #JxnPortable\docs\gallery\Wurfparabel.jxn

#ifndef owner
owner = @java.awt.Frame( "Wurfparabel | Balistic Trajectory" )
#endif
#JXN:include/SliderInclude.jxn
!
tmax0 = slider.add( "tmax / s", 0., 0., 10. )
g  = slider.add( "g / m/s\#178;",  10, 0, 20 )
h0 = slider.add( "ho / m", 35, 0, 150 )
v0 = slider.add( "vo / m/s", 28.28, 0, 100 ) 
alp0 = slider.add( "\#945;o / \#176;", 45, -90, 90 )
!
v0x = v0 cosD alp0
v0y = v0 sinD alp0
!
! 0 = h0 + v0y tmax - 0.5 g tmax^2
p = -2 v0y / g
q = -2 h0  / g
! TODO: Behandlung g == 0
! tmax = sw( tmax0, tmax0, max( 1., -p/2 + sqrt max( 0., p^2/4 - q ) ), tmax0 ) 
! tmax = max( 1., sw( tmax0, tmax0, -p/2 + sqrt max( 0., p^2/4 - q ), tmax0 ) ) 
tmax = max( 1., sw( tmax0, tmax0, -p/2 + max( -p/2, sqrt max( 0., p^2/4 - q ) ), tmax0 ) ) 
!
tt = t tmax
x =      v0x tt
y = h0 + v0y tt - 0.5 g tt^2
!
ti = @JxnRealArrayAlgebra( 0, floor tmax, 1. )
xi =      v0x ti
yi = h0 + v0y ti - 0.5 g ti^2
!
txt = @JxnTextPainter( round ti[1:] + "s", xi[1:], yi[1:] ).setAnchor( KmgGraphicsScaler.NORTHEAST ).setSpace(0.2).setBackground()
!
pf1 = plot( xi, yi, R, 11, 1. ).add( x, y ).add( txt )  ! .setXYLabels( "m", "m" )
pf1.add( phasor( 5 + 0j, h0 j, "ho", B ) ).add( phasor( h0 j, @JxnComplexAlgebra( v0, alp0, true ), "vo", G ) )
pf1.add( angle( h0 j, 7, 0, alp0, "\#945;o", G ) ).add( @JxnGraphicsPainter( 0, 0, h0, 12, h0 ).setColor( G ) )
pf1.setAutoScale(1)
!
#JXN:include/Center1Include.jxn
#JXN:include/FrameInclude.jxn