6 Vector2::Vector2(const Vector3 &v)
13 Vector3::Vector3(const Vector4 &v)
14 : x(v.x), y(v.y), z(v.z)
18 Vector3 operator *(const Vector3 &v, const Matrix4x4 &m)
20 float x = v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0];
21 float y = v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1];
22 float z = v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2];
23 return Vector3(x, y, z);
26 Vector3 operator *(const Matrix4x4 &m, const Vector3 &v)
28 float x = m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3];
29 float y = m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3];
30 float z = m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3];
31 return Vector3(x, y, z);
36 Vector4::Vector4(const Vector3 &v)
37 : x(v.x), y(v.y), z(v.z), w(1.0f)
41 Vector4 operator *(const Vector4 &v, const Matrix4x4 &m)
43 float x = v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + v.w * m[3][0];
44 float y = v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + v.w * m[3][1];
45 float z = v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + v.w * m[3][2];
46 float w = v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + v.w * m[3][3];
47 return Vector4(x, y, z, w);
50 Vector4 operator *(const Matrix4x4 &m, const Vector4 &v)
52 float x = m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w;
53 float y = m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] * v.w;
54 float z = m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3] * v.w;
55 float w = m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3] * v.w;
56 return Vector4(x, y, z, w);