You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+62-28Lines changed: 62 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,29 +5,29 @@ A Scala library for vectors and matrix math.
5
5
6
6
## Project goals
7
7
8
-
The goal of VecMatLib is to provide easy-to-use and efficient linear algebra operations.
8
+
The goal of VecMatLib is to provide easy-to-use and efficient linear algebra operations, needed by any 3D application.
9
9
10
10
Vectors and matrices structures are written in Scala to make the best use possible of Scala's operator overloading.
11
11
All methods with symbolic names have an alias for better interoperability with java.
12
12
13
-
All operations in VecMatLib are designed to **not** modify the object on which the operation is invoked to respect the principles of purity and immutability of functional programming.
13
+
All operations in VecMatLib are designed to **not** modify the object on which the operation is invoked to respect the
14
+
principles of purity and immutability of functional programming.
14
15
15
16
## Vector math
16
17
17
-
The vector package offers 2-dimensional, 3-dimensional, and 4-dimensional vectors of type int, float, and double with all their basic operations.
18
-
All operations do not modify the vector on which the operation is performed.
18
+
The vector package offers 2-dimensional, 3-dimensional, and 4-dimensional vectors of type int, float, and double with
19
+
all their basic operations. All operations do not modify the vector on which the operation is performed.
19
20
20
21
Scala example:
21
-
22
-
```scala
22
+
```
23
23
var a = Vec3f(1.0f, 1.0f, 1.0f)
24
24
var b = Vec3f(0.5f, 0.5f, 0.5f)
25
25
26
26
// 'a' and 'b' will not change
27
27
val c = a + b
28
28
29
29
// Increase 'a' by 'b'
30
-
a = a + b
30
+
a = a + b // or a += b
31
31
32
32
// Other operations
33
33
val dotProduct = a dot b
@@ -36,8 +36,7 @@ val reflection = b.reflect(normal)
The matrix package offers 2x2, 3x3, and 4x4 matrices of type int, float, and double with all their basic operations as well as methods to build matrices out of basic transformations.
59
-
All operations do not modify the matrix on which the operation is performed.
57
+
The matrix package offers 2x2, 3x3, and 4x4 matrices of type Int, Float, and Double with all their basic operations as
58
+
well as methods to build matrices out of basic transformations. All operations do not modify the matrix on which the
59
+
operation is performed.
60
60
61
61
The following example shows how a translation matrix is created and how the transformation is applied.
@@ -89,7 +89,7 @@ var point = Vec4f(x, y, z, 1.0f)
89
89
point = transform * point
90
90
```
91
91
92
-
```java
92
+
```
93
93
Mat4f transform = Mat4f.translation(tx, ty, tz)
94
94
.multiply(Mat4f.rotation(rx, ry, rz))
95
95
.multiply(Mat4f.scaling(sx, sy, sz));
@@ -103,58 +103,92 @@ point = transform.multiply(point);
103
103
104
104
## Color math
105
105
106
-
VecMatLib also provides a structure to represent a color as four-dimensional or three-dimensional floating point tuples with values between 0.0 and 1.0.
107
-
Such representation of colors resembles the one used in the [OpenGL Shading Language](https://www.khronos.org/opengl/wiki/OpenGL_Shading_Language).
106
+
VecMatLib also provides a structure to represent a color as four-dimensional or three-dimensional floating point tuples
107
+
with values between 0.0 and 1.0. Such representation of colors resembles the one used in the
Initially a university project, later completed and turned into a fully usable library.
159
192
160
-
Your contributions are always welcome! Please submit a pull request or open an issue if you want to contribute with bug fixes, code improvements, documentation, and better unit test coverage.
193
+
Your contributions are always welcome! Please submit a pull request or open an issue if you want to contribute with bug
194
+
fixes, code improvements, documentation, and better unit test coverage.
0 commit comments