示例#1
0
vec3_t projectPointOnEdge(const vec3_t& M,const vec3_t& A, const vec3_t& u)
{
  checkVector(u);
  if(u.abs2()==0) EG_BUG;
  double k = ((M-A)*u)/u.abs2();
  return A + k*u;
}
示例#2
0
vec2_t projectVectorOnPlane(vec3_t V,vec3_t i,vec3_t j)
{
  if(i.abs2()==0) EG_BUG;
  if(j.abs2()==0) EG_BUG;
  double x = V*i/i.abs2();
  double y = V*j/j.abs2();
  return vec2_t(x,y);
}
示例#3
0
double angle(const vec3_t & u, const vec3_t & v)
{
  // return the angle w.r.t. another 3-vector
  double ptot2 = u.abs2()*v.abs2();
  if(ptot2 <= 0) {
      return 0.0;
  } else {
    double arg = (u*v)/sqrt(ptot2);
    if(arg >  1.0) arg =  1.0;
    if(arg < -1.0) arg = -1.0;
    return acos(arg);
  }
}
示例#4
0
vec3_t projectPointOnPlane(const vec3_t& M, const vec3_t& A, const vec3_t& N)
{
  double k = ((M-A)*N)/N.abs2();
  return( M - k*N );
}