This is the web version of EJS interface
EJS version 4.2.7
  1. Title=Displacement & Velocity time graph applet showing relationships of area & dx/dt
  2. Author=Fu-Kwun Hwang and remixed by wee loo kang
  3. Keywords=physics applet kinematics graphs
  4. Level=secondary pre university
  5. Language=english
  6. Abstract=weelookang@gmail.com Designed by Fu-Kwun Hwang http://www.phy.ntnu.edu.tw/ntnujava/ Remixed by weelookang@gmail.com http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=750.0
  7. CaptureTools=false
  8. DataTools=true
  9. LanguageTools=true
  10. EmersionSupport=false
  11. UseInterpreter=true
  12. AuxiliaryFiles=_data/white cat on the run1.gif;_data/treecc.gif;_data/dogy.gif;_data/cartoon_house.gif;
  13. DetectedFiles=./CatDogtRace/DisplacementVelocitytimegraph.png;./CatDogtRace/cartoonhouse.png;./CatDogtRace/cat.gif;./CatDogtRace/dogy.gif;./CatDogtRace/treecc.png;
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension

    Init Page

    // need to initialise d1 and d2 to zero. introduce by lookang d1 = 0; d2 = 0; x1s=x1=x1area=x10; //testing need to add x1area too // comment lines by wee loo kang // 1,2 for object number, s = slider, 0 = initial, P =point, v = velocity // t is time of simulation // ts is the scroll bar display time for controller slider // x1s is displacement object 1 at ts // x1 is displacement object 1 at t // x10 is displacement object 1 initial x2s=x2=x2area=x20; // ts=t=0; // initialise t = 0 which in turn ts = 0 as well PT[2]=0; // fix bug of triangle showing non zero at t =0 PY1[1]=vx1=v1s=v10; // v1s assigned v10 value which then assign to vx1 and PY1[1] the second point of the array as first point is (0,0) // vx1 is the evolution dx1/dt PY2[1]=vx2=v2s=v20; showt=false; // showt initialise to false

    evo

    Indep. Var. Increment
    d x1 /dt=vx1
    d x2 /dt=vx2
    d vx1 /dt=a1
    d vx2 /dt=a2
    SolverEuler
    y1=size*2; // what does y1 and y2 do ? y2=-size*2; if(_isPlaying()){ if(x1>xmax || x2>xmax){ // if x1 greater xmax OR x2 greater xmax which is outside simulation time showt=true; // showt show the polygons dragt(); // assign polygons and draw them _pause(); // } // else assign simulation varaibles to slider values x1s=x1; x2s=x2; v1s=vx1; v2s=vx2; ts=t; if(t>tmax)tmax=t; }
    if(v10>=0 && v1s>=0){ d1 = Math.abs(0.5*(v10+v1s)*(ts-0)); } if(v10<=0 && v1s<=0){ d1 = Math.abs(0.5*(v10+v1s)*(ts-0)); } if(v10>=0 && v1s<0){ tprime= v10*ts/(v10-v1s); dtest = Math.abs(0.5*(ts-tprime)*v1s); d1 = Math.abs(0.5*(v10)*tprime) + Math.abs(0.5*(ts-tprime)*v1s); } if(v10<=0 && v1s>0){ tprime= v10*ts/(v10-v1s); dtest = Math.abs(0.5*(ts-tprime)*v1s); d1 = Math.abs(0.5*(v10)*tprime) + Math.abs(0.5*(ts-tprime)*v1s); }
    if(v20>=0 && v2s>=0){ d2 = Math.abs(0.5*(v20+v2s)*(ts-0)); } if(v20<=0 && v2s<=0){ d2 = Math.abs(0.5*(v20+v2s)*(ts-0)); } if(v10>=0 && v1s<0){ tprime2= v20*ts/(v20-v2s); dtest2 = Math.abs(0.5*(ts-tprime2)*v2s); d2 = Math.abs(0.5*(v20)*tprime2) + Math.abs(0.5*(ts-tprime2)*v2s); } if(v20<=0 && v2s>0){ tprime2= v20*ts/(v20-v2s); dtest2 = Math.abs(0.5*(ts-tprime2)*v2s); d2 = Math.abs(0.5*(v20)*tprime2) + Math.abs(0.5*(ts-tprime2)*v2s); }
    A1 = x1s - x10; A2 = x2s - x20;
    x1abs = Math.abs (x1s-x10) ; x2abs = Math.abs (x2s-x20) ; x1max = Math.max(x1abs,x1max) ; //if(x1max>x1abs){ //t1turning = t; //} x2max = Math.max(x2abs,x2max) ;
    title1="v_{1} ="+dvalue(v1s)+" m/s "; title2="v_{2} ="+dvalue(v2s)+" m/s "; area1="d_{1} ="+dvalue(d1)+" m "; area2="d_{2} ="+dvalue(d2)+" m "; displacment1="x_{1} ="+dvalue(A1)+" m "; displacment2="x_{2} ="+dvalue(A2)+" m ";
    // screen view if(x1<xmin ) xmin*=1.2; if(x1>xmax) xmax*=1.2; if(x2<xmin ) xmin*=1.2; if(x2>xmax) xmax*=1.2;
    public void drag () { x1=x10=x1s; // by wee loo kang // modified to allow cat to be drag // cat position is x1s // but on drag assign x10 = x1s // then also assign x1 = x10 x2=x20=x2s; _initialize(); }
    public void dragt () { PY1[2]=v1s=v10+a1*ts; // assign polygon drawing point third point PY1[2] to v1s // v1s slider obeys v10 +a1*ts PY2[2]=v2s=v20+a2*ts; x1s=x10+v10*ts+a1*ts*ts/2; // equation of motion x1s = x10 + v10*ts +0.5*ts*ts x2s=x20+v20*ts+a2*ts*ts/2; PT[2]=PT[3]=ts; // assign PT[2] = ts // PT[3] = ts }
    double dv; public double dvalue (double v) { if(v>0)dv=0.5; else if(v<0)dv=-0.5; else dv=0; return (int)(v*10.+dv)/10.; // change the 10 to get the correct decimal place }
    EJSVIEW: Click link to view it's content
    Control variables:(testing)
    double,double,double,double,double,double,double
    title="Displacement Velocity Acceleration Model"
    layout=border
    visible=true
    location="502,48"
    size="750,600"
    position=north
    autoscaleX=false
    autoscaleY=false
    minimumX=xmin*1.2
    maximumX=xmax*1.2
    minimumY=ymin*1.5
    maximumY=ymax*1.5
    square=false
    size="0,150"
    x=-100
    sizeX=size*10
    sizeY=size*10
    imageFile="./CatDogtRace/cartoonhouse.png"
    elementposition=EAST
    x=100
    sizeX=size*10
    sizeY=size*10
    imageFile="./CatDogtRace/treecc.png"
    elementposition=WEST
    x=x1s
    y=y1
    sizeX=size*5
    sizeY=size*5
    scalex=1.5
    scaley=1.5
    enabledPosition=!showt
    dragAction=drag()
    imageFile="./CatDogtRace/cat.gif"
    x=x2s
    y=y2
    sizeX=size*5
    sizeY=size*5
    scalex=1.5
    scaley=1.5
    enabledPosition=!showt
    dragAction=drag()
    imageFile="./CatDogtRace/dogy.gif"
    x=x1s
    y=y1
    sizex=v1s
    sizey=zero
    scalex=vscale
    visible=showdxdt
    enabled=false
    color=MAGENTA
    secondaryColor=MAGENTA
    x=x2s
    y=y2
    sizex=v2s
    sizey=zero
    scalex=vscale
    visible=showdxdt2
    enabled=false
    color=MAGENTA
    secondaryColor=MAGENTA
    x=x1s+v1s*vscale
    y=y1
    visible=showdxdt
    enabled=false
    text=%title1%
    elementposition=NORTH_WEST
    color=255,0,255
    font=Dialog,PLAIN,12
    x=x2s+v2s*vscale
    y=y2
    visible=showdxdt2
    enabled=false
    text=%title2%
    elementposition=NORTH_WEST
    color=255,0,255
    font=Dialog,PLAIN,12
    x=x10
    y=y1
    enabled=false
    text="x_{1i}"
    elementposition=NORTH_WEST
    color=BLACK
    font=Dialog,PLAIN,12
    x=x20
    y=y2
    enabled=false
    text="x_{2i}"
    elementposition=NORTH_WEST
    color=BLACK
    font=Dialog,PLAIN,12
    x=x10
    y=y1
    sizex=x1s-x10
    sizey=zero
    visible=showdisplacement
    enabled=false
    style=ARROW
    color=BLUE
    secondaryColor=BLUE
    x=x20
    y=y2
    sizex=x2s-x20
    sizey=zero
    visible=showdisplacement2
    enabled=false
    style=ARROW
    color=BLUE
    secondaryColor=BLUE
    x=x1s
    y=y1
    visible=showdisplacement
    enabled=false
    text=%displacment1%
    elementposition=SOUTH_EAST
    color=BLUE
    font=Dialog,PLAIN,12
    x=x2s
    y=y2
    visible=showdisplacement2
    enabled=false
    text=%displacment2%
    elementposition=SOUTH_EAST
    color=BLUE
    font=Dialog,PLAIN,12
    position=south
    layout=vbox
    layout=HBOX
    variable=showdisplacement
    text="x1= x1f - x1i"
    foreground=0,0,255,100
    tooltip="For cat 1, Displacement (x1) is the vector difference between the final position and the initial position x1i."
    variable=showdisplacement2
    text="x2= x2f - x2i"
    foreground=0,0,255,100
    tooltip="For cat 2, Displacement (x2) is the vector difference between the final position and the initial position x2i."
    variable=showdxdt
    text="dx1/dt"
    foreground=255,0,255,100
    tooltip="For cat 1, gradient of the displacement versus time graph is the instantaneous velocity at that time"
    variable=showdxdt2
    text="dx2/dt"
    foreground=255,0,255,100
    tooltip="the gradient of the displacement versus time graph is the instantaneous velocity at that time"
    variable=showdistance
    text="d1 = line integral of absolute value of x1."
    foreground=0,0,255,100
    variable=showdistance2
    text="d2 = line integral of absolute value of x2."
    foreground=0,0,255,100
    layout=grid:1,0,0,0
    layout=grid:1,0,0,0
    layout=VBOX
    layout=HBOX
    position=center
    text=" x1i = "
    background=0,64,255
    foreground=WHITE
    variable=x10
    format="0.0"
    editable=!showt && _isPaused()
    action=x1=x1s=x10
    text=" m "
    background=0,64,255
    foreground=WHITE
    variable=x10
    minimum=-100
    maximum=100
    ticks=21
    closest=true
    enabled=!showt && _isPaused()
    dragaction=x1=x1s=x10
    background=0,64,255
    foreground=WHITE
    tooltip="1 white cat's initial starting position"
    layout=VBOX
    layout=HBOX
    position=center
    text=" u1 = "
    background=MAGENTA
    variable=v10
    format="0.0"
    editable=!showt && _isPaused()
    action=PY1[1]=vx1=v10
    text=" m/s "
    background=MAGENTA
    variable=v10
    minimum=-vmax
    maximum=vmax
    ticks=ns
    closest=true
    enabled=!showt && _isPaused()
    dragaction=PY1[1]=vx1=v10
    background=MAGENTA
    tooltip="1 white cat's initial starting velocity"
    layout=VBOX
    layout=HBOX
    position=center
    text=" a1 = "
    background=RED
    variable=a1
    format="0.0"
    editable=!showt && _isPaused()
    text=" m/s^2 "
    background=RED
    variable=a1
    minimum=-amax
    maximum=amax
    ticks=ns
    enabled=!showt&& _isPaused()
    background=RED
    tooltip="1 white cat's constant acceleration"
    layout=VBOX
    layout=HBOX
    position=center
    text=" x2i = "
    background=0,64,255
    foreground=WHITE
    variable=x20
    format="0.0"
    editable=!showt && _isPaused()
    action=x2=x2s=x20
    text=" m "
    background=0,64,255
    foreground=WHITE
    variable=x20
    minimum=-100
    maximum=100
    ticks=21
    closest=true
    enabled=!showt && _isPaused()
    dragaction=x2=x2s=x20
    background=0,64,255
    foreground=WHITE
    tooltip="2 yellow dog's initial starting position"
    layout=VBOX
    layout=HBOX
    position=center
    text=" u2 = "
    background=MAGENTA
    variable=v20
    format="0.0"
    editable=!showt && _isPaused()
    action=PY2[1]=vx2=v20
    text=" m/s "
    background=MAGENTA
    variable=v20
    minimum=-vmax
    maximum=vmax
    ticks=ns
    closest=true
    enabled=!showt&& _isPaused()
    dragaction=PY2[1]=vx2=v20
    background=MAGENTA
    tooltip="2 yellow dog's initial starting velocity"
    layout=VBOX
    layout=HBOX
    position=center
    text=" a2 = "
    background=RED
    variable=a2
    format="0.0"
    editable=!showt && _isPaused()
    text=" m/s^2 "
    background=RED
    variable=a2
    minimum=-amax
    maximum=amax
    ticks=ns
    enabled=!showt&& _isPaused()
    background=RED
    tooltip="2 yellow dog's constant acceleration"
    position=south
    layout=HBOX
    variable=ts
    minimum=zero
    maximum=tmax
    format=" t = 0.0 s"
    enabled=_isPaused
    dragaction=dragt()
    tooltip="time"
    variable=_isPaused
    tooltip="play/pause"
    imageOn=/org/opensourcephysics/resources/controls/images/play.gif
    actionOn=_play()
    imageOff="/org/opensourcephysics/resources/controls/images/pause.gif"
    actionOff=_pause()
    image="/org/opensourcephysics/resources/controls/images/initial.gif"
    action=_initialize()
    tooltip=%l_init%
    image="/org/opensourcephysics/resources/controls/images/reset.gif"
    action=_reset()
    tooltip=%l_reset%
    position=center
    layout=grid:1,0,0,0
    position=center
    autoscaleX=false
    autoscaleY=_isPlaying
    minimumX=zero
    maximumX=tmax
    minimumY=xmin
    maximumY=xmax
    title="x (m) versus t (s)"
    titleX=t (s)
    interiorBackground=200,220,208
    background=200,220,208
    x=t
    y=x1
    memory=2
    memorycolor=200,200,200,255
    norepeat=true
    connected=_isPlaying
    color=white
    stroke=stroke
    x=t
    y=x2
    memory=2
    memorycolor=200,200,0,255
    norepeat=true
    connected=_isPlaying
    color=yellow
    stroke=stroke
    x=ts
    y=x1s
    sizex=sizet
    sizey=size
    scaley=3
    visible=showt
    enabled=false
    secondaryColor=WHITE
    color=WHITE
    x=ts
    y=x2s
    sizex=sizet
    sizey=size
    scaley=3
    visible=showt
    enabled=false
    secondaryColor=YELLOW
    color=YELLOW
    x=ts
    y=x1s
    sizex=1
    sizey=v1s
    visible=showdxdt
    enabled=false
    color=MAGENTA
    secondaryColor=MAGENTA
    x=ts
    y=x2s
    sizex=1
    sizey=v2s
    visible=showdxdt2
    enabled=false
    color=MAGENTA
    secondaryColor=MAGENTA
    x=ts
    y=x1s
    visible=showdxdt
    enabled=false
    text=%title1%
    elementposition=NORTH_WEST
    color=255,0,255
    font=Dialog,PLAIN,12
    x=ts
    y=x2s
    visible=showdxdt2
    enabled=false
    text=%title2%
    elementposition=NORTH_WEST
    color=255,0,255
    font=Dialog,PLAIN,12
    x=ts
    y=x10
    sizex=0
    sizey=x1s-x10
    visible=showdisplacement
    style=ARROW
    color=BLUE
    secondaryColor=BLUE
    x=ts
    y=x20
    sizex=0
    sizey=x2s-x20
    visible=showdisplacement2
    style=ARROW
    color=BLUE
    secondaryColor=BLUE
    x=0
    y=x1s
    visible=showdisplacement
    enabled=false
    text=%displacment1%
    elementposition=NORTH_WEST
    color=BLUE
    font=Dialog,PLAIN,12
    x=0
    y=x2s
    visible=showdisplacement2
    enabled=false
    text=%displacment2%
    elementposition=NORTH_WEST
    color=BLUE
    font=Dialog,PLAIN,12
    x=0
    y=x1s
    sizex=ts
    sizey=0
    visible=showdisplacement
    style=SEGMENT
    color=0,0,255,50
    secondaryColor=0,0,255,50
    x=0
    y=x2s
    sizex=ts
    sizey=0
    visible=showdisplacement2
    style=SEGMENT
    color=0,0,255,50
    secondaryColor=0,0,255,50
    x=0
    y=x10
    sizex=ts
    sizey=0
    visible=showdisplacement
    style=SEGMENT
    color=0,0,255,50
    secondaryColor=0,0,255,50
    x=0
    y=x20
    sizex=ts
    sizey=0
    visible=showdisplacement2
    style=SEGMENT
    color=0,0,255,50
    secondaryColor=0,0,255,50
    autoscaleX=false
    autoscaleY=_isPlaying
    minimumX=zero
    maximumX=tmax
    title="v (m/s) versus t (s)"
    titleX=t (s)
    interiorBackground=200,220,208
    background=200,220,208
    x=t
    y=vx1
    memory=2
    memorycolor=200,200,200,255
    norepeat=true
    connected=_isPlaying
    color=white
    stroke=stroke
    x=t
    y=vx2
    memory=2
    memorycolor=200,200,0,255
    norepeat=true
    connected=_isPlaying
    color=yellow
    stroke=stroke
    x=ts
    y=v1s
    sizex=sizet
    sizey=size
    visible=showt
    enabled=false
    secondaryColor=WHITE
    color=WHITE
    x=ts
    y=v2s
    sizex=sizet
    sizey=size
    visible=showt
    enabled=false
    secondaryColor=YELLOW
    color=YELLOW
    maxpoints=np
    x=PT
    y=PY1
    visible=showdistance
    enabled=false
    color=255,255,255,50
    stroke=stroke
    maxpoints=np
    x=PT
    y=PY2
    visible=showdistance2
    enabled=false
    color=255,255,0,50
    stroke=stroke
    x=0
    y=v1s
    sizex=ts
    visible=showdxdt
    enabled=false
    style=SEGMENT
    color=255,0,255,50
    secondaryColor=255,0,255,50
    x=0
    y=v1s
    visible=showdxdt
    enabled=false
    text=%title1%
    elementposition=NORTH_WEST
    color=255,0,255
    font=Dialog,PLAIN,12
    x=0
    y=v2s
    sizex=ts
    visible=showdxdt2
    enabled=false
    style=SEGMENT
    color=255,0,255,50
    secondaryColor=255,0,255,50
    x=0
    y=v2s
    visible=showdxdt2
    enabled=false
    text=%title2%
    elementposition=NORTH_WEST
    color=255,0,255
    font=Dialog,PLAIN,12
    x=ts/2
    y=(v10+v1s)/(2*2)
    visible=showdistance
    enabled=false
    text=%area1%
    elementposition=NORTH_WEST
    color=BLUE
    font=Dialog,PLAIN,12
    x=ts/2
    y=(v20+v2s)/(2*2)
    visible=showdistance2
    enabled=false
    text=%area2%
    elementposition=NORTH_WEST
    color=BLUE
    font=Dialog,PLAIN,12