• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Vect2类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Vect2的典型用法代码示例。如果您正苦于以下问题:C++ Vect2类的具体用法?C++ Vect2怎么用?C++ Vect2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Vect2类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: horizontal_WCV_interval

LossData WCV_TAUMOD::horizontal_WCV_interval(double T, const Vect2& s, const Vect2& v) const {
  double time_in = T;
  double time_out = 0;
  double sqs = s.sqv();
  double sdotv = s.dot(v);
  double sqD = Util::sq(table.getDTHR());
  double a = v.sqv();
  double b = 2*sdotv+table.getTTHR()*v.sqv();
  double c = sqs+table.getTTHR()*sdotv-sqD;
  if (Util::almost_equals(a,0) && sqs <= sqD) { // [CAM] Changed from == to almost_equals to mitigate numerical problems
    time_in = 0;
    time_out = T;
    return LossData(time_in,time_out);
  }
  if (sqs <= sqD) {
    time_in = 0;
    time_out = std::min(T,Horizontal::Theta_D(s,v,1,table.getDTHR()));
    return LossData(time_in,time_out);
  }
  double discr = Util::sq(b)-4*a*c;
  if (sdotv >= 0 || discr < 0)
    return LossData(time_in,time_out);
  double t = (-b - std::sqrt(discr))/(2*a);
  if (Horizontal::Delta(s, v,table.getDTHR()) >= 0 && t <= T) {
    time_in = std::max(0.0,t);
    time_out = std::min(T, Horizontal::Theta_D(s,v,1,table.getDTHR()));
  }
  return LossData(time_in,time_out);
}
开发者ID:,项目名称:,代码行数:29,代码来源:


示例2: return

// Compute modified tau
double TCAS2D::tau_mod(double DMOD, const Vect2& s, const Vect2& v) {
  double sdotv = s.dot(v);

  if (Util::almost_equals(sdotv,0)) // [CAM] Changed from == to almost_equals to mitigate numerical problems
    return 0;
  return (Util::sq(DMOD)-s.sqv())/sdotv;
}
开发者ID:,项目名称:,代码行数:8,代码来源:


示例3: horizontal_WCV_interval

LossData WCV_TEP::horizontal_WCV_interval(double T, const Vect2& s, const Vect2& v) const {
  double time_in = T;
  double time_out = 0;
  double sqs = s.sqv();
  double sqv = v.sqv();
  double sdotv = s.dot(v);
  double sqD = Util::sq(table.getDTHR());
  if (Util::almost_equals(sqv,0) && sqs <= sqD) { // [CAM] Changed from == to almost_equals to mitigate numerical problems
    time_in = 0;
    time_out = T;
    return LossData(time_in,time_out);
  }
  if (Util::almost_equals(sqv,0)) // [CAM] Changed from == to almost_equals to mitigate numerical problems
    return LossData(time_in,time_out);
  if (sqs <= sqD) {
    time_in = 0;
    time_out = Util::min(T,Horizontal::Theta_D(s,v,1,table.getDTHR()));
    return LossData(time_in,time_out);
  }
  if (sdotv > 0 || Horizontal::Delta(s,v,table.getDTHR()) < 0)
    return LossData(time_in,time_out);
  double tep = Horizontal::Theta_D(s,v,-1,table.getDTHR());
  if (tep-table.getTTHR() > T)
    return LossData(time_in,time_out);
  time_in = Util::max(0.0,tep-table.getTTHR());
  time_out = Util::min(T,Horizontal::Theta_D(s,v,1,table.getDTHR()));
  return LossData(time_in,time_out);
}
开发者ID:nasa,项目名称:WellClear,代码行数:28,代码来源:WCV_TEP.cpp


示例4: sphere_to_plane

 Vect2 AziEquiProjection::project2(const LatLonAlt& lla) const {
   Vect2 p =  sphere_to_plane(ref, spherical2xyz(lla.lat(),lla.lon()));
   if (p.norm() <= 0.0) {
 	  return Vect2::ZERO;
   } else {
       return p.Scal(GreatCircle::distance(lla, llaRef)/p.norm());
   }
 }
