SlideShare a Scribd company logo
1 of 22
Download to read offline
p3.f90


                                                                                   rootz31.f90




                                                        gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                        pivot.f90     baksub.f90                  eulexpl.f90



                                                       maxIndex.f90                               DG.f90

                                                                                                                F(s)




                                                                      Hemsida


Projekt: Basketbollkast                                         F¨rs¨ttsblad
                                                                 o a



                                                                      Inneh˚
                                                                           all




                                                                Sida 1 av 22


 av Grupp 3: Mikael B, J¨rgen H, Sofie J, Johannes L,
                        o                                             Tillbaka

           Anton N, Jenny P och Rasmus W
  f¨r kursen Ber¨kningsprogrammering, NUM131
   o            a                                                   Full Screen



                                                                           St¨ng
                                                                             a



                                                                       Avsluta
p3.f90


                                                                                                                           rootz31.f90




                                                                                                gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                                                                pivot.f90     baksub.f90                  eulexpl.f90




                  7                                                                            maxIndex.f90                               DG.f90

                                                                                                                                                        F(s)




                                1
                                2
                                                                                                              Hemsida
                                3
                  6
                                4
                                                                                                        F¨rs¨ttsblad
                                                                                                         o a


                  5
                                                                                                              Inneh˚
                                                                                                                   all
     height (m)




                  4



                  3

                                                                                                        Sida 2 av 22


                  2
                                                                                                              Tillbaka



                  1                                                                                         Full Screen
                      0   0.2       0.4   0.6   0.8         1      1.2   1.4   1.6   1.8   2
                                                      distance (m)
                                                                                                                   St¨ng
                                                                                                                     a



z0 = 0.2 s, α0 = 77◦, z ∗ = 88.264 ms, α∗ = 42.868◦.                                                           Avsluta
p3.f90


                                                                                                             rootz31.f90




                                                                                  gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                                                  pivot.f90     baksub.f90                  eulexpl.f90



                    12                                                           maxIndex.f90                               DG.f90

                                                                                                                                          F(s)




                                                                                                Hemsida
                    10


                                                                                          F¨rs¨ttsblad
                                                                                           o a


                     8

                                                                                                Inneh˚
                                                                                                     all
       height (m)




                     6




                     4



                                                                                          Sida 3 av 22

                     2
                                                            Korgen
                                                            1                                   Tillbaka
                                                            2
                                                            3
                                                            4

                     0                                                                        Full Screen
                         0   1   2   3                  4            5   6   7
                                         distance (m)


                                                                                                     St¨ng
                                                                                                       a



z0 = 3.5 s, α0 = 70◦, z ∗ = 3.554 s, α∗ = 86.826◦.                                               Avsluta
p3.f90


                                                                                                          rootz31.f90




                                                                               gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                 p3.f90                                        pivot.f90



                                                                              maxIndex.f90
                                                                                             baksub.f90                  eulexpl.f90



                                                                                                                         DG.f90

                                                                                                                                       F(s)




                                                                                             Hemsida

                               rootz31.f90
                                                                                       F¨rs¨ttsblad
                                                                                        o a



                                                                                             Inneh˚
                                                                                                  all

    gauss.f90       jacobi.f90               MyG.f90               pyts.f90




    pivot.f90     baksub.f90                  eulexpl.f90
                                                                                       Sida 4 av 22



   maxIndex.f90                               DG.f90                                         Tillbaka


                                                            F(s)
                                                                                           Full Screen



                                                                                                  St¨ng
                                                                                                    a
Subrutiner och funktioner i programmet p3 och deras relationer.
                                                                                              Avsluta
Interfaces:
                                                                                     p3.f90




subroutine rootz31(f, x0, tol,   maxIter, xst, ierr)    gauss.f90       jacobi.f90
                                                                                   rootz31.f90




                                                                                                 MyG.f90               pyts.f90




  implicit none                                         pivot.f90



                                                       maxIndex.f90
                                                                      baksub.f90                  eulexpl.f90



                                                                                                  DG.f90

                                                                                                                F(s)




  real(kind=8), intent(in) ::    x0(2), tol
  integer, intent(in)       ::   maxIter                              Hemsida


  real(kind=8), intent(out) ::   xst(2)
                                                                F¨rs¨ttsblad
                                                                 o a
  integer, intent(out)      ::   ierr
                                                                      Inneh˚
                                                                           all

  external f
end subroutine rootz31

