- Timestamp:
- Aug 20, 2014, 1:07:11 PM (11 years ago)
- Children:
- 7e45c4
- Parents:
- e94448
- git-author:
- Frederik Heber <heber@…> (07/21/14 08:17:42)
- git-committer:
- Frederik Heber <heber@…> (08/20/14 13:07:11)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/SphericalPointDistribution.cpp
re94448 r39616b 321 321 */ 322 322 inline 323 Vector calculateCenterOfGravity( 324 const SphericalPointDistribution::VectorArray_t &_positions, 325 const SphericalPointDistribution::IndexList_t &_indices) 326 { 327 Vector Center; 328 Center.Zero(); 329 for (SphericalPointDistribution::IndexList_t::const_iterator iter = _indices.begin(); 330 iter != _indices.end(); ++iter) 331 Center += _positions[*iter]; 332 if (!_indices.empty()) 333 Center *= 1./(double)_indices.size(); 334 335 return Center; 336 } 337 338 /** Calculate the center of a given set of points in \a _positions but only 339 * for those indicated by \a _indices. 340 * 341 */ 342 inline 323 343 Vector calculateCenter( 324 344 const SphericalPointDistribution::VectorArray_t &_positions, … … 838 858 remainingold, remainingnew); 839 859 840 Vector oldPosition = remainingnew.polygon[*remainingnew.indices.begin()]; 841 Vector newPosition = remainingold.polygon[0]; 842 LOG(6, "DEBUG: oldPosition is " << oldPosition << " (length: " 843 << oldPosition.Norm() << ") and newPosition is " << newPosition << " length(: " 844 << newPosition.Norm() << ")"); 845 846 if (!oldPosition.IsEqualTo(newPosition)) { 847 // we rotate at oldCenter and around the radial direction, which is again given 848 // by oldCenter. 849 Rotation.first = oldCenter; 850 Rotation.first.Normalize(); // note weighted sum of normalized weight is not normalized 851 LOG(6, "DEBUG: Using oldCenter " << oldCenter << " as rotation center and " 852 << Rotation.first << " as axis."); 853 oldPosition -= oldCenter; 854 newPosition -= oldCenter; 855 oldPosition = (oldPosition - oldPosition.Projection(Rotation.first)); 856 newPosition = (newPosition - newPosition.Projection(Rotation.first)); 857 LOG(6, "DEBUG: Positions after projection are " << oldPosition << " and " << newPosition); 858 859 // construct reference vector to determine direction of rotation 860 const double sign = determineSignOfRotation(oldPosition, newPosition, Rotation.first); 861 Rotation.second = sign * oldPosition.Angle(newPosition); 862 } else { 863 LOG(6, "DEBUG: oldPosition and newPosition are equivalent, hence no orientating rotation."); 864 } 860 // we rotate at oldCenter and around the radial direction, which is again given 861 // by oldCenter. 862 Rotation.first = oldCenter; 863 Rotation.first.Normalize(); // note weighted sum of normalized weight is not normalized 864 865 // calculate center of the rotational plane 866 newCenter = calculateCenterOfGravity(remainingnew.polygon, remainingnew.indices); 867 oldCenter = calculateCenterOfGravity(remainingold.polygon, remainingold.indices); 868 LOG(6, "DEBUG: Using oldCenter " << oldCenter << " as rotation center and " 869 << Rotation.first << " as axis."); 870 871 LOG(6, "DEBUG: old indices are " << remainingold.indices 872 << ", new indices are " << remainingnew.indices); 873 IndexList_t::const_iterator newiter = remainingnew.indices.begin(); 874 IndexList_t::const_iterator olditer = remainingold.indices.begin(); 875 for (; 876 (newiter != remainingnew.indices.end()) && (olditer != remainingold.indices.end()); 877 ++newiter,++olditer) { 878 Vector newPosition = remainingnew.polygon[*newiter]; 879 Vector oldPosition = remainingold.polygon[*olditer]; 880 LOG(6, "DEBUG: oldPosition is " << oldPosition << " (length: " 881 << oldPosition.Norm() << ") and newPosition is " << newPosition << " length(: " 882 << newPosition.Norm() << ")"); 883 884 if (!oldPosition.IsEqualTo(newPosition)) { 885 oldPosition -= oldCenter; 886 newPosition -= newCenter; 887 oldPosition = (oldPosition - oldPosition.Projection(Rotation.first)); 888 newPosition = (newPosition - newPosition.Projection(Rotation.first)); 889 LOG(6, "DEBUG: Positions after projection are " << oldPosition << " and " << newPosition); 890 891 // construct reference vector to determine direction of rotation 892 const double sign = determineSignOfRotation(newPosition, oldPosition, Rotation.first); 893 LOG(6, "DEBUG: Determining angle between " << oldPosition << " and " << newPosition); 894 const double angle = sign * newPosition.Angle(oldPosition); 895 LOG(6, "DEBUG: Adding " << angle << " to weighted rotation sum."); 896 Rotation.second += angle; 897 } else { 898 LOG(6, "DEBUG: oldPosition and newPosition are equivalent, hence no orientating rotation."); 899 } 900 } 901 Rotation.second *= 1./(double)remainingnew.indices.size(); 865 902 866 903 return Rotation; … … 1062 1099 << " while old was " << oldSet.polygon[0]); 1063 1100 const double difference = (rotatednew - oldSet.polygon[0]).NormSquared(); 1064 ASSERT( difference < distance+ 1e-8,1101 ASSERT( difference < distance+warn_amplitude, 1065 1102 "matchSphericalPointDistributions() - orientation rotation ends up off by " 1066 1103 +toString(difference)+", more than " 1067 +toString(distance+ 1e-8)+".");1104 +toString(distance+warn_amplitude)+"."); 1068 1105 } 1069 1106 #endif … … 1232 1269 << " while old was " << oldSet.polygon[0]); 1233 1270 const double difference = (rotatednew - oldSet.polygon[0]).NormSquared(); 1234 ASSERT( difference < distance+ 1e-8,1271 ASSERT( difference < distance+warn_amplitude, 1235 1272 "matchSphericalPointDistributions() - orientation rotation ends up off by " 1236 1273 +toString(difference)+", more than " 1237 +toString(distance+ 1e-8)+".");1274 +toString(distance+warn_amplitude)+"."); 1238 1275 } 1239 1276 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