开发者ID:E-LLP,项目名称:WellClear,代码行数:8,代码来源:AziEquiProjection.cpp


示例5: horizontal_tvar

double WCV_TEP::horizontal_tvar(const Vect2& s, const Vect2& v) const {
  // Time variable is Modified Tau
  double TEP = -1;
  double sdotv = s.dot(v);
  if (sdotv < 0)
    return (Util::sq(table.getDTHR())-s.sqv())/sdotv;
  return TEP;
}
开发者ID:nasa,项目名称:WellClear,代码行数:8,代码来源:WCV_TEP.cpp


示例6: closestPoint

Vect2 VectFuns::closestPoint(const Vect2& a, const Vect2& b, const Vect2& so) {
	// translate a to origin, then project so onto the line defined by ab, then translate back to a
	Vect2 ab = b.Sub(a);
	return ab.Scal(so.Sub(a).dot(ab)/ab.dot(ab)).Add(a);
//	if (collinear(a,b,so)) return so;
//	Vect2 v = a.Sub(b).PerpL().Hat(); // perpendicular vector to line
//	Vect2 s2 = so.AddScal(100, v);
//	Vect2 cp = intersection(so,s2,100,a,b).first;
//	return cp;
}
开发者ID:nasa,项目名称:WellClear,代码行数:10,代码来源:VectFuns.cpp


示例7: nominal_tau

double TCAS2D::time_of_min_tau(double DMOD, double B, double T, const Vect2& s, const Vect2& v) {
  if (v.ScalAdd(B,s).dot(v) >= 0)
    return B;
  double d = Horizontal::Delta(s,v,DMOD);
  double rr = 0;
  if (d < 0)
    rr = 2*std::sqrt(-d) / v.sqv();
  if (v.ScalAdd(T,s).dot(v) < 0)
    return T;
  return nominal_tau(B,T,s,v,rr);
}
开发者ID:,项目名称:,代码行数:11,代码来源:


示例8:

/**
 * Return actual time of closest point approach (return negative infinity if parallel)
 */
double Vect2::actual_tcpa (const Vect2& so, const Vect2& vo, const Vect2& si,  const Vect2& vi){
	double rtn;
	Vect2 s = so - si;
	Vect2 v = vo - vi;
	double nv = v.norm();
	if (nv > 0) {
		rtn = -s.dot(v)/(nv*nv);
	} else {
		rtn = NINFINITY;;
	}
	return rtn;
}
开发者ID:,项目名称:,代码行数:15,代码来源:


示例9: LineCheckForBoxOnIsle2

bool LineCheckForBoxOnIsle2(const Vect2 &minVal, const Vect2 &maxVal, const Vect2 &v1, const Vect2 &v2)
{
    float tMax = M_INFINITE;
    float tMin = -M_INFINITE;

    Vect2 rayVect = v2-v1;
    float rayLength = rayVect.Len();
    Vect2 rayDir = rayVect*(1.0f/rayLength);

    Vect2 center = ((maxVal-minVal)*0.5f)+minVal;
    Vect2 E = maxVal - center;
    Vect2 T = center-v1;

    for(int i=0; i<2; i++)
    {
        float e = T.ptr[i];
        float f = rayDir.ptr[i];
        float fI = 1.0f/f;

        if(fabs(f) > 0.0f)
        {
            float t1 = (e+E.ptr[i])*fI;
            float t2 = (e-E.ptr[i])*fI;
            if(t1 > t2)
            {
                if(t2 > tMin) tMin = t2;
                if(t1 < tMax) tMax = t1;
            }
            else
            {
                if(t1 > tMin) tMin = t1;
                if(t2 < tMax) tMax = t2;
            }
            if(tMin > tMax) return false;
            if(tMax < 0.0f) return false;
        }
        else if( ((-e - E.ptr[i]) > 0.0f) ||
                 ((-e + E.ptr[i]) < 0.0f) )
        {
            return FALSE;
        }

        if(tMin > rayLength) return false;
    }

    return true; 
};
开发者ID:alanzw,项目名称:JimEngine,代码行数:47,代码来源:LightmapUVs.cpp


