IceSegment.cpp
Go to the documentation of this file.
1 
8 
11 
21 
24 // Precompiled Header
25 #include "Stdafx.h"
26 
27 using namespace IceMaths;
28 
29 float Segment::SquareDistance(const Point& point, float* t) const
30 {
31  Point Diff = point - mP0;
32  Point Dir = mP1 - mP0;
33  float fT = Diff | Dir;
34 
35  if(fT<=0.0f)
36  {
37  fT = 0.0f;
38  }
39  else
40  {
41  float SqrLen= Dir.SquareMagnitude();
42  if(fT>=SqrLen)
43  {
44  fT = 1.0f;
45  Diff -= Dir;
46  }
47  else
48  {
49  fT /= SqrLen;
50  Diff -= fT*Dir;
51  }
52  }
53 
54  if(t) *t = fT;
55 
56  return Diff.SquareMagnitude();
57 }
float SquareDistance(const Point &point, float *t=null) const
Definition: IceSegment.cpp:29
inline_ float SquareMagnitude() const
Computes square magnitude.
Definition: OPC_IceHook.h:218


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:03