当前位置: 首页>>代码示例>>C++>>正文


C++ VSub函数代码示例

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


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

示例1: newtri

object * newtri(void * tex, vector v0, vector v1, vector v2) {
  tri * t;
  vector edge1, edge2, edge3;

  VSub(&v1, &v0, &edge1);
  VSub(&v2, &v0, &edge2);
  VSub(&v2, &v1, &edge3);

  /* check to see if this will be a degenerate triangle before creation */
  if ((VLength(&edge1) >= EPSILON) && 
      (VLength(&edge2) >= EPSILON) && 
      (VLength(&edge3) >= EPSILON)) {

    t=(tri *) rt_getmem(sizeof(tri));

    t->nextobj = NULL;
    t->methods = &tri_methods;

    t->tex = (texture *)tex;
    t->v0 = v0;
    t->edge1 = edge1;
    t->edge2 = edge2;
 
    return (object *) t;
  }
  
  return NULL; /* was a degenerate triangle */
}
开发者ID:SPLURGE831,项目名称:practice,代码行数:28,代码来源:triangle.cpp

示例2: cylinder_normal

static void cylinder_normal(cylinder * cyl, vector * pnt, ray * incident, vector * N) {
  vector a,b,c;
  flt t;

  VSub((vector *) pnt, &(cyl->ctr), &a);

  c=cyl->axis;

  VNorm(&c);
 
  VDOT(t, a, c);

  b.x = c.x * t + cyl->ctr.x; 
  b.y = c.y * t + cyl->ctr.y;
  b.z = c.z * t + cyl->ctr.z;

  VSub(pnt, &b, N); 
  VNorm(N);

  if (VDot(N, &(incident->d)) > 0.0)  { /* make cylinder double sided */
    N->x=-N->x;
    N->y=-N->y;
    N->z=-N->z;
  } 
}
开发者ID:Gorfaal,项目名称:CIS410Parallel,代码行数:25,代码来源:cylinder.cpp

示例3: EvalSinCos

void EvalSinCos ()
{
  VecR t, tt, u, w;
  int j, n;

  VSetAll (t, 2. * M_PI);
  VDiv (t, t, region);
  DO_MOL {
    VMul (tt, t, mol[n].r);
    VSetAll (tCos[0][n], 1.);
    VSetAll (tSin[0][n], 0.);
    VSet (tCos[1][n], cos (tt.x), cos (tt.y), cos (tt.z));
    VSet (tSin[1][n], sin (tt.x), sin (tt.y), sin (tt.z));
    VSCopy (u, 2., tCos[1][n]);
    VMul (tCos[2][n], u, tCos[1][n]);
    VMul (tSin[2][n], u, tSin[1][n]);
    VSetAll (tt, 1.);
    VVSub (tCos[2][n], tt);
    for (j = 3; j <= fSpaceLimit; j ++) {
      VMul (w, u, tCos[j - 1][n]);
      VSub (tCos[j][n], w, tCos[j - 2][n]);
      VMul (w, u, tSin[j - 1][n]);
      VSub (tSin[j][n], w, tSin[j - 2][n]);
    }
  }
}
开发者ID:qnu,项目名称:mdoch,代码行数:26,代码来源:pr_13_1.c

示例4: build_area_table

static __inline__ void build_area_table(const BBOX_TREE *bbox_tree,
	Uint32 a, Uint32  b, float *areas)
{
	VECTOR3 bmin, bmax, len;
	int i, j;

	VFill(bmin, BOUND_HUGE);
	VFill(bmax, -BOUND_HUGE);

	if (a < b)
	{
		for (i = a, j = 0; i <= b; i++, j++)
		{
			VMin(bmin, bmin, bbox_tree->items[i].bbox.bbmin);
			VMax(bmax, bmax, bbox_tree->items[i].bbox.bbmax);
			VSub(len, bmax, bmin);

			areas[j] = len[X] * len[Y] * len[Z];
		}
	}
	else
	{
		for (i = a, j = a-b; i >= (int)b; i--, j--)
		{
			VMin(bmin, bmin, bbox_tree->items[i].bbox.bbmin);
			VMax(bmax, bmax, bbox_tree->items[i].bbox.bbmax);
			VSub(len, bmax, bmin);

			areas[j] = len[X] * len[Y] * len[Z];
		}
	}
}
开发者ID:csiga,项目名称:Eternal-Lands,代码行数:32,代码来源:bbox_tree.c

示例5: Vfunc

