Changeset 45:2a407d1589d4 in rrlib_geometry


Ignore:
Timestamp:
30.11.2012 10:41:21 (7 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Parents:
44:eb2f323a8d11 (diff), 35:3bb421b79a01 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merged with changes from rrlib.org

Location:
curves
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • curves/tBezierCurve.hpp

    r35 r45  
    294294  tSubdivision subdivision(this->GetSubdivision()); 
    295295 
    296   tLineSegment<Tdimension, TElement> first_segment_base_line(subdivision.first.ControlPoints()[0], subdivision.first.ControlPoints()[Tdegree]); 
    297   tLineSegment<Tdimension, TElement> second_segment_base_line(subdivision.second.ControlPoints()[0], subdivision.second.ControlPoints()[Tdegree]); 
    298  
    299   typename tShape::tPoint first_candidate = first_segment_base_line.GetClosestPoint(reference_point); 
    300   typename tShape::tPoint second_candidate = second_segment_base_line.GetClosestPoint(reference_point); 
    301  
    302   double squared_distance_to_first_candidate = (reference_point - first_candidate).SquaredLength(); 
    303   double squared_distance_to_second_candidate = (reference_point - second_candidate).SquaredLength(); 
     296  double squared_distance_to_first_candidate = std::numeric_limits<double>::max(); 
     297  double squared_distance_to_second_candidate = std::numeric_limits<double>::max(); 
     298 
     299  for (unsigned int i = 0; i < Tdegree; ++i) 
     300  { 
     301    tLineSegment<Tdimension, TElement> first_segment_base_line(subdivision.first.ControlPoints()[i], subdivision.first.ControlPoints()[i + 1]); 
     302    tLineSegment<Tdimension, TElement> second_segment_base_line(subdivision.second.ControlPoints()[i], subdivision.second.ControlPoints()[i + 1]); 
     303 
     304    typename tShape::tPoint first_candidate = first_segment_base_line.GetClosestPoint(reference_point); 
     305    typename tShape::tPoint second_candidate = second_segment_base_line.GetClosestPoint(reference_point); 
     306 
     307    double squared_distance_to_first = (reference_point - first_candidate).SquaredLength(); 
     308    double squared_distance_to_second = (reference_point - second_candidate).SquaredLength(); 
     309 
     310    if (squared_distance_to_first < squared_distance_to_first_candidate) 
     311    { 
     312      squared_distance_to_first_candidate = squared_distance_to_first; 
     313    } 
     314 
     315    if (squared_distance_to_second < squared_distance_to_second_candidate) 
     316    { 
     317      squared_distance_to_second_candidate = squared_distance_to_second; 
     318    } 
     319  } 
    304320 
    305321  if (squared_distance_to_first_candidate < squared_distance_to_second_candidate) 
     
    307323    if (subdivision.first.GetTwist() < 1E-6) 
    308324    { 
    309       return first_candidate; 
     325      tLineSegment<Tdimension, TElement> first_segment_base_line(subdivision.first.ControlPoints()[0], subdivision.first.ControlPoints()[Tdegree]); 
     326      return first_segment_base_line.GetClosestPoint(reference_point); 
    310327    } 
    311328    return subdivision.first.GetClosestPoint(reference_point); 
     
    314331  if (subdivision.second.GetTwist() < 1E-6) 
    315332  { 
    316     return second_candidate; 
     333    tLineSegment<Tdimension, TElement> second_segment_base_line(subdivision.second.ControlPoints()[0], subdivision.second.ControlPoints()[Tdegree]); 
     334    return second_segment_base_line.GetClosestPoint(reference_point); 
    317335  } 
    318336  return subdivision.second.GetClosestPoint(reference_point); 
  • curves/tBezierCurve.hpp

    r43 r45  
    385385    } 
    386386  } 
    387   assert(math::IsEqual(rotation.Determinant(), 0)); 
     387  assert(math::IsEqual(rotation.Determinant(), 1)); 
    388388#endif 
    389389 
  • curves/tSplineCurve.hpp

    r40 r45  
    307307    } 
    308308  } 
    309   assert(math::IsEqual(rotation.Determinant(), 0)); 
     309  assert(math::IsEqual(rotation.Determinant(), 1)); 
    310310#endif 
    311311 
Note: See TracChangeset for help on using the changeset viewer.