real(kind = 8) function pyts(x)
  implicit none                                                 Sida 5 av 22
  real(kind = 8), intent(in) :: x(2)
end function pyts                                                     Tillbaka




subroutine jacobi(f, fx, x, jret)                                   Full Screen


  implicit none
                                                                           St¨ng
                                                                             a
  real(kind = 8), intent(in) :: fx(2), x(2)
  real(kind = 8), intent(out) :: jret(2,2)                             Avsluta
  external f
end subroutine jacobi
p3.f90


                                                                                     rootz31.f90




                                                          gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                          pivot.f90     baksub.f90                  eulexpl.f90



                                                         maxIndex.f90                               DG.f90

                                                                                                                  F(s)




Interfaces: (forts)
                                                                        Hemsida
subroutine MyG(z0alpha0, xy, printing)
  implicit none
                                                                  F¨rs¨ttsblad
                                                                   o a
  real(kind=8), intent(in) :: z0alpha0(2)
  real(kind=8), intent(out) :: xy(2)                                    Inneh˚
                                                                             all

  logical, intent(in)       :: printing
end subroutine MyG

subroutine eulexpl(yprim, ts, y0, divs, t, Y)
  implicit none                                                   Sida 6 av 22

  real(kind=8), intent(in) :: ts(2), y0(5)
  integer, intent(in)       :: divs                                     Tillbaka

  real(kind=8), intent(out) :: t(divs+1), Y(divs+1, 5)
                                                                      Full Screen
  external yprim
end subroutine eulexpl                                                       St¨ng
                                                                               a



                                                                         Avsluta
p3.f90


                                                                     rootz31.f90




                                          gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                          pivot.f90     baksub.f90                  eulexpl.f90



                                         maxIndex.f90                               DG.f90

                                                                                                  F(s)




                                                        Hemsida



Interfaces: (forts)                               F¨rs¨ttsblad
                                                   o a
subroutine DG(t, G, Gd)
   implicit none                                        Inneh˚
                                                             all

   real(kind=8), intent(in) :: t, G(5)
   real(kind=8), intent(out) :: Gd(5)
end subroutine DG

real(kind=8) function F(s)                        Sida 7 av 22

   implicit none
   real(kind=8), intent(in) :: s                        Tillbaka


end function F
                                                      Full Screen



                                                             St¨ng
                                                               a



                                                         Avsluta
p3.f90


                                                                           rootz31.f90




                                                gauss.f90       jacobi.f90               MyG.f90               pyts.f90




Interfaces: (forts)                             pivot.f90



                                               maxIndex.f90
                                                              baksub.f90                  eulexpl.f90



                                                                                          DG.f90




subroutine gauss(A, b, x, r)                                                                            F(s)




  implicit none                                               Hemsida

  real(kind=8), intent(in) :: A(2,2), b(2)
  real(kind=8), intent(out) :: x(2)                     F¨rs¨ttsblad
                                                         o a


  integer, intent(out)      :: r
                                                              Inneh˚
                                                                   all
end subroutine gauss

    subroutine pivot(A, m, Aret)
      implicit none
      real(kind=8), intent(in) :: A(2, 3)
                                                        Sida 8 av 22
      integer, intent(in)      :: m
      real(kind=8), intent(out):: Aret(2, 3)                  Tillbaka
    end subroutine pivot
                                                            Full Screen

    integer function maxIndex(y)
                                                                   St¨ng
                                                                     a
      real(kind=8), intent(in) :: y(:)
    end function maxIndex
                                                               Avsluta
p3.f90


                                                                                  rootz31.f90




                                                       gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                       pivot.f90     baksub.f90                  eulexpl.f90



                                                      maxIndex.f90                               DG.f90

                                                                                                               F(s)




                                                                     Hemsida



                                                               F¨rs¨ttsblad
                                                                o a




Interfaces: (sista)                                                  Inneh˚
                                                                          all

      subroutine baksub(U, b, x, ierr)
           implicit none
           real(kind=8), intent(in) :: U(2,2), b(2)
           real(kind=8), intent(out) :: x(2)
           integer, intent(out)      :: ierr                   Sida 9 av 22

      end subroutine baksub
                                                                     Tillbaka



                                                                   Full Screen



                                                                          St¨ng
                                                                            a



                                                                      Avsluta
p3.f90


                                                                                       rootz31.f90




                                                            gauss.f90       jacobi.f90               MyG.f90               pyts.f90




