Brucey пре 5 година
родитељ
комит
fa112ce3cd
2 измењених фајлова са 55 додато и 4 уклоњено
  1. 53 2
      matrix.mod/matrix.bmx
  2. 2 2
      vector.mod/vector.bmx

+ 53 - 2
matrix.mod/matrix.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2019 Bruce A Henderson
+' Copyright (c) 2019-2020 Bruce A Henderson
 '
 '
 ' This software is provided 'as-is', without any express or implied
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
 ' warranty. In no event will the authors be held liable for any damages
@@ -29,7 +29,7 @@ Module BRL.Matrix
 ModuleInfo "Version: 1.00"
 ModuleInfo "Version: 1.00"
 ModuleInfo "Author: Bruce A Henderson"
 ModuleInfo "Author: Bruce A Henderson"
 ModuleInfo "License: zlib"
 ModuleInfo "License: zlib"
-ModuleInfo "Copyright: 2019 Bruce A Henderson"
+ModuleInfo "Copyright: 2019-2020 Bruce A Henderson"
 
 
 ModuleInfo "History: 1.00"
 ModuleInfo "History: 1.00"
 ModuleInfo "History: Initial Release"
 ModuleInfo "History: Initial Release"
@@ -221,6 +221,13 @@ Struct SMat3D
 		Return New SVec3D(v.x * a + v.y * d + v.z * g, v.x * b + v.y * e + v.z * h, v.x * c + v.y * f + v.z * i)
 		Return New SVec3D(v.x * a + v.y * d + v.z * g, v.x * b + v.y * e + v.z * h, v.x * c + v.y * f + v.z * i)
 	End Method
 	End Method
 
 
+	Rem
+	bbdoc: Applies the matrix to the vector @v, returning a new vector.
+	End Rem
+	Method Apply:SVec4D(v:SVec4D)
+		Return New SVec4D(v.x * a + v.y * d + v.z * g, v.x * b + v.y * e + v.z * h, v.x * c + v.y * f + v.z * i, 0)
+	End Method
+
 	Rem
 	Rem
 	bbdoc: Return the 3x3 identity matrix.
 	bbdoc: Return the 3x3 identity matrix.
 	End Rem
 	End Rem
@@ -472,6 +479,16 @@ Struct SMat4D
 			(c * v.x + g * v.y + k * v.z + o) * w)
 			(c * v.x + g * v.y + k * v.z + o) * w)
 	End Method
 	End Method
 
 
+	Rem
+	bbdoc: Applies the 4x4 matrix @b to the vector, returning a new vector.
+	End Rem
+	Method Apply:SVec4D(v:SVec4D)
+		Return New SVec4D(a * v.x + e * v.y + i * v.z + m * v.w, ..
+			b * v.x + f * v.y + j * v.z + n * v.w, ..
+			c * v.x + g * v.y + k * v.z + o * v.w, ..
+			d * v.x + h * v.y + l * v.z + p * v.w)
+	End Method
+
 	Rem
 	Rem
 	bbdoc: Returns the identity matrix.
 	bbdoc: Returns the identity matrix.
 	End Rem
 	End Rem
@@ -1074,6 +1091,13 @@ Struct SMat3F
 		Return New SVec3F(v.x * a + v.y * d + v.z * g, v.x * b + v.y * e + v.z * h, v.x * c + v.y * f + v.z * i)
 		Return New SVec3F(v.x * a + v.y * d + v.z * g, v.x * b + v.y * e + v.z * h, v.x * c + v.y * f + v.z * i)
 	End Method
 	End Method
 
 
+	Rem
+	bbdoc: Applies the matrix to the vector @v, returning a new vector.
+	End Rem
+	Method Apply:SVec4F(v:SVec4F)
+		Return New SVec4F(v.x * a + v.y * d + v.z * g, v.x * b + v.y * e + v.z * h, v.x * c + v.y * f + v.z * i, 0)
+	End Method
+
 	Rem
 	Rem
 	bbdoc: Return the 3x3 identity matrix.
 	bbdoc: Return the 3x3 identity matrix.
 	End Rem
 	End Rem