float Vfunc(int which, float* v1, float* v2, float* vresult, float scalar)
{
 int i = 0;
 float fTmp[3];

 if (which == 2) { // vresult = v1 - v2
  for (; i < 3; i++)
   vresult[i] = v1[i] - v2[i];
 }

 if (which == 4) { // vresult = scalar * v1
  for (; i < 3; ++i)
   vresult[i] = scalar * v1[i];
 }

 if (which == 6) { // returns distance between v1 and v2
  VSub(v1, v2, fTmp); // fTmp = v1 - v2
  return VLen(fTmp);
 }

 if (which == 8)
  return acosf(VDot(v1, v2)/(VLen(v1) * VLen(v2)))*180.0/PI;

 if (which == 9)
 { // unit vector pointing from v1 toward v2
  VSub(v2, v1, vresult);
  VUnit(vresult);
 }

 return 0;
}
开发者ID:Stuy-Naught,项目名称:Stuy-Naught-2010,代码行数:31,代码来源:K_Vfunc.c

示例6: getVector

inline VECTOR MODEL :: getVector(){
	VECTOR tmp = VSub(VGet(x, y, z), VGet(preX, preY, preZ));
	if(tmp.x == 0 && tmp.z ==0)
		return VSub(VGet(x, y, z), VGet(ppX, ppY, ppZ));
	ppX = preX;
	ppY = preY;
	ppZ = preZ;
	return VSub(VGet(x, y, z), VGet(preX, preY, preZ));
}
开发者ID:cam-xetal,项目名称:c_zemi,代码行数:9,代码来源:model.hpp

示例7: ComputeSiteForces

void ComputeSiteForces ()
{
  VecR dr, shift;
  real fcVal, rr, rrCut, rri, rri3, uVal;
  int j1, j2, m1, m2, ms1, ms2, n, typeSum;

  rrCut = Sqr (rCut);
  for (n = 0; n < nMol * sitesMol; n ++) VZero (site[n].f);
  uSum = 0.;
  for (m1 = 0; m1 < nMol - 1; m1 ++) {
    for (m2 = m1 + 1; m2 < nMol; m2 ++) {
      VSub (dr, mol[m1].r, mol[m2].r);
      VZero (shift);
      VShiftAll (dr);
      VVAdd (dr, shift);
      rr = VLenSq (dr);
      if (rr < rrCut) {
        ms1 = m1 * sitesMol;
        ms2 = m2 * sitesMol;
        for (j1 = 0; j1 < sitesMol; j1 ++) {
          for (j2 = 0; j2 < sitesMol; j2 ++) {
            typeSum = mSite[j1].typeF + mSite[j2].typeF;
            if (mSite[j1].typeF == mSite[j2].typeF || typeSum == 5) {
              VSub (dr, site[ms1 + j1].r, site[ms2 + j2].r);
              VVAdd (dr, shift);
              rr = VLenSq (dr);
              rri = 1. / rr;
              switch (typeSum) {
                case 2:
                  rri3 = Cube (rri);
                  uVal = 4. * rri3 * (rri3 - 1.);
                  fcVal = 48. * rri3 * (rri3 - 0.5) * rri;
                  break;
                case 4:
                  uVal = 4. * bCon * sqrt (rri);
                  fcVal = uVal * rri;
                  break;
                case 5:
                  uVal = -2. * bCon * sqrt (rri);
                  fcVal = uVal * rri;
                  break;
                case 6:
                  uVal = bCon * sqrt (rri);
                  fcVal = uVal * rri;
                  break;
              }
              VVSAdd (site[ms1 + j1].f, fcVal, dr);
              VVSAdd (site[ms2 + j2].f, - fcVal, dr);
              uSum += uVal;
            }
          }
        }
      }
    }
  }
}
开发者ID:qnu,项目名称:mdoch,代码行数:56,代码来源:pr_08_1.c

示例8: EvalRdf

