Changeset 1608 for code/trunk/src/util
- Timestamp:
- Jun 17, 2008, 3:33:03 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/util/Math.cc
r1566 r1608 75 75 { 76 76 orxonox::Vector3 distance = otherposition - myposition; 77 return acos(mydirection.dotProduct(distance) / distance.length()); 77 float distancelength = distance.length(); 78 if (distancelength == 0) 79 return 0; 80 else 81 return acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)); 78 82 } 79 83 … … 84 88 // project difference vector on our plane 85 89 orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance); 86 float angle = acos(myorthonormal.dotProduct(projection) / projection.length()); 90 91 float projectionlength = projection.length(); 92 if (projectionlength == 0) return orxonox::Vector2(0, 0); 93 float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1)); 87 94 88 95 if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0) … … 98 105 // project difference vector on our plane 99 106 orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance); 100 float angle = acos(myorthonormal.dotProduct(projection) / projection.length()); 101 float radius = acos(mydirection.dotProduct(distance) / distance.length()) / Ogre::Math::PI; 107 108 float projectionlength = projection.length(); 109 if (projectionlength == 0) return orxonox::Vector2(0, 0); 110 float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1)); 111 112 float distancelength = distance.length(); 113 if (distancelength == 0) return orxonox::Vector2(0, 0); 114 float radius = acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)) / Ogre::Math::PI; 102 115 103 116 if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
Note: See TracChangeset
for help on using the changeset viewer.