@@ -1341,6 +1365,16 @@ Struct SMat4F
 			(c * v.x + g * v.y + k * v.z + o) * w)
 			(c * v.x + g * v.y + k * v.z + o) * w)
 	End Method
 	End Method
 
 
+	Rem
+	bbdoc: Applies the 4x4 matrix @b to the vector, returning a new vector.
+	End Rem
+	Method Apply:SVec4F(v:SVec4F)
+		Return New SVec4F(a * v.x + e * v.y + i * v.z + m * v.w, ..
+			b * v.x + f * v.y + j * v.z + n * v.w, ..
+			c * v.x + g * v.y + k * v.z + o * v.w, ..
+			d * v.x + h * v.y + l * v.z + p * v.w)
+	End Method
+
 	Rem
 	Rem
 	bbdoc: Returns the identity matrix.
 	bbdoc: Returns the identity matrix.
 	End Rem
 	End Rem
@@ -1987,6 +2021,13 @@ Struct SMat3I
 		Return New SVec3I(v.x * a + v.y * d + v.z * g, v.x * b + v.y * e + v.z * h, v.x * c + v.y * f + v.z * i)
 		Return New SVec3I(v.x * a + v.y * d + v.z * g, v.x * b + v.y * e + v.z * h, v.x * c + v.y * f + v.z * i)
 	End Method
 	End Method
 
 
+	Rem
+	bbdoc: Applies the matrix to the vector @v, returning a new vector.
+	End Rem
+	Method Apply:SVec4I(v:SVec4I)
+		Return New SVec4I(v.x * a + v.y * d + v.z * g, v.x * b + v.y * e + v.z * h, v.x * c + v.y * f + v.z * i, 0)
+	End Method
+
 	Rem
 	Rem
 	bbdoc: Return the 3x3 identity matrix.
 	bbdoc: Return the 3x3 identity matrix.
 	End Rem
 	End Rem
@@ -2270,6 +2311,16 @@ Struct SMat4I
 			Int((c * v.x + g * v.y + k * v.z + o) * w))
 			Int((c * v.x + g * v.y + k * v.z + o) * w))
 	End Method
 	End Method
 
 
+	Rem
+	bbdoc: Applies the 4x4 matrix @b to the vector, returning a new vector.
+	End Rem
+	Method Apply:SVec4I(v:SVec4I)
+		Return New SVec4I(a * v.x + e * v.y + i * v.z + m * v.w, ..
+			b * v.x + f * v.y + j * v.z + n * v.w, ..
+			c * v.x + g * v.y + k * v.z + o * v.w, ..
+			d * v.x + h * v.y + l * v.z + p * v.w)
+	End Method
+
 	Rem
 	Rem
 	bbdoc: Returns the identity matrix.
 	bbdoc: Returns the identity matrix.
 	End Rem
 	End Rem

+ 2 - 2
vector.mod/vector.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2019 Bruce A Henderson
+' Copyright (c) 2019-2020 Bruce A Henderson
 '
 '
 ' This software is provided 'as-is', without any express or implied
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
 ' warranty. In no event will the authors be held liable for any damages
@@ -29,7 +29,7 @@ Module BRL.Vector
 ModuleInfo "Version: 1.00"
 ModuleInfo "Version: 1.00"
 ModuleInfo "Author: Bruce A Henderson"
 ModuleInfo "Author: Bruce A Henderson"
 ModuleInfo "License: zlib"
 ModuleInfo "License: zlib"
-ModuleInfo "Copyright: 2019 Bruce A Henderson"
+ModuleInfo "Copyright: 2019-2020 Bruce A Henderson"
 
 
 ModuleInfo "History: 1.00"
 ModuleInfo "History: 1.00"
 ModuleInfo "History: Initial Release"
 ModuleInfo "History: Initial Release"