void EvalRdf ()
{
  VecR dr, shift;
  real deltaR, normFac, rr;
  int j1, j2, k, m1, m2, ms1, ms2, n, rdfType, typeSum;

  if (countRdf == 0) {
    for (k = 0; k < 3; k ++) {
      for (n = 0; n < sizeHistRdf; n ++) histRdf[k][n] = 0.;
    }
  }
  deltaR = rangeRdf / sizeHistRdf;
  for (m1 = 0; m1 < nMol - 1; m1 ++) {
    for (m2 = m1 + 1; m2 < nMol; m2 ++) {
      VSub (dr, mol[m1].r, mol[m2].r);
      VZero (shift);
      VShiftAll (dr);
      VVAdd (dr, shift);
      rr = VLenSq (dr);
      if (rr < Sqr (rangeRdf)) {
        ms1 = m1 * sitesMol;
        ms2 = m2 * sitesMol;
        for (j1 = 0; j1 < sitesMol; j1 ++) {
          for (j2 = 0; j2 < sitesMol; j2 ++) {
            typeSum = mSite[j1].typeRdf + mSite[j2].typeRdf;
            if (typeSum >= 2) {
              VSub (dr, site[ms1 + j1].r, site[ms2 + j2].r);
              VVAdd (dr, shift);
              rr = VLenSq (dr);
              if (rr < Sqr (rangeRdf)) {
                n = sqrt (rr) / deltaR;
                if (typeSum == 2) rdfType = 0;
                else if (typeSum == 3) rdfType = 1;
                else rdfType = 2;
                ++ histRdf[rdfType][n];
              }
            }
          }
        }
      }
    }
  }
  ++ countRdf;
  if (countRdf == limitRdf) {
    normFac = VProd (region) / (2. * M_PI * Cube (deltaR) *
       Sqr (nMol) * countRdf);
    for (k = 0; k < 3; k ++) {
      for (n = 0; n < sizeHistRdf; n ++)
         histRdf[k][n] *= normFac / Sqr (n - 0.5);
    }
    PrintRdf (stdout);
    countRdf = 0;
  }
}
开发者ID:qnu,项目名称:mdoch,代码行数:54,代码来源:pr_08_1.c

示例9: Chara_Collision

// キャラクターに当たっていたら押し出す処理を行う( chk_ch に ch が当たっていたら ch が離れる )
void Chara_Collision( CHARA *ch, VECTOR *ch_MoveVec, CHARA *chk_ch )
{
	VECTOR ChkChToChVec ;
	VECTOR PushVec ;
	VECTOR ChPosition ;
	float Length ;

	// 移動後の ch の座標を算出
	ChPosition = VAdd( ch->Position, *ch_MoveVec ) ;

	// 当たっていなかったら何もしない
	if( HitCheck_Capsule_Capsule(
			ChPosition, VAdd( ChPosition, VGet( 0.0f, CHARA_HIT_HEIGHT, 0.0f ) ), CHARA_HIT_WIDTH, 
			chk_ch->Position, VAdd( chk_ch->Position, VGet( 0.0f, CHARA_HIT_HEIGHT, 0.0f ) ), CHARA_HIT_WIDTH ) == TRUE )
	{
		// 当たっていたら ch が chk から離れる処理をする

		// chk_ch から ch へのベクトルを算出
		ChkChToChVec = VSub( ChPosition, chk_ch->Position ) ;

		// Y軸は見ない
		ChkChToChVec.y = 0.0f ;

		// 二人の距離を算出
		Length = VSize( ChkChToChVec ) ;

		// chk_ch から ch へのベクトルを正規化( ベクトルの長さを 1.0f にする )
		PushVec = VScale( ChkChToChVec, 1.0f / Length ) ;

		// 押し出す距離を算出、もし二人の距離から二人の大きさを引いた値に押し出し力を足して離れてしまう場合は、ぴったりくっつく距離に移動する
		if( Length - CHARA_HIT_WIDTH * 2.0f + CHARA_HIT_PUSH_POWER > 0.0f )
		{
			float TempY ;

			TempY = ChPosition.y ;
			ChPosition = VAdd( chk_ch->Position, VScale( PushVec, CHARA_HIT_WIDTH * 2.0f ) ) ; 

			// Y座標は変化させない
			ChPosition.y = TempY ;
		}
		else
		{
			// 押し出し
			ChPosition = VAdd( ChPosition, VScale( PushVec, CHARA_HIT_PUSH_POWER ) ) ;
		}
	}

	// 当たり判定処理後の移動ベクトルをセット
	*ch_MoveVec = VSub( ChPosition, ch->Position ) ;
}
开发者ID:KNCT-KPC,项目名称:OpenCampus,代码行数:51,代码来源:3DAction_DepthShadow.cpp

示例10: Find_Required_Motion

/*	Vector
**	Find_Required_Motion(Vector pt, FeaturePtr con)
**	Returns the displacement required to make the pt satisfy the constraint.
*/
Vector
Find_Required_Motion(Vector pt, FeaturePtr con)
{
	Vector	result;
	Vector	temp_v;

	switch ( con->f_type )
	{
		case plane_feature:
			temp_v = Closest_Plane_Point(con->f_vector, con->f_point, pt);
			break;
	
		case line_feature:
			temp_v = Closest_Line_Point(con->f_vector, con->f_point, pt);
			break;

		case point_feature:
			temp_v = con->f_point;
			break;

		default: VNew(0, 0, 0, result);
	}

	VSub(temp_v, pt, result);
	return result;

}
开发者ID:Thump,项目名称:sceda,代码行数:31,代码来源:constraint.c

示例11: Compute_Cylinder_Data

