Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type coord2_i
- x as integer
- y as integer
- end type
- type coord2_d
- x as double
- y as double
- end type
- 'For radial/angle data
- type coord2_r
- r as double
- o as double
- end type
- 'Wrapper type for all these things, and associated constants
- const vector_Int = 0
- const vector_Dbl = 1
- const vector_Rad = 2 'radial types always use double precision
- const vector_Sph = 3 'so no need to designate data type
- const vector_Cyl = 4
- 'Most functions will be overloaded so type data isn't as important to distinguish
- 'here, but it's done for possible future considerations
- type vector2
- dataType as integer
- union
- i as coord2_i
- d as coord2_d
- r as coord2_r
- end union
- declare constructor() 'defaults to double I suppose
- declare constructor(x as integer, y as integer)
- declare constructor(a as double, b as double, dataType as integer) 'optional parameter defaults to vector_Dbl
- declare constructor(i_ as coord2_i)
- declare constructor(d_ as coord2_d)
- declare constructor(r_ as coord2_r)
- end type
- constructor vector2()
- d = type(0.0d, 0.0d)
- dataType = vector_Dbl
- end constructor
- constructor vector2(x as integer, y as integer)
- i = type(x,y)
- dataType = vector_Int
- end constructor
- constructor vector2(a as double, b as double, dataType as integer = vector_Dbl)
- select case dataType
- case vector_Dbl:
- d = type(a,b)
- dataType = vector_Dbl
- case vector_Rad:
- r = type(a,b)
- dataType = vector_Rad
- case else 'default to double in case garbage passed in
- d = type(a,b)
- dataType = vector_Dbl
- end select
- end constructor
- constructor vector2(i_ as coord2_i)
- i = i_
- dataType = vector_Int
- end constructor
- constructor vector2(d_ as coord2_d)
- d = d_
- dataType = vector_Dbl
- end constructor
- constructor vector2(r_ as coord2_r)
- r = r_
- dataType = vector_Rad
- end constructor
Add Comment
Please, Sign In to add comment