Permalink
Browse files

fixing lines

  • Loading branch information...
phpboxxx committed Mar 12, 2012
2 parents c1f76de + 8719b3a commit 6be87bc0ded2f434a058a97f125824adc98fcbbe
Showing with 1 addition and 1 deletion.
  1. +1 −1 system/classes/vector.bas
@@ -1 +1 @@
'DEFINE VECTOR TYPESType vec2 x As Single y As SingleEnd TypeType vec3 x As Single y As Single z As SingleEnd TypeType vec4 x As Single y As Single z As Single w As SingleEnd Type'OPERATORS'ADDOperator + ( v1 As vec2, v2 As vec2 ) As vec2 Return type<vec2>( v1.x + v2.x, v1.y + v2.y)End OperatorOperator + ( v1 As vec3, v2 As vec3 ) As vec3 Return type<vec3>( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z )End Operator'SUBSTRACTOperator - ( v1 As vec2, v2 As vec2 ) As vec2 Return type<vec2>( v1.x - v2.x, v1.y - v2.y)End OperatorOperator - ( v1 As vec3, v2 As vec3 ) As vec3 Return type<vec3>( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z )End Operator'MULTIPLYOperator * ( v1 As vec2, v2 As vec2 ) As vec2 Return type<vec2>( v1.x * v2.x, v1.y * v2.y)End OperatorOperator * ( v1 As vec3, v2 As vec3 ) As vec3 Return type<vec3>( v1.x * v2.x, v1.y * v2.y, v1.z * v2.z )End OperatorOperator * ( v1 As vec3, v2 As Single ) As vec3 Return type<vec3>( v1.x * v2, v1.y * v2, v1.z * v2 )End Operator'DIVIDEOperator / ( v1 As vec2, v2 As vec2 ) As vec2 Return type<vec2>( v1.x / v2.x, v1.y / v2.y)End OperatorOperator / ( v1 As vec3, v2 As vec3 ) As vec3 Return type<vec3>( v1.x / v2.x, v1.y / v2.y, v1.z / v2.z )End Operator'FUNCTIONS TO CREATE VECTORSFunction createVec2 (x As Single, y As Single) As vec2 Return type<vec2>( x, y )End FunctionFunction createVec3 (x As Single, y As Single, z As Single) As vec3 Return type<vec3>( x, y, z )End Function'HELPER FUNCTIONSFunction normalize(tv As vec3) As vec3 Dim As Single length Dim As vec3 v = tv length = Sqr(v.x * v.x + v.y * v.y + v.z * v.z) v.x /= length v.y /= length v.z /= length Return vEnd FunctionFunction dot(v1 As vec3, v2 As vec3) As Single return (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z)End FunctionFunction cross (v1 As vec3, v2 As vec3) As vec3 Dim As vec3 v v.x = (v1.y * v2.z) - (v2.y * v1.z) v.y = (v1.z * v2.x) - (v2.z * v1.x) v.z = (v1.x * v2.y) - (v2.x * v1.y) Return vEnd Function
line1line2line3

0 comments on commit 6be87bc

Please sign in to comment.