void Compute_Cylinder_Data(OBJECT *Object)
{
  DBL tmpf;
  VECTOR axis;
  CONE *Cone = (CONE *)Object;

  VSub(axis, Cone->apex, Cone->base);

  VLength(tmpf, axis);

  if (tmpf < EPSILON)
  {
    Error("Degenerate cylinder, base point = apex point.");
  }
  else
  {
    VInverseScaleEq(axis, tmpf);

    Compute_Coordinate_Transform(Cone->Trans, Cone->base, axis, Cone->apex_radius, tmpf);
  }

  Cone->dist = 0.0;

  /* Recalculate the bounds */

  Compute_Cone_BBox(Cone);
}
开发者ID:obeoneji,项目名称:light_field_personal,代码行数:27,代码来源:cones.cpp

示例12: waves

static void waves (const VECTOR EPoint, const TNORMAL *Tnormal, VECTOR normal, const TraceThreadData *Thread)
{
	register unsigned int i;
	register DBL length, scalar, index, sinValue ;
	VECTOR point;

	for (i = 0 ; i < Thread->numberOfWaves ; i++)
	{
		VSub (point, EPoint, *Thread->waveSources[i]);

		VLength (length, point);

		if (length == 0.0)
		{
			length = 1.0;
		}

		index = length * Tnormal->Frequency * Thread->waveFrequencies[i] + Tnormal->Phase;

		sinValue = cycloidal(index);

		scalar = sinValue * Tnormal->Amount / Thread->waveFrequencies[i];

		VAddScaledEq(normal, scalar / (length * (DBL)Thread->numberOfWaves), point);
	}
}
开发者ID:acekiller,项目名称:povray,代码行数:26,代码来源:normal.cpp

示例13: Make_BBox

void Parametric::Compute_BBox()
{
	if(container_shape != 0)
	{
		Make_BBox(BBox,
		          container.sphere.center[X] - container.sphere.radius,
		          container.sphere.center[Y] - container.sphere.radius,
		          container.sphere.center[Z] - container.sphere.radius,
		          container.sphere.radius * 2,
		          container.sphere.radius * 2,
		          container.sphere.radius * 2);
	}
	else
	{
		// [ABX 20.01.2004] Low_Left introduced to hide BCC 5.5 bug
		BBOX_VECT& Low_Left = BBox.Lower_Left;

		Assign_BBox_Vect(Low_Left, container.box.corner1);
		VSub(BBox.Lengths, container.box.corner2, container.box.corner1);
	}

	if(Trans != NULL)
	{
		Recompute_BBox(&BBox, Trans);
	}
}
开发者ID:fourks,项目名称:povray,代码行数:26,代码来源:fpmetric.cpp

示例14: VSub

void Bullet::Collision(Character* character)
{
    for (l = 0; l < BULLET; l++)
    {
        if (bullet[l] == 1 | bullet[l] == 2 | bullet[l] == 3)
        {
            colVector = VSub(VGet(character->vector.x, character->vector.y + 40.0f, character->vector.z), bulletLocation[l]);
            distVector = colVector.x * colVector.x + colVector.y * colVector.y + colVector.z * colVector.z;
            if (isGraze[l] == 0 & distVector  < 250)
            {
                if (bullet[l] == 1 | bullet[l] == 2)
                {
                    character->AddMp(5);
                }
                if (bullet[l] == 3)
                {
                    character->AddMp(15);
                }
            }
            if (distVector < 20)
            {
                if (bullet[l] == 1 | bullet[l] == 2)
                {
                    bullet[l] = 0;
                    character->AddHp(-10);
                }
                if (bullet[l] == 3)
                {
                    bullet[l] = 0;
                    character->AddHp(-30);
                }
            }
        }
    }
}
开发者ID:Narinyir,项目名称:3Dshooting,代码行数:35,代码来源:Bullet.cpp

示例15: VSub

Bullet::Bullet(VECTOR direction, VECTOR translation, int damage, float speed,  BULLET_TYPE bulletType,float size)
:Object(direction,translation)
{
	_damage = damage;
	_size = size;
	_speed = speed;
	_bulletType = bulletType;
	_count = 0;
	_targetEnemy = NULL;
	_hit = false;
	if (_bulletType == BULLET_TYPE_PLAYER_HORMING)
	{
		float mdist = FLT_MAX;
		auto &enemies = ObjectField::getObjectField().Enemies;

		for (auto& enemy : enemies)
		{
			VECTOR v = VSub(_translation, enemy.GetTranslation());
			float dist = VDot(v, v);
			if (mdist > dist)
			{
				mdist = dist;
				_targetEnemy = &enemy;
			}
		}
	}
}
开发者ID:c-plus-c,项目名称:3DShootingOne,代码行数:27,代码来源:Bullet.cpp


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