nuclear@4: #include "vector.h" nuclear@4: #include "matrix.h" nuclear@3: nuclear@3: namespace gph { nuclear@3: nuclear@5: Vector2::Vector2(const Vector3 &v) nuclear@5: : x(v.x), y(v.y) nuclear@5: { nuclear@5: } nuclear@5: nuclear@3: Vector3::Vector3(const Vector4 &v) nuclear@3: : x(v.x), y(v.y), z(v.z) nuclear@3: { nuclear@3: } nuclear@3: nuclear@4: Vector3 operator *(const Vector3 &v, const Matrix4x4 &m) nuclear@4: { nuclear@4: float x = v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0]; nuclear@4: float y = v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1]; nuclear@4: float z = v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]; nuclear@4: return Vector3(x, y, z); nuclear@4: } nuclear@4: nuclear@4: Vector3 operator *(const Matrix4x4 &m, const Vector3 &v) nuclear@4: { nuclear@4: float x = m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3]; nuclear@4: float y = m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3]; nuclear@4: float z = m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3]; nuclear@4: return Vector3(x, y, z); nuclear@4: } nuclear@4: nuclear@3: Vector4::Vector4(const Vector3 &v) nuclear@3: : x(v.x), y(v.y), z(v.z), w(1.0f) nuclear@3: { nuclear@3: } nuclear@3: nuclear@3: } // namespace gph