Changeset 9779 for code/branches/radarDreiD/src
- Timestamp:
- Nov 11, 2013, 4:13:02 PM (11 years ago)
- Location:
- code/branches/radarDreiD/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/radarDreiD/src/libraries/util/Math.cc
r9770 r9779 207 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) 208 208 { 209 // 209 // Orxonox Vectors: x_direction you are looking, y_direction points up, z_direction points to the right 210 210 orxonox::Vector3 distance = otherposition - myposition; 211 211 212 // new coordinate system base y_coordinate 213 orxonox::Vector3 myside = -(mydirection.crossProduct(myorthonormal)); 212 // new coordinate system: x_axsis: mydirection (points front) 213 // y_axsis: myorthonormal (points up) 214 // z_axsis: myside (points right) 215 orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal); 216 orxout() << "mydirection " << mydirection << endl; 217 orxout() << "mydirection.lenght " << mydirection.length() << endl; 218 orxout() << "myorthonormal " << myorthonormal << endl; 219 orxout() << "myorthonormal.lenght " << myorthonormal.length() << endl; 220 orxout() << "myside " << myside << endl; 221 orxout() << "myside.lenght " << myside.length() << endl; 222 223 distance = 5 * distance / detectionlimit; // shrink vector on map 214 224 215 225 // inverse of the transform matrix 216 float determinant = +mydirection.x * (my side.y*myorthonormal.z - myorthonormal.y*myside.z)217 -mydirection.y * (my side.x*myorthonormal.z - myside.z*myorthonormal.x)218 +mydirection.z * (my side.x*myorthonormal.y - myside.y*myorthonormal.x);226 float determinant = +mydirection.x * (myorthonormal.y*myside.z - myside.y*myorthonormal.z) 227 -mydirection.y * (myorthonormal.x*myside.z - myorthonormal.z*myside.x) 228 +mydirection.z * (myorthonormal.x*myside.y - myorthonormal.y*myside.x); 219 229 float invdet = 1/determinant; 220 230 … … 224 234 orxonox::Vector3 zinvtransform; 225 235 226 xinvtransform.x = (my side.y * myorthonormal.z - myorthonormal.y * myside.z)*invdet;227 xinvtransform.y = (mydirection.z * my orthonormal.y - mydirection.y * myorthonormal.z)*invdet;228 xinvtransform.z = (mydirection.y * my side.z - mydirection.z * myside.y)*invdet;229 yinvtransform.x = (my side.z * myorthonormal.x - myside.x * myorthonormal.z)*invdet;230 yinvtransform.y = (mydirection.x * my orthonormal.z - mydirection.z * myorthonormal.x)*invdet;231 yinvtransform.z = (my side.x * mydirection.z - mydirection.x * myside.z)*invdet;232 zinvtransform.x = (my side.x * myorthonormal.y - myorthonormal.x * myside.y)*invdet;233 zinvtransform.y = (my orthonormal.x * mydirection.y - mydirection.x * myorthonormal.y)*invdet;234 zinvtransform.z = (mydirection.x * my side.y - myside.x* mydirection.y )*invdet;236 xinvtransform.x = (myorthonormal.y * myside.z - myside.y * myorthonormal.z)*invdet; 237 xinvtransform.y = (mydirection.z * myside.y - mydirection.y * myside.z )*invdet; 238 xinvtransform.z = (mydirection.y * myorthonormal.z - mydirection.z * myorthonormal.y)*invdet; 239 yinvtransform.x = (myorthonormal.z * myside.x - myorthonormal.x * myside.z )*invdet; 240 yinvtransform.y = (mydirection.x * myside.z - mydirection.z * myside.x )*invdet; 241 yinvtransform.z = (myorthonormal.x * mydirection.z - mydirection.x * myorthonormal.z)*invdet; 242 zinvtransform.x = (myorthonormal.x * myside.y - myside.x * myorthonormal.y)*invdet; 243 zinvtransform.y = (myside.x * mydirection.y - mydirection.x * myside.y )*invdet; 244 zinvtransform.z = (mydirection.x * myorthonormal.y - myorthonormal.x * mydirection.y )*invdet; 235 245 236 246 // coordinate transformation 237 distance.x = (xinvtransform.x + yinvtransform.x + zinvtransform.x) * distance.x;238 distance.y = (xinvtransform.y + yinvtransform.y + zinvtransform.y) * distance.y;239 distance.z = (xinvtransform.z + yinvtransform.z + zinvtransform.z)* distance.z;247 distance.x = xinvtransform.x * distance.x + yinvtransform.x * distance.y + zinvtransform.x * distance.z; 248 distance.y = xinvtransform.y * distance.x + yinvtransform.y * distance.y + zinvtransform.y * distance.z; 249 distance.z = xinvtransform.z * distance.x + yinvtransform.z * distance.y + zinvtransform.z * distance.z; 240 250 241 251 // cap vector for map … … 244 254 //distance.z = clamp<float>(distance.z, -detectionlimit/5, detectionlimit/5); 245 255 //float distancelength = distance.length(); 246 distance = 5 * distance / detectionlimit; 256 247 257 248 258 // project vector for the rotated 3DMap on screen 249 float xcoordinate = distance.z; // z; cause z direction is to the side 250 float ycoordinate = (distance.x*sin(mapangle)+distance.y*cos(mapangle)); 259 float xcoordinate = distance.z; 260 float ycoordinate = distance.y; 261 262 //float xcoordinate = distance.z; // z; cause z direction is to the side 263 //float ycoordinate = distance.x*sin(mapangle)+distance.y*cos(mapangle);// -; cause on screen y coordinate points down 251 264 return orxonox::Vector2(xcoordinate , ycoordinate); 252 265 } -
code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.cc
r9742 r9779 173 173 coord *= math::pi / 3.5f; // small adjustment to make it fit the texture 174 174 it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f); 175 175 176 if( distance < detectionLimit_ || detectionLimit_ < 0 ) 176 177 it->second->show();
Note: See TracChangeset
for help on using the changeset viewer.