Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'File for basic data structures
- 'Coordinate structures
- '2D
- 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
- '3D
- type coord3_i 'I don't know if I'll need this but for completeness' sake
- x as integer
- y as integer
- z as integer
- end type
- type coord3_d
- x as double
- y as double
- z as double
- end type
- type coord3_s 'spherical
- r as double
- o as double
- p as double 'angle measured vertically from equator
- end type
- type coord3_c 'cylindrical
- r as double
- o as double
- z as double
- end type
- type vector3
- dataType as integer
- union
- i as coord3_i
- d as coord3_d
- s as coord3_s
- c as coord3_c
- end union
- declare constructor() 'defaults to double I suppose
- declare constructor(x as integer, y as integer, z as integer)
- declare constructor(a as double, b as double, c as double, dataType_ as integer) 'optional parameter defaults to vector_Dbl
- declare constructor(i_ as coord3_i)
- declare constructor(d_ as coord3_d)
- declare constructor(s_ as coord3_s)
- declare constructor(c_ as coord3_c)
- end type
- constructor vector3() 'defaults to double I suppose
- d = type(0.0d, 0.0d, 0.0d)
- dataType = vector_Dbl
- end constructor
- constructor vector3(x as integer, y as integer, z as integer)
- i = type(x,y,z)
- dataType = vector_Int
- end constructor
- constructor vector3(a as double, b as double, c as double, dataType_ as integer = vector_Dbl) 'optional parameter defaults to vector_Dbl
- select case dataType
- case vector_Dbl:
- d = type(a,b,c)
- dataType = vector_Dbl
- case vector_Sph:
- s = type(a,b,c)
- dataType = vector_Sph
- case vector_Cyl:
- c = type(a,b,c)
- dataType = vector_Cyl
- case else 'default do double in case of garbage input
- d = type(a,b,c)
- dataType = vector_Dbl
- end select
- end constructor
- constructor vector3(i_ as coord3_i)
- i = i_
- dataType = vector_Int
- end constructor
- constructor vector3(d_ as coord3_d)
- d = d_
- dataType = vector_Dbl
- end constructor
- constructor vector3(s_ as coord3_s)
- s = s_
- dataType = vector_Sph
- end constructor
- constructor vector3(c_ as coord3_c)
- c = c_
- dataType = vector_Cyl
- end constructor
- 'Colors
- 'RGB
- type rgb_d
- r as double
- g as double
- b as double
- end type
- type rgb_i
- r as integer
- g as integer
- b as integer
- end type
- 'also as byte
- type rgb_ub
- r as ubyte
- g as ubyte
- b as ubyte
- end type
- 'RGBA
- type rgba_d
- r as double
- g as double
- b as double
- a as double
- end type
- type rgba_i 'something else that will rarely if ever be used
- r as integer
- g as integer
- b as integer
- a as integer
- end type
- type rgba_ub
- r as ubyte
- g as ubyte
- b as ubyte
- a as ubyte
- end type
Add Comment
Please, Sign In to add comment