Changeset 9740 for code/branches/radarDreiD/src/libraries
- Timestamp:
- Nov 4, 2013, 3:17:32 PM (11 years ago)
- Location:
- code/branches/radarDreiD/src/libraries/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/radarDreiD/src/libraries/util/Math.cc
r9719 r9740 196 196 @param myposition My position 197 197 @param mydirection My viewing direction 198 @param myorthonormal My orthonormalvector (pointing upwards through my head) 198 199 @param otherposition The position of the other object 199 200 @param mapangle The angle you look on the 3Dmap … … 204 205 - 205 206 */ 206 orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit)207 orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit) 207 208 { 208 209 // 209 210 orxonox::Vector3 distance = otherposition - myposition; 210 211 211 // project difference vector on our plane 212 orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance); 213 214 //float projectionlength = projection.length(); 215 216 // project vector for the rotated 3DMap 217 float xcoordinate = projection.y/(2*detectionlimit); 218 float ycoordinate = (projection.x*sin(mapangle)+projection.z*cos(mapangle))/(2*detectionlimit); 212 // new coordinate system base y_coordinate 213 orxonox::Vector3 myside = -mydirection.crossProduct(myorthonormal); 214 215 // inverse of the transform matrix 216 float determinant = +mydirection.x * (myside.y*myorthonormal.z - myorthonormal.y*myside.z) 217 -mydirection.y * (myside.x*myorthonormal.z - myside.z*myorthonormal.x) 218 +mydirection.z * (myside.x*myorthonormal.y - myside.y*myorthonormal.x); 219 float invdet = 1/determinant; 220 orxonox::Vector3 xinvtransform; 221 orxonox::Vector3 yinvtransform; 222 orxonox::Vector3 zinvtransform; 223 224 xinvtransform.x = (myside.y * myorthonormal.z - myorthonormal.y * myside.z )*invdet; 225 xinvtransform.y = -(mydirection.y * myorthonormal.z - mydirection.z * myorthonormal.y)*invdet; 226 xinvtransform.z = (mydirection.y * myside.z - mydirection.z * myside.y )*invdet; 227 yinvtransform.x = -(myside.x * myorthonormal.z - myside.z * myorthonormal.x)*invdet; 228 yinvtransform.y = (mydirection.x * myorthonormal.z - mydirection.z * myorthonormal.x)*invdet; 229 yinvtransform.z = -(mydirection.x * myside.z - myside.x * mydirection.z )*invdet; 230 zinvtransform.x = (myside.x * myorthonormal.y - myorthonormal.x * myside.y )*invdet; 231 zinvtransform.y = -(mydirection.x * myorthonormal.y - myorthonormal.x * mydirection.y )*invdet; 232 zinvtransform.z = (mydirection.x * myside.y - myside.x * mydirection.x )*invdet; 233 234 // coordinate transformation 235 distance.x = (xinvtransform.x + yinvtransform.x + zinvtransform.x) * distance.x; 236 distance.y = (xinvtransform.y + yinvtransform.y + zinvtransform.y) * distance.y; 237 distance.z = (xinvtransform.z + yinvtransform.z + zinvtransform.z) * distance.z; 238 239 // project vector for the rotated 3DMap on screen 240 float xcoordinate = distance.y/(2*detectionlimit); 241 float ycoordinate = (distance.x*sin(mapangle)+distance.z*cos(mapangle))/(2*detectionlimit); 219 242 return orxonox::Vector2(xcoordinate , ycoordinate); 220 243 } -
code/branches/radarDreiD/src/libraries/util/Math.h
r9719 r9740 92 92 _UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition); 93 93 _UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition); 94 _UtilExport orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit);94 _UtilExport orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit); 95 95 _UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity); 96 96
Note: See TracChangeset
for help on using the changeset viewer.