示例10: horizontal_WCV

bool WCV_tvar::horizontal_WCV(const Vect2& s, const Vect2& v) const {
  if (s.norm() <= table.getDTHR()) return true;
  if (Horizontal::dcpa(s,v) <= table.getDTHR()) {
    double tvar = horizontal_tvar(s,v);
    return 0  <= tvar && tvar <= table.getTTHR();
  }
  return false;
}
开发者ID:,项目名称:,代码行数:8,代码来源:


示例11: InitTangentLineY

double InitTangentLineY (const Vect2& s, const double D, const int eps) {
//  double x;
  double y;
  double sq_s  = s.sqv();
  double sq_D  = sq(D);
  if (Util::almost_equals(sq_s,sq_D))  {
//    x = eps*s.y;
    y = -eps*s.x;
  } else {
    Vect2 q = TangentLine::Q(s,D,eps);
//    x = q.x;
    y = q.y;
    if (!q.isZero()) {
//      x -= s.x;
      y -= s.y;
    }
  }
  return y;
}
开发者ID:E-LLP,项目名称:WellClear,代码行数:19,代码来源:TangentLine.cpp


示例12:

std::pair<Vect2,double> VectFuns::intersection(const Vect2& so, const Vect2& vo, const Vect2& si, const Vect2& vi) {
	Vect2 ds = si.Sub(so);
	if (vo.det(vi) == 0) {
		//f.pln(" $$$ intersection: lines are parallel");
		return std::pair<Vect2,double>(Vect2::ZERO(),  NaN);
	}
	double tt = ds.det(vi)/vo.det(vi);
	Vect2 intersec = so.Add(vo.Scal(tt));
	return std::pair<Vect2,double>(intersec,tt);
}
开发者ID:nasa,项目名称:WellClear,代码行数:10,代码来源:VectFuns.cpp


示例13: sq

Vect2 TangentLine::Q(const Vect2& s, const double D, const int eps) {
  double sq_s = s.sqv();
  double sq_D = sq(D);
  double delta = sq_s -sq_D;
  if (delta >= 0) { 
    double alpha = sq_D/sq_s;
    double beta  = D*sqrt_safe(delta)/sq_s;
    return Vect2(alpha*s.x+eps*beta*s.y,
		 alpha*s.y-eps*beta*s.x);   
    }
    return Vect2();
}
开发者ID:E-LLP,项目名称:WellClear,代码行数:12,代码来源:TangentLine.cpp


示例14: tcpa

/**
 * Return distance at time of closest point of approach
 **/
double Vect2::dcpa(const Vect2& so, const Vect2& vo, const Vect2& si, const Vect2& vi) {
	double t = tcpa(so,vo,si,vi);
	Vect2 s = so.Sub(si);
	Vect2 v = vo.Sub(vi);
	Vect2 st = s.AddScal(t,v);
	return st.norm();
}
开发者ID:,项目名称:,代码行数:10,代码来源:


示例15: Convert3DTo2D

inline Vect2 Convert3DTo2D(Vect &p, DWORD axis, BOOL bNegative)
{
    Vect2 val;

    switch(axis)
    {
        case 0:
            val.Set(p.z, p.y);
            break;

        case 1:
            val.Set(p.x, p.z);
            break;

        case 2:
            val.Set(-p.x, p.y);
            break;
    }

    if(bNegative)
        val.x = -val.x;

    return val;
}
开发者ID:alanzw,项目名称:JimEngine,代码行数:24,代码来源:Triangulator.cpp


示例16: timeOfIntersection

/**
 * Computes 2D intersection point of two lines, but also finds z component (projected by time from line 1)
 * @param s0 starting point of line 1
 * @param v0 direction vector for line 1
 * @param s1 starting point of line 2
 * @param v1 direction vector of line 2
 * @return Pair (2-dimensional point of intersection with 3D projection, relative time of intersection, relative to the so3)
 * If the lines are parallel, this returns the pair (0,NaN).
 */
