comparison src/zamikongine/math/vector.nim @ 481:c472abfcee57

add: generate ubermeshes
author Sam <sam@basx.dev>
date Tue, 10 Jan 2023 00:23:40 +0700
parents 14e5151f68d1
children 3f1111f3b9f8
comparison
equal deleted inserted replaced
480:14e5151f68d1 481:c472abfcee57
9 type 9 type
10 Vec2*[T: SomeNumber] = array[2, T] 10 Vec2*[T: SomeNumber] = array[2, T]
11 Vec3*[T: SomeNumber] = array[3, T] 11 Vec3*[T: SomeNumber] = array[3, T]
12 Vec4*[T: SomeNumber] = array[4, T] 12 Vec4*[T: SomeNumber] = array[4, T]
13 Vec* = Vec2|Vec3|Vec4 13 Vec* = Vec2|Vec3|Vec4
14
15 converter toVec2*[T: SomeNumber](orig: Vec3[T]|Vec4[T]): Vec2[T] =
16 Vec2[T]([orig[0], orig[1]])
17 converter toVec3*[T: SomeNumber](orig: Vec4[T]): Vec3[T] =
18 Vec2[T]([orig[0], orig[1], orig[2]])
14 19
15 # define some often used constants 20 # define some often used constants
16 func ConstOne2[T: SomeNumber](): auto {.compiletime.} = Vec2[T]([T(1), T(1)]) 21 func ConstOne2[T: SomeNumber](): auto {.compiletime.} = Vec2[T]([T(1), T(1)])
17 func ConstOne3[T: SomeNumber](): auto {.compiletime.} = Vec3[T]([T(1), T(1), T(1)]) 22 func ConstOne3[T: SomeNumber](): auto {.compiletime.} = Vec3[T]([T(1), T(1), T(1)])
18 func ConstOne4[T: SomeNumber](): auto {.compiletime.} = Vec4[T]([T(1), T(1), T(1), T(1)]) 23 func ConstOne4[T: SomeNumber](): auto {.compiletime.} = Vec4[T]([T(1), T(1), T(1), T(1)])