p3:                                                         pivot.f90



                                                           maxIndex.f90
                                                                          baksub.f90                  eulexpl.f90



                                                                                                      DG.f90




write (*, *) ’Ange startv¨rdet z0’
                         a                                                                                          F(s)




read (*, *) z0                                                            Hemsida

write (*, *) ’Ange begynnelsevinkeln i grader’
read (*, *) alphadeg                                                F¨rs¨ttsblad
                                                                     o a


alpha0 = alphadeg*pi/180 ! R¨knar om vinkeln fr˚n grader
                            a                  a
                                                                          Inneh˚
                                                                               all
                         !    till radianer
x0(1) = z0
x0(2) = alpha0 ! S¨tter in startv¨rdena i en vektor
                   a              a

open(unit = 15, file=’matG.m’, status=’unknown’, &
                                                                 Sida 10 av 22
   & action=’write’, iostat=oerr)
write (15, *) ’G=[’                                                       Tillbaka
call rootz31(MyG, x0, tol, maxIter, xst, ierr)
write (15, *) ’];’                                                      Full Screen

close(15)
write (*, *) ’V¨rdena f¨r x- och y-koordinater ¨r&
               a       o                       a                               St¨ng
                                                                                 a


   & skrivna i filen matG.m.’
                                                                           Avsluta
p3.f90


                                                                                       rootz31.f90




                                                            gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                            pivot.f90     baksub.f90                  eulexpl.f90



                                                           maxIndex.f90                               DG.f90

                                                                                                                    F(s)




                                                                          Hemsida




p3: (forts)                                                         F¨rs¨ttsblad
                                                                     o a


z = xst(1)
                                                                          Inneh˚
                                                                               all
alphast = xst(2)  ! F˚r ut de slutliga v¨rdena i form av
                     a                  a
                  !    en vektor
alphastdeg = alphast*180/pi ! R¨knar om vinkeln fr˚n
                                a                  a
                             !    radianer till grader
write (*, *) ’Bollen m˚ste skickas iv¨g med vinkeln’, &
                      a              a
                                                                 Sida 11 av 22
   & alphastdeg, ’grader f¨r att tr¨ffa korgen’
                          o        a
write (*, *) ’Tiden det tar f¨r bollen att n˚ korgen &
                             o              a                             Tillbaka
   &¨r’, z, ’sekunder.’
    a
                                                                        Full Screen



                                                                               St¨ng
                                                                                 a



                                                                           Avsluta
p3.f90


                                                                                  rootz31.f90




                                                       gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                       pivot.f90     baksub.f90                  eulexpl.f90




subroutine rootz31(f, x0, tol, maxiter, xst, ierr):   maxIndex.f90                               DG.f90

                                                                                                               F(s)




  tol2 = tol**2
                                                                     Hemsida


  x = x0                                                       F¨rs¨ttsblad
                                                                o a
  do i = 1, maxIter
     call f(x, fx, printing)                                         Inneh˚
                                                                          all

     call jacobi(f, fx, x, jx)
     call gauss(jx, fx, deltax, r)
     x = x - deltax
     if (pyts(deltax) < tol2) then
        ierr = 0                                            Sida 12 av 22

        xst = x
        return                                                       Tillbaka


     end if
                                                                   Full Screen
  end do
                                                                          St¨ng
                                                                            a
  ierr = 1
                                                                      Avsluta
p3.f90


                                                                rootz31.f90




                                     gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                     pivot.f90     baksub.f90                  eulexpl.f90



                                    maxIndex.f90                               DG.f90

                                                                                             F(s)




                                                   Hemsida



                                             F¨rs¨ttsblad
                                              o a



                                                   Inneh˚
                                                        all



real(kind = 8) function pyts(x):
real(kind = 8), intent(in):: x(2)

pyts = x(1)*x(1) + x(2)*x(2)
                                          Sida 13 av 22



                                                   Tillbaka



                                                 Full Screen



                                                        St¨ng
                                                          a



                                                    Avsluta
p3.f90


                                                                       rootz31.f90




                                            gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                            pivot.f90     baksub.f90                  eulexpl.f90



                                           maxIndex.f90                               DG.f90

                                                                                                    F(s)




                                                          Hemsida



subroutine jacobi(f, fx, x, J):                     F¨rs¨ttsblad
                                                     o a
  E(1,1) = 1
  E(1,2) = 0                                              Inneh˚
                                                               all

  E(2,1) = 0
  E(2,2) = 1

  do i = 1, n
     xplushe = x + h*E(:, i)                     Sida 14 av 22

     call f(xplushe, fxplushe, printing)
     J(:, i) = (fxplushe - fx)/h                          Tillbaka


  end do
                                                        Full Screen



                                                               St¨ng
                                                                 a



                                                           Avsluta
p3.f90




subroutine MyG(z0alpha0, xy, printing):
                                                                                        rootz31.f90




                                                             gauss.f90       jacobi.f90               MyG.f90               pyts.f90




  z0 = z0alpha0(1)
                                                             pivot.f90     baksub.f90                  eulexpl.f90



                                                            maxIndex.f90                               DG.f90

                                                                                                                     F(s)




  alpha0 = z0alpha0(2)
                                                                           Hemsida
  G0(1) = x0
  G0(2) = y0                                                         F¨rs¨ttsblad
                                                                      o a
  G0(3) = z0
  G0(4) = s0*cos(alpha0); ! vx0, alpha0 from ground plane                  Inneh˚
                                                                                all

  G0(5) = s0*sin(alpha0); ! vy0
  ts = (/ 0, 1 /)
  call eulexpl(DG, ts, G0, divs, t, G)
  if (printing) then
     do i = 1, size(G, 1)                                         Sida 15 av 22

         write (unit=15, fmt=’(f20.14)’, advance=’no’) &
            & G(i, 1)                                                      Tillbaka


         if (mod(i, 3) == 0) then
                                                                         Full Screen
            write (15, *) ’ ...’
         end if                                                                 St¨ng
                                                                                  a
     end do
     write (15, *) ’;’                                                      Avsluta
p3.f90


                                                                                       rootz31.f90




                                                            gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                            pivot.f90     baksub.f90                  eulexpl.f90



                                                           maxIndex.f90                               DG.f90

                                                                                                                    F(s)




                                                                          Hemsida

subroutine MyG(z0alpha0, xy, printing): (forts)
     do i = 1, size(G, 1)                                           F¨rs¨ttsblad
                                                                     o a

         write (unit=15, fmt=’(f20.14)’, advance=’no’) &
                                                                          Inneh˚
                                                                               all
            & G(i, 2)
         if (mod(i, 3) == 0) then
            write (15, *) ’ ...’
         end if
     end do
                                                                 Sida 16 av 22
     write (15, *) ’;’
  end if
                                                                          Tillbaka
  xy(1) = G(size(G, 1), 1) - x_B
  xy(2) = G(size(G, 1), 2) - y_B                                        Full Screen



                                                                               St¨ng
                                                                                 a



                                                                           Avsluta
p3.f90


                                                                                   rootz31.f90




                                                        gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                        pivot.f90     baksub.f90                  eulexpl.f90



                                                       maxIndex.f90                               DG.f90

                                                                                                                F(s)




                                                                      Hemsida

subroutine eulexpl(yprim, ts, y0, divs, tret, Yret):
  h = (ts(2) - ts(1))/divs ! h ¨r stegl¨ngden
                                    a         a                 F¨rs¨ttsblad
                                                                 o a


  ! skapar en vektor t med tidpunkter
                                                                      Inneh˚
                                                                           all
  do i = 1, divs+1
     tret(i) = (i-1)*h+ts(1)
  end do
  Yret(1, :) = y0 !tilldelning av initialv¨rde    a
  do i = 1, divs
                                                             Sida 17 av 22
     Ya = Yret(i,:) !(a = aktuell)
     call yprim(tret(i), Ya, Yd)                                      Tillbaka
     Yret(i+1, :) = Yret(i, :) + Yd*h
  end do                                                            Full Screen



                                                                           St¨ng
                                                                             a



                                                                       Avsluta
subroutine DG(t, G, Gd):
                                                                              p3.f90


                                                                            rootz31.f90




  x = G(1)
                                                 gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                 pivot.f90     baksub.f90                  eulexpl.f90



                                                maxIndex.f90                               DG.f90




  y = G(2)                                                                                               F(s)




  z = G(3)                                                     Hemsida

  vx = G(4)
  vy = G(5)                                              F¨rs¨ttsblad
                                                          o a



                                                               Inneh˚
                                                                    all
  xd = vx * z
  yd = vy * z
  s = sqrt(xd**2 + yd**2)
  alpha = acos(xd / s)
                                                      Sida 18 av 22
  ! Gd = 0
  Gd(1) =    xd                                                Tillbaka
  Gd(2) =    yd
  Gd(3) =    0                                               Full Screen

  Gd(4) =    -F(s) * z * cos(alpha)
                                                                    St¨ng
                                                                      a
  Gd(5) =    -F(s) * z * sin(alpha) - gravity
                                                                Avsluta
