Guest User

Untitled

a guest
Aug 20th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'File for basic data structures
  2.  
  3. 'Coordinate structures
  4.  
  5. '2D
  6.  
  7. type coord2_i
  8.     x as integer
  9.     y as integer
  10. end type
  11.  
  12. type coord2_d
  13.     x as double
  14.     y as double
  15. end type
  16.  
  17. 'For radial/angle data
  18. type coord2_r
  19.     r as double
  20.     o as double
  21. end type
  22.  
  23. 'Wrapper type for all these things, and associated constants
  24.  
  25. const vector_Int = 0
  26. const vector_Dbl = 1
  27. const vector_Rad = 2 'radial types always use double precision
  28. const vector_Sph = 3 'so no need to designate data type
  29. const vector_Cyl = 4
  30. 'Most functions will be overloaded so type data isn't as important to distinguish
  31. 'here, but it's done for possible future considerations
  32.  
  33. type vector2
  34.     dataType as integer
  35.     union
  36.         i as coord2_i
  37.         d as coord2_d
  38.         r as coord2_r
  39.     end union
  40.    
  41.     declare constructor() 'defaults to double I suppose
  42.     declare constructor(x as integer, y as integer)
  43.     declare constructor(a as double, b as double, dataType_ as integer) 'optional parameter defaults to vector_Dbl
  44.     declare constructor(i_ as coord2_i)
  45.     declare constructor(d_ as coord2_d)
  46.     declare constructor(r_ as coord2_r)
  47.    
  48. end type
  49.  
  50. constructor vector2()
  51.     d = type(0.0d, 0.0d)
  52.     dataType = vector_Dbl
  53. end constructor
  54.  
  55. constructor vector2(x as integer, y as integer)
  56.     i = type(x,y)
  57.     dataType = vector_Int
  58. end constructor
  59.  
  60. constructor vector2(a as double, b as double, dataType_ as integer = vector_Dbl)
  61.     select case dataType_
  62.     case vector_Dbl:
  63.         d = type(a,b)
  64.         dataType = vector_Dbl
  65.     case vector_Rad:
  66.         r = type(a,b)
  67.         dataType = vector_Rad
  68.     case else 'default to double in case garbage passed in
  69.         d = type(a,b)
  70.         dataType = vector_Dbl
  71.     end select
  72. end constructor
  73.  
  74. constructor vector2(i_ as coord2_i)
  75.     i = i_
  76.     dataType = vector_Int
  77. end constructor
  78.  
  79. constructor vector2(d_ as coord2_d)
  80.     d = d_
  81.     dataType = vector_Dbl
  82. end constructor
  83.  
  84. constructor vector2(r_ as coord2_r)
  85.     r = r_
  86.     dataType = vector_Rad
  87. end constructor
  88.  
  89.  
  90.  
  91. '3D
  92.  
  93. type coord3_i 'I don't know if I'll need this but for completeness' sake
  94.     x as integer
  95.     y as integer
  96.     z as integer
  97. end type
  98.  
  99. type coord3_d
  100.     x as double
  101.     y as double
  102.     z as double
  103. end type
  104.  
  105. type coord3_s 'spherical
  106.     r as double
  107.     o as double
  108.     p as double 'angle measured vertically from equator
  109. end type
  110.  
  111. type coord3_c 'cylindrical
  112.     r as double
  113.     o as double
  114.     z as double
  115. end type
  116.  
  117.  
  118. type vector3
  119.     dataType as integer
  120.     union
  121.         i as coord3_i
  122.         d as coord3_d
  123.         s as coord3_s
  124.         c as coord3_c
  125.     end union
  126.    
  127.     declare constructor() 'defaults to double I suppose
  128.     declare constructor(x as integer, y as integer, z as integer)
  129.     declare constructor(a as double, b as double, c as double, dataType_ as integer) 'optional parameter defaults to vector_Dbl
  130.     declare constructor(i_ as coord3_i)
  131.     declare constructor(d_ as coord3_d)
  132.     declare constructor(s_ as coord3_s)
  133.     declare constructor(c_ as coord3_c)
  134. end type
  135.  
  136. constructor vector3() 'defaults to double I suppose
  137.     d = type(0.0d, 0.0d, 0.0d)
  138.     dataType = vector_Dbl
  139. end constructor
  140.  
  141. constructor vector3(x as integer, y as integer, z as integer)
  142.     i = type(x,y,z)
  143.     dataType = vector_Int
  144. end constructor
  145.  
  146. constructor vector3(a as double, b as double, c as double, dataType_ as integer = vector_Dbl) 'optional parameter defaults to vector_Dbl
  147.     select case dataType
  148.     case vector_Dbl:
  149.         d = type(a,b,c)
  150.         dataType = vector_Dbl
  151.     case vector_Sph:
  152.         s = type(a,b,c)
  153.         dataType = vector_Sph
  154.     case vector_Cyl:
  155.         c = type(a,b,c)
  156.         dataType = vector_Cyl
  157.     case else 'default do double in case of garbage input
  158.         d = type(a,b,c)
  159.         dataType = vector_Dbl
  160.     end select
  161. end constructor
  162.  
  163. constructor vector3(i_ as coord3_i)
  164.     i = i_
  165.     dataType = vector_Int
  166. end constructor
  167.  
  168. constructor vector3(d_ as coord3_d)
  169.     d = d_
  170.     dataType = vector_Dbl
  171. end constructor
  172.  
  173. constructor vector3(s_ as coord3_s)
  174.     s = s_
  175.     dataType = vector_Sph
  176. end constructor
  177.  
  178. constructor vector3(c_ as coord3_c)
  179.     c = c_
  180.     dataType = vector_Cyl
  181. end constructor
  182.  
  183.  
  184.  
  185. 'Colors
  186.  
  187. 'RGB
  188.  
  189. type rgb_d
  190.     r as double
  191.     g as double
  192.     b as double
  193. end type
  194.  
  195. type rgb_i
  196.     r as integer
  197.     g as integer
  198.     b as integer
  199. end type
  200.  
  201. 'also as byte
  202. type rgb_ub
  203.     r as ubyte
  204.     g as ubyte
  205.     b as ubyte
  206. end type
  207.  
  208.  
  209. 'RGBA
  210.  
  211. type rgba_d
  212.     r as double
  213.     g as double
  214.     b as double
  215.     a as double
  216. end type
  217.  
  218. type rgba_i 'something else that will rarely if ever be used
  219.     r as integer
  220.     g as integer
  221.     b as integer
  222.     a as integer
  223. end type
  224.  
  225. type rgba_ub
  226.     r as ubyte
  227.     g as ubyte
  228.     b as ubyte
  229.     a as ubyte
  230. end type
Add Comment
Please, Sign In to add comment