public Mat4f toMat() { Mat4f res = new Mat4f(); float wx, wy, wz, xx, yy, zz, yz, xy, xz, x2, y2, z2; x2 = this.i + this.i; y2 = this.j + this.j; z2 = this.k + this.k; xx = this.i * x2; xy = this.i * y2; xz = this.i * z2; yy = this.j * y2; yz = this.j * z2; zz = this.k * z2; wx = this.r * x2; wy = this.r * y2; wz = this.r * z2; res.data[0][0] = 1.0f - (yy + zz); res.data[0][1] = xy - wz; res.data[0][2] = xz + wy; res.data[0][3] = 0.0f; res.data[1][0] = xy + wz; res.data[1][1] = 1.0f - (xx + zz); res.data[1][2] = yz - wx; res.data[1][3] = 0.0f; res.data[2][0] = xz - wy; res.data[2][1] = yz + wx; res.data[2][2] = 1.0f - (xx + yy); res.data[2][3] = 0.0f; res.data[3][0] = 0.0f; res.data[3][1] = 0.0f; res.data[3][2] = 0.0f; res.data[3][3] = 1.0f; return(res); }
public static Mat4f operator +(Mat4f m1, Mat4f m2) { Mat4f res = new Mat4f(); res.data[0] = m1.data[0] + m2.data[0]; res.data[1] = m1.data[1] + m2.data[1]; res.data[2] = m1.data[2] + m2.data[2]; res.data[3] = m1.data[3] + m2.data[3]; return(res); }
public static Mat4f lookAtLH(Vec3f eye, Vec3f center, Vec3f up) { Vec3f f = (center - eye).normal(); Vec3f s = (f * up).normal(); Vec3f u = s * f; Mat4f Result = new Mat4f(); Result.data[0][0] = s.x; Result.data[1][0] = s.y; Result.data[2][0] = s.z; Result.data[0][1] = u.x; Result.data[1][1] = u.y; Result.data[2][1] = u.z; Result.data[0][2] = f.x; Result.data[1][2] = f.y; Result.data[2][2] = f.z; Result.data[3][0] = -(s.dot(eye)); Result.data[3][1] = -(u.dot(eye)); Result.data[3][2] = -(f.dot(eye)); return(Result); }
public void fromMat(Mat4f other) { }