JOML-CI / JOML

A Java math library for OpenGL rendering calculations
MIT License
729 stars 104 forks source link

[Question] I can't understand the result of Matrix-Matrix multiplication #260

Closed scaventz closed 4 years ago

scaventz commented 4 years ago
public class MatrixExample {
    public static void main(String[] args) {

        Matrix2f mat1 = new Matrix2f(1.0f, 2.0f, 3.0f, 4.0f);
        Matrix2f mat2 = new Matrix2f(5.0f, 6.0f, 7.0f, 8.0f);
        System.out.println(mat1.mul(mat2));
    }
}

I ran the code above, the result is

2.300E+1 3.100E+1 3.400E+1 4.600E+1

I thought the result should be: 19 22 43 50

How can I understand this? By the way , is there a tutorial about how to use JOML? thanks

httpdigest commented 4 years ago

When using the matrix constructor taking individual floats, make sure to look at the parameter names and their JavaDocs. Also make sure to read https://github.com/JOML-CI/JOML/wiki/Common-Pitfalls .