double  VectFuns::timeOfIntersection(const Vect3& so3, const Velocity& vo3, const Vect3& si3, const Velocity& vi3) {
	Vect2 so = so3.vect2();
	Vect2 vo = vo3.vect2();
	Vect2 si = si3.vect2();
	Vect2 vi = vi3.vect2();
	Vect2 ds = si.Sub(so);
	if (vo.det(vi) == 0) {
		//f.pln(" $$$ intersection: lines are parallel");
		return NaN;
	}
	double tt = ds.det(vi)/vo.det(vi);
	//f.pln(" $$$ intersection: tt = "+tt);
	return tt;
}
开发者ID:nasa,项目名称:WellClear,代码行数:23,代码来源:VectFuns.cpp


示例17: Delta

bool TCAS2D::min_tau_undef(double DMOD, double B, double T, Vect2 s, Vect2 v) {
  return Horizontal::Delta(s,v,DMOD) >= 0 &&
      v.ScalAdd(B,s).dot(v) < 0 && v.ScalAdd(T,s).dot(v) >= 0;
}
开发者ID:,项目名称:,代码行数:4,代码来源:


示例18: max

double TCAS2D::nominal_tau(double B, double T, const Vect2& s, const Vect2& v, double rr) {
  if (v.isZero())
    return B;
  return std::max(B,std::min(T,-s.dot(v) / v.sqv()-rr/2));
}
开发者ID:,项目名称:,代码行数:5,代码来源:


示例19: horizontal_RA

bool TCAS2D::horizontal_RA_at(double DMOD, double Tau, const Vect2& s, const Vect2& v, double t) {
  const Vect2& sat = v.ScalAdd(t,s);
  return horizontal_RA(DMOD,Tau,sat,v);
}
开发者ID:,项目名称:,代码行数:4,代码来源:


示例20:

BOOL Line2::LinesIntersect(const Line2 &collider) const
{
    //this looks more complex than it really is.  I'm just an optimization freak.
    //...okay, this probably isn't the kind of function that's called every frame or something.
    //but I'm compulsive about optimization!  ..okay, I'll make it cleaner one of these days.

    Vect2 vec = (A-B);
    float len = vec.Len();
    Vect2 norm = (vec/len);
    Vect2 cross = norm.GetCross();
    float dist = cross.Dot(A);

    float fADist = collider.A.Dot(cross)-dist;
    float fBDist = collider.B.Dot(cross)-dist;

    BOOL bAAbove = (fADist > -EPSILON);
    BOOL bBAbove = (fBDist > -EPSILON);

    BOOL bFoundZeroLine1 = FALSE;

    if( (fabs(fADist) < EPSILON) ||
        (fabs(fBDist) < EPSILON) )
    {
        bFoundZeroLine1 = TRUE;
    }

    if(bAAbove == bBAbove)
        return FALSE;

    vec = (collider.A-collider.B);
    len = vec.Len();
    norm = (vec/len);
    cross = norm.GetCross();
    dist = cross.Dot(collider.A);

    fADist = A.Dot(cross)-dist;
    fBDist = B.Dot(cross)-dist;

    bAAbove = (fADist > -EPSILON);
    bBAbove = (fBDist > -EPSILON);

    if(fabs(fADist) < EPSILON)
        bAAbove = bBAbove;
    if(fabs(fBDist) < EPSILON)
        bBAbove = bAAbove;

    BOOL bFoundZeroLine2 = FALSE;

    if( (fabs(fADist) < EPSILON) ||
        (fabs(fBDist) < EPSILON) )
    {
        bFoundZeroLine2 = TRUE;
    }

    if(bAAbove == bBAbove)
        return FALSE;

    if(bFoundZeroLine1 && bFoundZeroLine2)
        return FALSE;

    return TRUE;
}
开发者ID:373137461,项目名称:OBS,代码行数:62,代码来源:XMath.cpp



注:本文中的Vect2类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Vect3类代码示例发布时间:2022-05-31
下一篇:
C++ Vect类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap