Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.82 KB | None | 0 0
  1. abstract type Panel <: Solution end
  2.  
  3. struct Panel2D <: Panel
  4.     xs :: Float64
  5.     ys :: Float64
  6.     xe :: Float64
  7.     ye :: Float64
  8.     xc :: Float64
  9.     yc :: Float64
  10.     length :: Float64
  11.     angle :: Float64
  12.     loc :: T where T <: AbstractString
  13.     function Panel2D(xs, ys, xe, ye)
  14.         xc, yc   = (xe + xs)/2.0, (ye + ys)/2.0
  15.         length = mag([ xe - xs, ye - ys ])
  16.         angle = xe <= xs ? acos((ye - ys)/length) : π + acos(-(ye - ys)/length)
  17.         loc = angle <= π ? "upper" : "lower"
  18.         new(xs, ys, xe, ye, xc, yc, length, angle, loc)
  19.     end
  20. end
  21.  
  22. mutable struct SourcePanel2D <: Panel2D
  23.     panel :: Panel2D
  24.     strength :: Float64
  25.     vt :: Float64
  26.     cp :: Float64
  27.     function SourcePanel2D(panel, strength=0.0, vt=0.0, cp=0.0)
  28.         new(panel, strength, vt, cp)
  29.     end
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement