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

C++ Vector4D类代码示例

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

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



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

示例1: Slerp

		Vector4D Slerp(const Vector4D &a, const Vector4D &b, Float t) {
			 Float dot = Math::WrapFloat(Dot(a, b), -1.0f, 1.0f);
			 Float theta = acos(dot) * t;
			 Vector4D relativeVec = b - (a * dot);
			 relativeVec.Normalize();
			 return ((a*cos(theta)) + (relativeVec*sin(theta)));
		}
开发者ID:JSandrew4,项目名称:FastGdk,代码行数:7,代码来源:Vector4DMath.cpp


示例2: aij

LScrMatrix4D LScrMatrix4D::diag3() const
{
  Matrix3D mat;
  for (int i=1; i<=3; ++i)
    for (int j=1; j<=3; ++j)
      mat.aij(i,j) = aij(i,j);

  Matrix3D evecs;
  Vector4D evals;
  mat.diag(evecs, evals);

  LScrMatrix4D rval;
  for (int i=1; i<=3; ++i)
    for (int j=1; j<=3; ++j)
      rval.aij(i,j) = evecs.aij(i,j);

  rval.aij(4,1) = evals.x();
  rval.aij(4,2) = evals.y();
  rval.aij(4,3) = evals.z();

  if ( rval.aij(4,1)>rval.aij(4,2) )
    swapcols(rval, 1, 2);
  if ( rval.aij(4,1)>rval.aij(4,3) )
    swapcols(rval, 1, 3);
  if ( rval.aij(4,2)>rval.aij(4,3) )
    swapcols(rval, 2, 3);

  return rval;
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:29,代码来源:LScrMatrix4D.cpp


示例3: addHeightFieldActor

		/**
		 * Method is used to add heightfield actor to physics scene.
		 * @param	entity is actor logic object.
		 * @param	heightData is terrain height map data.
		 * @param	params is terrain parameters: heightmap size, row/column scale, max. height.
		 * @param	filterGroup is actor own id.
		 * @param	filterMask is mask to filter pairs that trigger a contact callback.
		 */
		void PhysicsManager::addHeightFieldActor(SceneEntity* entity, unsigned char* heightData, const Vector4D& params, PxU32 filterGroup, PxU32 filterMask)
		{
			int terrainSize = static_cast<int>(params.x());

			PxHeightFieldSample* samples = new PxHeightFieldSample[terrainSize*terrainSize];
			PxHeightFieldDesc descriptor;
			descriptor.nbColumns = static_cast<int>(terrainSize);
			descriptor.nbRows = static_cast<int>(terrainSize);
	
			for(int i = 0; i < terrainSize*terrainSize; ++i)
				samples[i].height = static_cast<PxI16>(heightData[i]);

			descriptor.samples.data = samples;
			descriptor.samples.stride = sizeof(PxHeightFieldSample);

			PxHeightField* heightField = physicsSDK->createHeightField(descriptor);
			PxHeightFieldGeometry geometry(heightField, PxMeshGeometryFlags(),params.w()*0.00390625f,params.y(),params.z());
			PxTransform transformation = PxTransform(PxVec3(-terrainSize*0.5f*params.y(),0.0f,-terrainSize*0.5f*params.z()),PxQuat::createIdentity());

			PxRigidStatic* heightFieldActor = physicsSDK->createRigidStatic(transformation);
			PxShape* aHeightFieldShape = heightFieldActor->createShape(geometry,*materials[0].second);
			heightFieldActor->setName(entity->entityName.c_str());
			setupFiltering(heightFieldActor,filterGroup,filterMask);
			scene->addActor(*heightFieldActor);
			
			StaticActor* s = new StaticActor();
			s->entityLogic = entity;
			s->entityPhysics = heightFieldActor;
			staticActors.push_back(s);
		}
开发者ID:veldrinlab,项目名称:ayumiEngine,代码行数:38,代码来源:PhysicsManager.cpp


示例4: DistToSqr

		// Get the distance from this vector to the other one squared.
		// NJS: note, VC wasn't inlining it correctly in several deeply nested inlines due to being an 'out of line' .  
		// may be able to tidy this up after switching to VC7
		vec_t DistToSqr( const Vector4D &vOther ) const {
			Vector4D delta;

			delta.x = x - vOther.x;
			delta.y = y - vOther.y;
			delta.z = z - vOther.z;
			delta.w = w - vOther.w;

			return delta.LengthSqr();
		}
开发者ID:ljuwon321,项目名称:pChanger,代码行数:13,代码来源:Vector4D.hpp


示例5: Normal

    /// Computes normal vector for object
    /// \param point point in space, where w = 1 and point is near object (almost hit or hit)
    /// \return normal vector
    virtual Vector4D Normal(const Point4D& point) const {
        static double e = 0.00005;
        Vector4D n;

        n[0] = dist(MakeVector4(point[0] + e, point[1], point[2])) - dist(MakeVector4(point[0] - e, point[1], point[2]));
        n[1] = dist(MakeVector4(point[0], point[1] + e, point[2])) - dist(MakeVector4(point[0], point[1] - e, point[2]));
        n[2] = dist(MakeVector4(point[0], point[1], point[2] + e)) - dist(MakeVector4(point[0], point[1], point[2] - e));
      
        return n.Norm();
    }
开发者ID:rAum,项目名称:rum,代码行数:13,代码来源:IObject.hpp


示例6: begin

void MolArrayMap::convertf(qlib::Array<float> &refary)
{
  int i;
  const_iterator iter = begin();
  for (i=0; iter!=end(); ++iter, ++i) {
    Vector4D pos = iter->first.pA->getPos();
    refary[i*3] = (float)pos.x();
    refary[i*3+1] = (float)pos.y();
    refary[i*3+2] = (float)pos.z();
  }
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:11,代码来源:MolArrayMap.cpp


示例7: ai

void LScrVector4D::setStrValue(const LString &val)
{
  Vector4D vec;
  if (!Vector4D::fromStringS(val, vec)) {
    LString msg = LString::format("cannot convert \"%s\" to vector", val.c_str());
    MB_THROW(qlib::RuntimeException, msg);
    return;
  }

  for (int i=1; i<=4; ++i)
    ai(i) = vec.ai(i);
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:12,代码来源:LScrVector4D.cpp


示例8: Vector4D

void MolSurfBuilder::drawArc(const Vector4D &n, double rad, const Vector4D &cen,
             const Vector4D &vst, double theta2)
{
  const Vector4D &e1 = n;
  const Vector4D e2 = vst.normalize();
  const Vector4D e3 = e1.cross(e2);

  Matrix4D xfmat = Matrix4D::makeTransMat(cen);

  xfmat.aij(1,1) = e2.x();
  xfmat.aij(2,1) = e2.y();
  xfmat.aij(3,1) = e2.z();

  xfmat.aij(1,2) = e3.x();
  xfmat.aij(2,2) = e3.y();
  xfmat.aij(3,2) = e3.z();

  xfmat.aij(1,3) = e1.x();
  xfmat.aij(2,3) = e1.y();
  xfmat.aij(3,3) = e1.z();

  m_pdl->pushMatrix();
  m_pdl->multMatrix(xfmat);
  /*m_pdl->cylinder(0.05, Vector4D(0,0,0), e1);
    m_pdl->cylinder(0.05, Vector4D(0,0,0), e2);
    m_pdl->cylinder(0.05, Vector4D(0,0,0), e3);*/

  /*
    m_pdl->color_3d(1, 0, 0);
    m_pdl->cylinder(0.05, Vector4D(0,0,0), Vector4D(1,0,0));
    m_pdl->color_3d(0, 1, 0);
    m_pdl->cylinder(0.05, Vector4D(0,0,0), Vector4D(0,1,0));
    m_pdl->color_3d(0, 0, 1);
    m_pdl->cylinder(0.05, Vector4D(0,0,0), Vector4D(0,0,1));
   */

  const double arclen = qlib::abs(theta2 * rad);
  int ndiv = int(arclen/0.1);
  if (ndiv<5)
    ndiv = 5;
  const double dth = theta2/double(ndiv);
  //MB_DPRINTLN("arclen: %f, ndiv: %d, dth: %f", arclen, ndiv, dth);

  int i;
  double th = 0.0;
  m_pdl->setLighting(false);
  m_pdl->startLineStrip();
  for (i=0; i<ndiv+1; ++i) {
    m_pdl->vertex(rad*::cos(th), rad*::sin(th), 0.0);
    th += dth;
  }
  m_pdl->end();
  m_pdl->setLighting(true);
  m_pdl->popMatrix();
}
开发者ID:biochem-fan,项目名称:cuemol2,代码行数:55,代码来源:MolSurfBuilder.cpp


示例9: qFromAngleAxis

Quaternions Quaternions::qFromAngleAxis(float theta, Vector4D axis)
{
	Vector4D axisn = axis.normalize();
	Quaternions q;
	float a = theta * (float)DEGREES_TO_RADIANS;
	q.t = cos(a / 2.0f);
	float s = sin(a / 2.0f);
	q.x = axisn.getX() * s;
	q.y = axisn.getY() * s;
	q.z = axisn.getZ() * s;

	qClean(q);
	return qNormalize(q);
}
开发者ID:miguelfmp,项目名称:CGJ,代码行数:14,代码来源:Quaternions.cpp


示例10: RGB2HSV

void RGB2HSV(const Vector4D &normalizedRGB, float &H, float &s, float &v)
{
    float fmax = max(normalizedRGB.x, max(normalizedRGB.y, normalizedRGB.z));
    float fmin = min(normalizedRGB.x, min(normalizedRGB.y, normalizedRGB.z));

    v = fmax;

    if (fmax <= 0.0f || normalizedRGB.LengthSqr() <= 0.0f)
        s = 0.0f;
    else
        s = (fmax - fmin) / fmax;

    if (fmax == fmin || (normalizedRGB.x == normalizedRGB.y && normalizedRGB.x == normalizedRGB.z))
    {
        H = 0; //-1.0f;
    }
    else if (normalizedRGB.x >= fmax)
        H = 60.0f * ((normalizedRGB.y - normalizedRGB.z) / (fmax - fmin));
    else if (normalizedRGB.y >= fmax)
        H = 60.0f * (2 + (normalizedRGB.z - normalizedRGB.x) / (fmax - fmin));
    else if (normalizedRGB.z >= fmax)
        H = 60.0f * (4 + (normalizedRGB.x - normalizedRGB.y) / (fmax - fmin));
    if (H < 0)
        H += 360.0f;
}
开发者ID:bonjorno7,项目名称:GAME,代码行数:25,代码来源:ColorPicker.cpp


示例11: drawDisk

void MolSurfBuilder::drawDisk(const Vector4D &cen, const Vector4D &norm, double rad)
{
  const double thik = 0.05;
  const Vector4D start = cen - norm.scale(thik/2.0);
  const Vector4D end   = cen + norm.scale(thik/2.0);
  m_pdl->cylinderCap(rad, start, end);
}
开发者ID:biochem-fan,项目名称:cuemol2,代码行数:7,代码来源:MolSurfBuilder.cpp


示例12: Vector4DMultiplyPosition

void Vector4DMultiplyPosition( const VMatrix& src1, Vector const& src2, Vector4D& dst )
{
	// Make sure it works if src2 == dst
	Vector tmp;
	Vector const&v = ( &src2 == &dst.AsVector3D() ) ? static_cast<const Vector>(tmp) : src2;

	if (&src2 == &dst.AsVector3D())
	{
		VectorCopy( src2, tmp );
	}

	dst[0] = src1[0][0] * v[0] + src1[0][1] * v[1] + src1[0][2] * v[2] + src1[0][3];
	dst[1] = src1[1][0] * v[0] + src1[1][1] * v[1] + src1[1][2] * v[2] + src1[1][3];
	dst[2] = src1[2][0] * v[0] + src1[2][1] * v[1] + src1[2][2] * v[2] + src1[2][3];
	dst[3] = src1[3][0] * v[0] + src1[3][1] * v[1] + src1[3][2] * v[2] + src1[3][3];
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:16,代码来源:vmatrix.cpp


示例13:

//------------------------------------------------------------------------------------------------------
//function that multiplies two Matrix objects together
//------------------------------------------------------------------------------------------------------
Matrix4D& Matrix4D::operator*(Matrix4D& rhs)
{

	//variable to keep track of each matrix element of final result
	int count = 0;
	
	//the final matrix result object and two Vector4D objects 
	//are needed to calculate each row and column multiplication
	Matrix4D result;
	Vector4D<float> leftRow;
	Vector4D<float> topColumn;
	
	//loop through each of the top matrix columns
	for(int i = 0; i < 4; i++)
	{

		//assign the elements from top to bottom 
		topColumn.X = rhs[i * 4];
		topColumn.Y = rhs[i * 4 + 1];
		topColumn.Z = rhs[i * 4 + 2];
		topColumn.W = rhs[i * 4 + 3];

		//loop through each of the left matrix rows
		for(int j = 0; j < 4; j++)
		{

			//assign the elements from left to right 
			leftRow.X = m_matrix[j];
			leftRow.Y = m_matrix[j + 4];
			leftRow.Z = m_matrix[j + 8];
			leftRow.W = m_matrix[j + 12];
						
			//use dot product to produce each matrix element result
			result[count++] = leftRow.DotProduct(topColumn);

		}

	}

	//assign result to Matrix object and return reference
	//of lhs matrix to allow for multiplication chaining
	return (*this = result);

}
开发者ID:Ahmed310,项目名称:Handmade,代码行数:47,代码来源:Matrix4D.cpp


示例14: getRandomVector

Vector4D	Vector4D :: getRandomVector ( float len )
{
	Vector4D	v;

	for ( ; ; )
	{
		v.x = rnd ();
		v.y = rnd ();
		v.z = rnd ();
		v.w = rnd ();

		if ( v.lengthSq () < EPS )
			continue;

		v *= len / v.length ();

		return v;
	}
}
开发者ID:makseq,项目名称:Trap,代码行数:19,代码来源:Vector4D.cpp


示例15: NormalizeVector

	vec_t NormalizeVector(Vector4D& v) {
		vec_t l = v.Length();
		if (l != 0.0f) {
			v /= l;
		}
		else {
			v.x = v.y = v.z = v.w = 0.0f;
		}
		return l;
	}
开发者ID:ljuwon321,项目名称:pChanger,代码行数:10,代码来源:Vector4D.cpp


示例16: ColorVarsToVector

//-----------------------------------------------------------------------------
// Converts a color + alpha into a vector4
//-----------------------------------------------------------------------------
void CBaseVSShader::ColorVarsToVector( int colorVar, int alphaVar, Vector4D &color )
{
	color.Init( 1.0, 1.0, 1.0, 1.0 ); 
	if ( colorVar != -1 )
	{
		IMaterialVar* pColorVar = s_ppParams[colorVar];
		if ( pColorVar->GetType() == MATERIAL_VAR_TYPE_VECTOR )
		{
			pColorVar->GetVecValue( color.Base(), 3 );
		}
		else
		{
			color[0] = color[1] = color[2] = pColorVar->GetFloatValue();
		}
	}
	if ( alphaVar != -1 )
	{
		float flAlpha = s_ppParams[alphaVar]->GetFloatValue();
		color[3] = clamp( flAlpha, 0.0f, 1.0f );
	}
}
开发者ID:RubberWar,项目名称:Portal-2,代码行数:24,代码来源:BaseVSShader.cpp


示例17: getClientObj

qlib::Vector4D RendGroup::getCenter() const
{
  // Calc COM of renderers in this group
  Vector4D resvec;
  int nsum = 0;
  ObjectPtr pObj = getClientObj();
  Object::RendIter iter = pObj->beginRend();
  Object::RendIter eiter = pObj->endRend();
  for (;iter!=eiter;++iter) {
    RendererPtr pRend = iter->second;
    if (!pRend->getGroupName().equals(getName()))
      continue;
    if (pRend->hasCenter()) {
      resvec += pRend->getCenter();
      ++nsum;
    }
  }
  if (nsum>0)
    return resvec.divide(nsum);
  else
    return qlib::Vector4D();
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:22,代码来源:RendGroup.cpp


示例18: convToOrth

Vector4D ElePotMap::convToOrth(const Vector4D &index) const
{
  Vector4D tv = index;

  tv.x() = tv.x() * m_gx;
  tv.y() = tv.y() * m_gy;
  tv.z() = tv.z() * m_gz;

  tv += m_origPos;

  return tv;
}
开发者ID:biochem-fan,项目名称:cuemol2,代码行数:12,代码来源:ElePotMap.cpp


示例19: interpolate

/** perform interpolation */
bool CubicSpline::interpolate(double par, Vector4D *vec,
                              Vector4D *dvec /*= NULL*/,
                              Vector4D *ddvec /*= NULL*/)
{
  // check parameter value f
  int ncoeff = (int)::floor(par);
  if (ncoeff<0)
    ncoeff = 0;
  if (ncoeff>=(m_nPoints-1))
    ncoeff = m_nPoints-2;

  const Vector4D &coeff0 = m_pCoeff0[ncoeff];
  const Vector4D &coeff1 = m_pCoeff1[ncoeff];
  const Vector4D &coeff2 = m_pCoeff2[ncoeff];
  const Vector4D &coeff3 = m_pCoeff3[ncoeff];

  double f = par - (double)ncoeff;

  Vector4D tmp;
  tmp = coeff3.scale(f) + coeff2;
  tmp = tmp.scale(f) + coeff1;
  tmp = tmp.scale(f) + coeff0;
  *vec = tmp;

  if (dvec != NULL) {
    // calculate tangential vector
    tmp = coeff3.scale(3.0*f) + coeff2.scale(2.0);
    tmp = tmp.scale(f) + coeff1;
    *dvec = tmp;
  }

  if (ddvec != NULL) {
    // calculate curvature vector
    tmp = coeff3.scale(6.0*f) + coeff2.scale(2.0);
    *ddvec = tmp;
  }
  return true;
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:39,代码来源:CubicSpline.cpp


示例20: Serialize

bool Serialize( CUtlBuffer &buf, const Vector4D &src )
{
	if ( buf.IsText() )
	{
		SerializeFloats( buf, 4, src.Base() );
	}
	else
	{
		buf.PutFloat( src.x );
		buf.PutFloat( src.y );
		buf.PutFloat( src.z );
		buf.PutFloat( src.w );
	}
	return buf.IsValid();
}
开发者ID:Cre3per,项目名称:hl2sdk-csgo,代码行数:15,代码来源:utlbufferutil.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ Vector4d类代码示例发布时间:2022-05-31
下一篇:
C++ Vector4类代码示例发布时间: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