contains
p3.f90


                                                                                    rootz31.f90




                                                         gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                         pivot.f90     baksub.f90                  eulexpl.f90



                                                        maxIndex.f90                               DG.f90

                                                                                                                 F(s)




                                                                       Hemsida



                                                                 F¨rs¨ttsblad
                                                                  o a



                                                                       Inneh˚
                                                                            all




real(kind=8) function F(s):
     F = (1.0/2.0) * rho * c_w * (pi/4) * d**2 * s**2

                                                              Sida 19 av 22



                                                                       Tillbaka



                                                                     Full Screen



                                                                            St¨ng
                                                                              a



                                                                        Avsluta
p3.f90


                                                                                  rootz31.f90




                                                       gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                       pivot.f90     baksub.f90                  eulexpl.f90



                                                      maxIndex.f90                               DG.f90

                                                                                                               F(s)




                                                                     Hemsida



                                                               F¨rs¨ttsblad
                                                                o a
subroutine gauss(A, b, x, r):
  det = A(1,1)*A(2,2) - A(1,2)*A(2,1)
                                                                     Inneh˚
                                                                          all
  if(abs(det) < tol) then
     stop ’Fel i funktionen gauss. Singul¨r matris’
                                         a
  end if

 x(1) = (b(1)*A(2,2) - b(2)*A(1,2))/det
                                                            Sida 20 av 22
 x(2) = (b(2)*A(1,1) - b(1)*A(2,1))/det
                                                                     Tillbaka
 r = 2
                                                                   Full Screen



                                                                          St¨ng
                                                                            a



                                                                      Avsluta
p3.f90


                                                                                            rootz31.f90




                                                                 gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                                 pivot.f90     baksub.f90                  eulexpl.f90



                                                                maxIndex.f90                               DG.f90

                                                                                                                         F(s)




Genomf¨randeplan
      o                                                                        Hemsida



 • Fungerande MATLAB-prototyp                                            F¨rs¨ttsblad
                                                                          o a


   ¨
 • Overs¨ttning till Fortran 95
        a                                                                      Inneh˚
                                                                                    all



     - Konstruktion av interfaces

 • Skriva Fortran-program-, subrutin- och funktionsinterfaces
 • Konstruktion av skelett av intefaces                               Sida 21 av 22


 • Test av varje enskilt program & subrutin
                                                                               Tillbaka

 • Hops¨ttning av fungerande skelett + test
       a
                                                                             Full Screen

 • MATLAB for att visa resultat
           ¨
                                                                                    St¨ng
                                                                                      a



                                                                                Avsluta
p3.f90


                                                                                                                                                                                                                rootz31.f90




                                                                                                                                                                                     gauss.f90       jacobi.f90               MyG.f90               pyts.f90




                                                                                                                                                                                     pivot.f90     baksub.f90                  eulexpl.f90



                                                                                                                                                                                    maxIndex.f90                               DG.f90

                                                                                                                                                                                                                                             F(s)




                 7
                               1
                               2
                               3
                 6
                               4                                                                                       12                                                                          Hemsida

                 5                                                                                                     10
    height (m)




                                                                                                                        8

                 4                                                                                                                                                                           F¨rs¨ttsblad
                                                                                                                                                                                              o a




                                                                                                          height (m)
                                                                                                                        6


                 3

                                                                                                                        4




                 2
                                                                                                                                                                                                   Inneh˚
                                                                                                                                                                                                        all
                                                                                                                        2
                                                                                                                                                               Korgen
                                                                                                                                                               1
                                                                                                                                                               2
                                                                                                                                                               3
                                                                                                                                                               4
                 1                                                                                                      0
                     0   0.2       0.4   0.6      0.8         1      1.2   1.4    1.6      1.8     2                        0   1   2   3                  4            5   6   7
                                                                                                                                            distance (m)
                                                        distance (m)



                                                   p3.f90


                                                rootz31.f90




 gauss.f90                           jacobi.f90                   MyG.f90                      pyts.f90                                                                                   Sida 22 av 22


 pivot.f90                         baksub.f90                       eulexpl.f90
                                                                                                                                                                                                   Tillbaka

