Implement Matrix4x4::RandomGeneral()
This commit is contained in:
@@ -557,10 +557,10 @@ namespace J3ML::LinearAlgebra {
|
||||
// See http://www.songho.ca/opengl/gl_projectionmatrix.html , unlike in Direct3D, where the
|
||||
// Z coordinate ranges in [0, 1]. This is the only difference between D3DPerspProjRH and OpenGLPerspProjRH.
|
||||
using f32 = float;
|
||||
float p00 = 2.f *n / h; float p01 = 0; float p02 = 0; float p03 = 0.f;
|
||||
float p10 = 0; float p11 = 2.f * n / v; float p12 = 0; float p13 = 0.f;
|
||||
float p20 = 0; float p21 = 0; float p22 = (n+f) / (n-f); float p23 = 2.f*n*f / (n-f);
|
||||
float p30 = 0; float p31 = 0; float p32 = -1.f; float p33 = 0.f;
|
||||
f32 p00 = 2.f *n / h; f32 p01 = 0; f32 p02 = 0; f32 p03 = 0.f;
|
||||
f32 p10 = 0; f32 p11 = 2.f * n / v; f32 p12 = 0; f32 p13 = 0.f;
|
||||
f32 p20 = 0; f32 p21 = 0; f32 p22 = (n+f) / (n-f); f32 p23 = 2.f*n*f / (n-f);
|
||||
f32 p30 = 0; f32 p31 = 0; f32 p32 = -1.f; f32 p33 = 0.f;
|
||||
|
||||
return {p00, p01, p02, p03, p10, p11, p12, p13, p20, p21, p22, p23, p30, p31, p32, p33};
|
||||
}
|
||||
@@ -1038,5 +1038,16 @@ namespace J3ML::LinearAlgebra {
|
||||
0.f, 0.f, 0.f, 1.f);
|
||||
}
|
||||
|
||||
Matrix4x4 Matrix4x4::RandomGeneral(RNG &rng, float minElem, float maxElem) {
|
||||
assert(std::isfinite(minElem));
|
||||
assert(std::isfinite(maxElem));
|
||||
|
||||
Matrix4x4 m;
|
||||
for (int y = 0; y < 4; ++y)
|
||||
for (int x = 0; x < 4; ++x)
|
||||
m[y][x] = rng.Float(minElem, maxElem);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user