/lib/ode/ode_source/OPCODE/Ice/IceHPoint.cpp
C++ | 70 lines | 26 code | 9 blank | 35 comment | 0 complexity | 250794010d246a5ed9e7c071285689a5 MD5 | raw file
1/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2/** 3 * Contains code for homogeneous points. 4 * \file IceHPoint.cpp 5 * \author Pierre Terdiman 6 * \date April, 4, 2000 7 */ 8/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 9 10/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 11/** 12 * Homogeneous point. 13 * 14 * Use it: 15 * - for clipping in homogeneous space (standard way) 16 * - to differentiate between points (w=1) and vectors (w=0). 17 * - in some cases you can also use it instead of Point for padding reasons. 18 * 19 * \class HPoint 20 * \author Pierre Terdiman 21 * \version 1.0 22 * \warning No cross-product in 4D. 23 * \warning HPoint *= Matrix3x3 doesn't exist, the matrix is first casted to a 4x4 24 */ 25/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 27/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 28// Precompiled Header 29#include "Stdafx.h" 30 31using namespace IceMaths; 32 33/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 34// Point Mul = HPoint * Matrix3x3; 35/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 36Point HPoint::operator*(const Matrix3x3& mat) const 37{ 38 return Point( 39 x * mat.m[0][0] + y * mat.m[1][0] + z * mat.m[2][0], 40 x * mat.m[0][1] + y * mat.m[1][1] + z * mat.m[2][1], 41 x * mat.m[0][2] + y * mat.m[1][2] + z * mat.m[2][2] ); 42} 43 44/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 45// HPoint Mul = HPoint * Matrix4x4; 46/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 47HPoint HPoint::operator*(const Matrix4x4& mat) const 48{ 49 return HPoint( 50 x * mat.m[0][0] + y * mat.m[1][0] + z * mat.m[2][0] + w * mat.m[3][0], 51 x * mat.m[0][1] + y * mat.m[1][1] + z * mat.m[2][1] + w * mat.m[3][1], 52 x * mat.m[0][2] + y * mat.m[1][2] + z * mat.m[2][2] + w * mat.m[3][2], 53 x * mat.m[0][3] + y * mat.m[1][3] + z * mat.m[2][3] + w * mat.m[3][3]); 54} 55 56/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 57// HPoint *= Matrix4x4 58/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 59HPoint& HPoint::operator*=(const Matrix4x4& mat) 60{ 61 float xp = x * mat.m[0][0] + y * mat.m[1][0] + z * mat.m[2][0] + w * mat.m[3][0]; 62 float yp = x * mat.m[0][1] + y * mat.m[1][1] + z * mat.m[2][1] + w * mat.m[3][1]; 63 float zp = x * mat.m[0][2] + y * mat.m[1][2] + z * mat.m[2][2] + w * mat.m[3][2]; 64 float wp = x * mat.m[0][3] + y * mat.m[1][3] + z * mat.m[2][3] + w * mat.m[3][3]; 65 66 x = xp; y = yp; z = zp; w = wp; 67 68 return *this; 69} 70