maxIndex.f90                                                        DG.f90

                                                                                        F(s)
                                                                                                                                                                                                 Full Screen


                                                                             Trevlig sommar!
                                                                                                                                                                                                        St¨ng
                                                                                                                                                                                                          a



                                                                                                                                                                                                    Avsluta

More Related Content

Featured

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Basketball Throw Simulation (Basketbollkast)

  • 1. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Hemsida Projekt: Basketbollkast F¨rs¨ttsblad o a Inneh˚ all Sida 1 av 22 av Grupp 3: Mikael B, J¨rgen H, Sofie J, Johannes L, o Tillbaka Anton N, Jenny P och Rasmus W f¨r kursen Ber¨kningsprogrammering, NUM131 o a Full Screen St¨ng a Avsluta
  • 2. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 7 maxIndex.f90 DG.f90 F(s) 1 2 Hemsida 3 6 4 F¨rs¨ttsblad o a 5 Inneh˚ all height (m) 4 3 Sida 2 av 22 2 Tillbaka 1 Full Screen 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 distance (m) St¨ng a z0 = 0.2 s, α0 = 77◦, z ∗ = 88.264 ms, α∗ = 42.868◦. Avsluta
  • 3. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 12 maxIndex.f90 DG.f90 F(s) Hemsida 10 F¨rs¨ttsblad o a 8 Inneh˚ all height (m) 6 4 Sida 3 av 22 2 Korgen 1 Tillbaka 2 3 4 0 Full Screen 0 1 2 3 4 5 6 7 distance (m) St¨ng a z0 = 3.5 s, α0 = 70◦, z ∗ = 3.554 s, α∗ = 86.826◦. Avsluta
  • 4. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 p3.f90 pivot.f90 maxIndex.f90 baksub.f90 eulexpl.f90 DG.f90 F(s) Hemsida rootz31.f90 F¨rs¨ttsblad o a Inneh˚ all gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 Sida 4 av 22 maxIndex.f90 DG.f90 Tillbaka F(s) Full Screen St¨ng a Subrutiner och funktioner i programmet p3 och deras relationer. Avsluta
  • 5. Interfaces: p3.f90 subroutine rootz31(f, x0, tol, maxIter, xst, ierr) gauss.f90 jacobi.f90 rootz31.f90 MyG.f90 pyts.f90 implicit none pivot.f90 maxIndex.f90 baksub.f90 eulexpl.f90 DG.f90 F(s) real(kind=8), intent(in) :: x0(2), tol integer, intent(in) :: maxIter Hemsida real(kind=8), intent(out) :: xst(2) F¨rs¨ttsblad o a integer, intent(out) :: ierr Inneh˚ all external f end subroutine rootz31 real(kind = 8) function pyts(x) implicit none Sida 5 av 22 real(kind = 8), intent(in) :: x(2) end function pyts Tillbaka subroutine jacobi(f, fx, x, jret) Full Screen implicit none St¨ng a real(kind = 8), intent(in) :: fx(2), x(2) real(kind = 8), intent(out) :: jret(2,2) Avsluta external f end subroutine jacobi
  • 6. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Interfaces: (forts) Hemsida subroutine MyG(z0alpha0, xy, printing) implicit none F¨rs¨ttsblad o a real(kind=8), intent(in) :: z0alpha0(2) real(kind=8), intent(out) :: xy(2) Inneh˚ all logical, intent(in) :: printing end subroutine MyG subroutine eulexpl(yprim, ts, y0, divs, t, Y) implicit none Sida 6 av 22 real(kind=8), intent(in) :: ts(2), y0(5) integer, intent(in) :: divs Tillbaka real(kind=8), intent(out) :: t(divs+1), Y(divs+1, 5) Full Screen external yprim end subroutine eulexpl St¨ng a Avsluta
  • 7. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Hemsida Interfaces: (forts) F¨rs¨ttsblad o a subroutine DG(t, G, Gd) implicit none Inneh˚ all real(kind=8), intent(in) :: t, G(5) real(kind=8), intent(out) :: Gd(5) end subroutine DG real(kind=8) function F(s) Sida 7 av 22 implicit none real(kind=8), intent(in) :: s Tillbaka end function F Full Screen St¨ng a Avsluta
  • 8. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 Interfaces: (forts) pivot.f90 maxIndex.f90 baksub.f90 eulexpl.f90 DG.f90 subroutine gauss(A, b, x, r) F(s) implicit none Hemsida real(kind=8), intent(in) :: A(2,2), b(2) real(kind=8), intent(out) :: x(2) F¨rs¨ttsblad o a integer, intent(out) :: r Inneh˚ all end subroutine gauss subroutine pivot(A, m, Aret) implicit none real(kind=8), intent(in) :: A(2, 3) Sida 8 av 22 integer, intent(in) :: m real(kind=8), intent(out):: Aret(2, 3) Tillbaka end subroutine pivot Full Screen integer function maxIndex(y) St¨ng a real(kind=8), intent(in) :: y(:) end function maxIndex Avsluta
  • 9. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Hemsida F¨rs¨ttsblad o a Interfaces: (sista) Inneh˚ all subroutine baksub(U, b, x, ierr) implicit none real(kind=8), intent(in) :: U(2,2), b(2) real(kind=8), intent(out) :: x(2) integer, intent(out) :: ierr Sida 9 av 22 end subroutine baksub Tillbaka Full Screen St¨ng a Avsluta
  • 10. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 p3: pivot.f90 maxIndex.f90 baksub.f90 eulexpl.f90 DG.f90 write (*, *) ’Ange startv¨rdet z0’ a F(s) read (*, *) z0 Hemsida write (*, *) ’Ange begynnelsevinkeln i grader’ read (*, *) alphadeg F¨rs¨ttsblad o a alpha0 = alphadeg*pi/180 ! R¨knar om vinkeln fr˚n grader a a Inneh˚ all ! till radianer x0(1) = z0 x0(2) = alpha0 ! S¨tter in startv¨rdena i en vektor a a open(unit = 15, file=’matG.m’, status=’unknown’, & Sida 10 av 22 & action=’write’, iostat=oerr) write (15, *) ’G=[’ Tillbaka call rootz31(MyG, x0, tol, maxIter, xst, ierr) write (15, *) ’];’ Full Screen close(15) write (*, *) ’V¨rdena f¨r x- och y-koordinater ¨r& a o a St¨ng a & skrivna i filen matG.m.’ Avsluta
  • 11. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Hemsida p3: (forts) F¨rs¨ttsblad o a z = xst(1) Inneh˚ all alphast = xst(2) ! F˚r ut de slutliga v¨rdena i form av a a ! en vektor alphastdeg = alphast*180/pi ! R¨knar om vinkeln fr˚n a a ! radianer till grader write (*, *) ’Bollen m˚ste skickas iv¨g med vinkeln’, & a a Sida 11 av 22 & alphastdeg, ’grader f¨r att tr¨ffa korgen’ o a write (*, *) ’Tiden det tar f¨r bollen att n˚ korgen & o a Tillbaka &¨r’, z, ’sekunder.’ a Full Screen St¨ng a Avsluta
  • 12. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 subroutine rootz31(f, x0, tol, maxiter, xst, ierr): maxIndex.f90 DG.f90 F(s) tol2 = tol**2 Hemsida x = x0 F¨rs¨ttsblad o a do i = 1, maxIter call f(x, fx, printing) Inneh˚ all call jacobi(f, fx, x, jx) call gauss(jx, fx, deltax, r) x = x - deltax if (pyts(deltax) < tol2) then ierr = 0 Sida 12 av 22 xst = x return Tillbaka end if Full Screen end do St¨ng a ierr = 1 Avsluta
  • 13. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Hemsida F¨rs¨ttsblad o a Inneh˚ all real(kind = 8) function pyts(x): real(kind = 8), intent(in):: x(2) pyts = x(1)*x(1) + x(2)*x(2) Sida 13 av 22 Tillbaka Full Screen St¨ng a Avsluta
  • 14. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Hemsida subroutine jacobi(f, fx, x, J): F¨rs¨ttsblad o a E(1,1) = 1 E(1,2) = 0 Inneh˚ all E(2,1) = 0 E(2,2) = 1 do i = 1, n xplushe = x + h*E(:, i) Sida 14 av 22 call f(xplushe, fxplushe, printing) J(:, i) = (fxplushe - fx)/h Tillbaka end do Full Screen St¨ng a Avsluta
  • 15. p3.f90 subroutine MyG(z0alpha0, xy, printing): rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 z0 = z0alpha0(1) pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) alpha0 = z0alpha0(2) Hemsida G0(1) = x0 G0(2) = y0 F¨rs¨ttsblad o a G0(3) = z0 G0(4) = s0*cos(alpha0); ! vx0, alpha0 from ground plane Inneh˚ all G0(5) = s0*sin(alpha0); ! vy0 ts = (/ 0, 1 /) call eulexpl(DG, ts, G0, divs, t, G) if (printing) then do i = 1, size(G, 1) Sida 15 av 22 write (unit=15, fmt=’(f20.14)’, advance=’no’) & & G(i, 1) Tillbaka if (mod(i, 3) == 0) then Full Screen write (15, *) ’ ...’ end if St¨ng a end do write (15, *) ’;’ Avsluta
  • 16. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Hemsida subroutine MyG(z0alpha0, xy, printing): (forts) do i = 1, size(G, 1) F¨rs¨ttsblad o a write (unit=15, fmt=’(f20.14)’, advance=’no’) & Inneh˚ all & G(i, 2) if (mod(i, 3) == 0) then write (15, *) ’ ...’ end if end do Sida 16 av 22 write (15, *) ’;’ end if Tillbaka xy(1) = G(size(G, 1), 1) - x_B xy(2) = G(size(G, 1), 2) - y_B Full Screen St¨ng a Avsluta
  • 17. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Hemsida subroutine eulexpl(yprim, ts, y0, divs, tret, Yret): h = (ts(2) - ts(1))/divs ! h ¨r stegl¨ngden a a F¨rs¨ttsblad o a ! skapar en vektor t med tidpunkter Inneh˚ all do i = 1, divs+1 tret(i) = (i-1)*h+ts(1) end do Yret(1, :) = y0 !tilldelning av initialv¨rde a do i = 1, divs Sida 17 av 22 Ya = Yret(i,:) !(a = aktuell) call yprim(tret(i), Ya, Yd) Tillbaka Yret(i+1, :) = Yret(i, :) + Yd*h end do Full Screen St¨ng a Avsluta
  • 18. subroutine DG(t, G, Gd): p3.f90 rootz31.f90 x = G(1) gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 y = G(2) F(s) z = G(3) Hemsida vx = G(4) vy = G(5) F¨rs¨ttsblad o a Inneh˚ all xd = vx * z yd = vy * z s = sqrt(xd**2 + yd**2) alpha = acos(xd / s) Sida 18 av 22 ! Gd = 0 Gd(1) = xd Tillbaka Gd(2) = yd Gd(3) = 0 Full Screen Gd(4) = -F(s) * z * cos(alpha) St¨ng a Gd(5) = -F(s) * z * sin(alpha) - gravity Avsluta contains
  • 19. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Hemsida F¨rs¨ttsblad o a Inneh˚ all real(kind=8) function F(s): F = (1.0/2.0) * rho * c_w * (pi/4) * d**2 * s**2 Sida 19 av 22 Tillbaka Full Screen St¨ng a Avsluta
  • 20. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Hemsida F¨rs¨ttsblad o a subroutine gauss(A, b, x, r): det = A(1,1)*A(2,2) - A(1,2)*A(2,1) Inneh˚ all if(abs(det) < tol) then stop ’Fel i funktionen gauss. Singul¨r matris’ a end if x(1) = (b(1)*A(2,2) - b(2)*A(1,2))/det Sida 20 av 22 x(2) = (b(2)*A(1,1) - b(1)*A(2,1))/det Tillbaka r = 2 Full Screen St¨ng a Avsluta
  • 21. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) Genomf¨randeplan o Hemsida • Fungerande MATLAB-prototyp F¨rs¨ttsblad o a ¨ • Overs¨ttning till Fortran 95 a Inneh˚ all - Konstruktion av interfaces • Skriva Fortran-program-, subrutin- och funktionsinterfaces • Konstruktion av skelett av intefaces Sida 21 av 22 • Test av varje enskilt program & subrutin Tillbaka • Hops¨ttning av fungerande skelett + test a Full Screen • MATLAB for att visa resultat ¨ St¨ng a Avsluta
  • 22. p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 pivot.f90 baksub.f90 eulexpl.f90 maxIndex.f90 DG.f90 F(s) 7 1 2 3 6 4 12 Hemsida 5 10 height (m) 8 4 F¨rs¨ttsblad o a height (m) 6 3 4 2 Inneh˚ all 2 Korgen 1 2 3 4 1 0 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0 1 2 3 4 5 6 7 distance (m) distance (m) p3.f90 rootz31.f90 gauss.f90 jacobi.f90 MyG.f90 pyts.f90 Sida 22 av 22 pivot.f90 baksub.f90 eulexpl.f90 Tillbaka maxIndex.f90 DG.f90 F(s) Full Screen Trevlig sommar! St¨ng a Avsluta