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

C++ Vector4d类代码示例

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

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



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

示例1:

Vector4d Matrix4d::operator* (Vector4d& other){
	Vector4d result;
	for (int i = 0; i < 4; i++){
		result.set(i, other[0] * m[0][i] + other[1] * m[1][i] + other[2] * m[2][i] + other[3] * m[3][i]);
	}
	return result;
}
开发者ID:haymh,项目名称:cse167_pro5,代码行数:7,代码来源:Matrix4d.cpp


示例2: data

ColorBank::Colorf ColorBank::colorf(DotPath const &path) const
{
    if (path.isEmpty()) return Colorf();
    Vector4d clamped = data(path).as<Impl::ColorData>().color;
    clamped = clamped.max(Vector4d(0, 0, 0, 0)).min(Vector4d(1, 1, 1, 1));
    return Colorf(float(clamped.x), float(clamped.y), float(clamped.z), float(clamped.w));
}
开发者ID:,项目名称:,代码行数:7,代码来源:


示例3: Vector

Vector PickObjectTool::GetWorldCoordinates(BaseDraw* bd, const Matrix4d& m, Float x, Float y, Float z)
{
	// pick object returns the view-projection matrix. This transforms a point in camera space into clip space.

	Int32		 l, t, r, b, w, h;
	Vector4d pos;
	Vector	 posWorld;

	bd->GetFrame(&l, &t, &r, &b);
	if (l == r || b == t)
		return Vector(0.0);

	w = r - l;
	h = b - t;

	// first, transform the points into clip space
	pos.x = (x - Float(l)) / Float(w);
	pos.y = (y - Float(t)) / Float(h);
	pos.z = z;
	pos.w = 1.0;
	pos = pos * 2.0f - Vector4d(1.0f);
	pos.y = -pos.y;

	// apply the inverse view transform
	Matrix4d im = !m;
	pos = im * pos;
	pos.MakeVector3();

	// convert it into a 3-tupel
	posWorld = bd->GetMg() * GetVector3(pos);

	return posWorld;
}
开发者ID:archimy,项目名称:cinema4d_cpp_sdk,代码行数:33,代码来源:pickobject.cpp


示例4: cross

/**
 * operating with 3-vectors here because there are a lot of cross products
 */
double Triangle::intersection(const ray &viewRay)const {
    Vector4d edge1 = p2 - p1;
    Vector4d edge2 = p3 - p1;

    Vector4d h = cross(viewRay.dir, edge2);
    double a = edge1.dot(h);

    if (a > -EPSILON && a < EPSILON)
        return -1 * std::numeric_limits<double>::max();


    double f = 1/a;
    Vector4d s = viewRay.orig - p1;
    double u = f * s.dot(h);

    if (u < 0.0 || u > 1.0)
        return -1 * std::numeric_limits<double>::max();

    Vector4d q = cross(s, edge1);
    double v = f * q.dot(viewRay.dir);

    if (v < 0.0 || u + v > 1.0)
        return -1 * std::numeric_limits<double>::max();

    double t = f * edge2.dot(q);

    return t;
}
开发者ID:blargg,项目名称:ray-based-graphics,代码行数:31,代码来源:triangle.cpp


示例5: addPointAndProjection

int addPointAndProjection(SysSBA& sba, vector<Point, Eigen::aligned_allocator<Point> >& points, int ndi)
{
    // Define dimensions of the image.
    int maxx = 640;
    int maxy = 480;

    // Project points into nodes.
    for (int i = 0; i < points.size(); i++)
    {
      double pointnoise = 0.1;
  
      // Add points into the system, and add noise.
      // Add up to .5 pixels of noise.
      Vector4d temppoint = points[i];
      temppoint.x() += pointnoise*(drand48() - 0.5);
      temppoint.y() += pointnoise*(drand48() - 0.5);
      temppoint.z() += pointnoise*(drand48() - 0.5);
      int index = sba.addPoint(temppoint);
    
      Vector3d proj;
      calculateProj(sba, points[i], ndi, proj);
      
      // If valid (within the range of the image size), add the stereo 
      // projection to SBA.
      //if (proj.x() > 0 && proj.x() < maxx && proj.y() > 0 && proj.y() < maxy)
      //{
        sba.addStereoProj(ndi, index, proj);
      //}
    }
    
    
    return sba.tracks.size() - points.size();
}
开发者ID:IDSCETHZurich,项目名称:gajanLocal,代码行数:33,代码来源:single_plane_vis.cpp


示例6: gc_pipi_plk

Vector6d gc_pipi_plk( Vector4d pi1, Vector4d pi2){
  Vector6d plk;
  Matrix4d dp = pi1 * pi2.transpose() - pi2 * pi1.transpose();

  plk << dp(0,3), dp(1,3), dp(2,3), - dp(1,2), dp(0,2), - dp(0,1);
  return plk;
}
开发者ID:rgkoo,项目名称:slslam,代码行数:7,代码来源:gc.cpp


示例7: rigidBodyConstraintParseQuat

void rigidBodyConstraintParseQuat(const mxArray* pm, Vector4d &quat)
{
  if(!mxIsNumeric(pm))
  {
    mexErrMsgIdAndTxt("Drake:rigidBodyConstraintParseQuat:BadInputs","The input argument 1 should be a 4x1 double vector");
  }
  if(!(mxGetM(pm) == 4 && mxGetN(pm) == 1))
  {
    mexErrMsgIdAndTxt("Drake:rigidBodyConstraintParseQuat:BadInputs","The input argument 1 should be of size 4x1");
  }
  memcpy(quat.data(),mxGetPr(pm),sizeof(double)*4);
  for(int i = 0;i<4;i++)
  {
    if((mxIsInf(quat(i)))||(mxIsNaN(quat(i))))
    {
      mexErrMsgIdAndTxt("Drake:rigidBodyConstraintParseQuat:BadInputs","The input argument 1 cannot have entry equal to NaN or Inf");
    }
  }
  double quat_norm = quat.norm();
  if(quat_norm==0.0)
  {
    mexErrMsgIdAndTxt("Drake:rigidBodyConstraintParseQuat:BadInputs","The Input argument 1 must be a nonzero vector");
  }
  quat = quat/quat_norm;
}
开发者ID:RussTedrake,项目名称:drake,代码行数:25,代码来源:constructPtrRigidBodyConstraint.cpp


示例8: uvCoords

Vector4d Triangle::normal_vector(const Vector4d &surface) const {
    double u, v;
    std::tie(u, v) = uvCoords(surface);
    Vector4d normal = (1 - u - v) * n1 + u * n2 + v * n3;
    normal.normalize();
    return normal;
}
开发者ID:blargg,项目名称:ray-based-graphics,代码行数:7,代码来源:triangle.cpp


示例9: addnode

void 
addnode(SysSPA &spa, int n, 
	// node translation
	std::vector< Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > ntrans,
	// node rotation
	std::vector< Eigen::Vector4d, Eigen::aligned_allocator<Eigen::Vector4d> > nqrot,
	// constraint indices
	std::vector< Eigen::Vector2i, Eigen::aligned_allocator<Eigen::Vector2i> > cind,
	// constraint local translation 
	std::vector< Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > ctrans,
	// constraint local rotation as quaternion
	std::vector< Eigen::Vector4d, Eigen::aligned_allocator<Eigen::Vector4d> > cqrot,
	// constraint covariance
	std::vector< Eigen::Matrix<double,6,6>, Eigen::aligned_allocator<Eigen::Matrix<double,6,6> > > cvar)

{
  Node nd;

  // rotation
  Quaternion<double> frq;
  frq.coeffs() = nqrot[n];
  frq.normalize();
  if (frq.w() <= 0.0) frq.coeffs() = -frq.coeffs();
  nd.qrot = frq.coeffs();

  // translation
  Vector4d v;
  v.head(3) = ntrans[n];
  v(3) = 1.0;
  nd.trans = v;
  nd.setTransform();        // set up world2node transform
  nd.setDr(true);

  // add to system
  spa.nodes.push_back(nd);

  // add in constraints
  for (int i=0; i<(int)ctrans.size(); ++i)
    {
      ConP2 con;
      con.ndr = cind[i].x();
      con.nd1 = cind[i].y();

      if ((con.ndr == n && con.nd1 <= n-1) ||
          (con.nd1 == n && con.ndr <= n-1))
        {
	  con.tmean = ctrans[i];
	  Quaternion<double> qr;
	  qr.coeffs() = cqrot[i];
	  qr.normalize();
	  con.qpmean = qr.inverse(); // inverse of the rotation measurement
	  con.prec = cvar[i];       // ??? should this be inverted ???

	  // need a boost for noise-offset system
	  //con.prec.block<3,3>(3,3) *= 10.0;
	  spa.p2cons.push_back(con);
	}
    }
}
开发者ID:jpanikulam,项目名称:sba,代码行数:59,代码来源:run_spa.cpp


示例10: RotateObject

void Model::RotateObject(Shape* shape, TreeObject* object, Vector4d rotate)
{
  if (!shape)
    return;
  Vector3d rot(rotate.x(), rotate.y(), rotate.z());
  shape->Rotate(rot, rotate.w());
  ModelChanged();
}
开发者ID:semiLab,项目名称:repsnapper,代码行数:8,代码来源:model.cpp


示例11: transformPoint

Vector3d transformPoint(Vector3d& point,const MatrixXd& transform)
{
  Vector4d tmp;
  tmp.head(3)=point;
  tmp(3)=1;
  tmp.head(3)=transform*tmp;
  return tmp.head(3);
}
开发者ID:Khrylx,项目名称:AntiMotionSLAM,代码行数:8,代码来源:RGBDFramePair.cpp


示例12: updateRotationQuaternionForAllElements

void CSimuVertexRingObj::_computeElasticForcesNew(
	const unsigned int timeid, const bool isStatic, const bool needjacobian)
{
	//compute the rotation for each vertex
	const bool bRecompRot = (timeid%2 == 1);
	if (timeid<=1 || bRecompRot){ 
		const bool needquat = false;
		updateRotationQuaternionForAllElements(timeid, needquat);
	}
	else{
		//use central difference to update the quaternions
		for (int i=0; i<m_nVRingElementCount; i++){
			CVertexRingElement &e = m_pVRingElement[i];
			Vector4d quat = e.m_quat + e.m_quat - e.m_quat0;
			quat.normalize();
			e.m_quat0 = e.m_quat;
			e.m_quat = quat;
			//convert quat to matrix 
			Quaternion *pquat = (Quaternion*)&e.m_quat.x;
			typedef double M33[3][3];
			pquat->getRotationMatrix(*((M33*)&e.m_R.x));
		}
	}

	//call the old alg.
	const int SKIPSTEP = m_nRotationSkipStep;
	m_nRotationSkipStep = INT_MAX-1;
	_computeElasticForces(timeid, isStatic, needjacobian);
	m_nRotationSkipStep = SKIPSTEP;

	/*
	//compute forces using the rotation
	Vector3d force;
	double3x3 jacobian, *pjac=NULL;
	const bool FASTSTIFF = (this->m_mtl.getMaterialType()==0);
	if (needjacobian) pjac = &jacobian;
	for (int i=0; i<m_nEdge; i++){
		CSimuEdgeInput& edge = m_pEdge[i];
		const int v0=edge.v0, v1=edge.v1;
		if (bRecompRot){
			//computer averaged rotation of the rod, then save it
			const Quaternion *q0 = (const Quaternion *)(&m_pVRingElement[v0].m_quat);
			const Quaternion *q1 = (const Quaternion *)(&m_pVRingElement[v1].m_quat);
			const Quaternion q = Quaternion::slerp_midpoint(*q0, *q1);
			q.getRotationMatrix(*((double(*)[3][3])(&edge.mat)));
		}
		//apply the rotation for the rod element
		const Vector3d& p0 = m_pVertInfo[v0].m_pos;
		const Vector3d& p1 = m_pVertInfo[v1].m_pos;
		m_pGyrod[i].computeNodalForce(p0, p1, edge.mat, *edge.pMaterial, force, pjac);
		//accumulate the force and stiffness
		m_pVertInfo[v0].m_force+=force;
		m_pVertInfo[v1].m_force-=force;
		if (needjacobian) 
			saveVertSitffMatrixIntoSparseMatrix(v0, v1, *pjac, FASTSTIFF);
	}
	*/
}
开发者ID:nanzhang790,项目名称:View3dn,代码行数:58,代码来源:obj_vertexring.cpp


示例13: cullSphere

 inline bool cullSphere(const Vector4d& center,
                        double radius) const
 {
     return (center.z() - radius > m_nearZ ||
             center.z() + radius < m_farZ  ||
             center.dot(m_planeNormals[0]) < -radius ||
             center.dot(m_planeNormals[1]) < -radius ||
             center.dot(m_planeNormals[2]) < -radius ||
             center.dot(m_planeNormals[3]) < -radius);
 }
开发者ID:nisselarsson,项目名称:Celestia,代码行数:10,代码来源:curveplot.cpp


示例14:

Vector4d rigidBodyDynamics::mrp2quaternion(Vector3d mrp) const{
	Vector4d dq;
	dq << 8*mrp / (16 + mrp.transpose() * mrp), (16 - mrp.transpose() * mrp) / (16+mrp.transpose() * mrp);
//	std::cout << "MRP: " << mrp.transpose() << std::endl;
//	std::cout << "dq_prenorm: " << dq.transpose() << std::endl;
	dq /=dq.norm();
//	std::cout << "dq_postnorm: " << dq.transpose() << std::endl;

	return dq;
}
开发者ID:Gabs48,项目名称:HaloLinux_Software,代码行数:10,代码来源:rigidBodyDynamics.cpp


示例15: geometric

double geometric(Vector4d s1, Vector4d n1, Vector4d s2, Vector4d n2) {
    ASSERT(isUnitVector(n1), "assumes the normals are normalized");
    ASSERT(isUnitVector(n2), "assumes the normals are normalized");
    Vector4d segment = s1 - s2;
    Vector4d seg_dir = segment.normalized();
    double cos1 = n1.dot(seg_dir);
    double cos2 = n2.dot(-1 * seg_dir);

    return std::abs(cos1 * cos2) / segment.squaredNorm();
}
开发者ID:blargg,项目名称:ray-based-graphics,代码行数:10,代码来源:shader.cpp


示例16:

// Project a 3D point into this Pose.
Vector2d Pose::ProjectTo2D(const Vector3d& pt3d) {
  Vector4d pt3d_h = Vector4d::Constant(1.0);
  pt3d_h.head(3) = pt3d;

  const Vector4d proj_h = Rt_ * pt3d_h;
  Vector2d proj = proj_h.head(2);
  proj /= proj_h(2);

  return proj;
}
开发者ID:erik-nelson,项目名称:berkeley_sfm,代码行数:11,代码来源:pose.cpp


示例17: Vector4d

Vector4d CProxyCamera::intersect(const Vector4d &coord, const Vector4d& abcd) const 
{
	Vector4d ray = m_center - coord;

	const double A = coord.dot(abcd);
	const double B = ray.dot(abcd);

	if (fabs(B)<1e-8)
		return Vector4d(0.0f, 0.0f, 0.0f, -1.0f);
	else
		return coord - A / B * ray;
}
开发者ID:Khrylx,项目名称:BoxProxy,代码行数:12,代码来源:ProxyCam.cpp


示例18: frustumCull

// Test a point to see if it lies within the frustum defined by
// planes z=nearZ, z=farZ, and the four side planes with specified
// normals.
static inline bool frustumCull(const Vector4d& curvePoint,
                               double curveBoundingRadius,
                               double nearZ, double farZ,
                               const Vector4d viewFrustumPlaneNormals[])
{
    return (curvePoint.z() - curveBoundingRadius > nearZ ||
            curvePoint.z() + curveBoundingRadius < farZ  ||
            curvePoint.dot(viewFrustumPlaneNormals[0]) < -curveBoundingRadius ||
            curvePoint.dot(viewFrustumPlaneNormals[1]) < -curveBoundingRadius ||
            curvePoint.dot(viewFrustumPlaneNormals[2]) < -curveBoundingRadius ||
            curvePoint.dot(viewFrustumPlaneNormals[3]) < -curveBoundingRadius);
}
开发者ID:nisselarsson,项目名称:Celestia,代码行数:15,代码来源:curveplot.cpp


示例19: if

/** Add a new sample to the path. If the sample time is less than the first time,
  * it is added at the end. If it is greater than the last time, it is appended
  * to the path. The sample is ignored if it has a time in between the first and
  * last times of the path.
  */
void
CurvePlot::addSample(const CurvePlotSample& sample)
{
    bool addToBack = false;

    if (m_samples.empty() || sample.t > m_samples.back().t)
    {
        addToBack = true;
    }
    else if (sample.t < m_samples.front().t)
    {
        addToBack = false;
    }
    else
    {
        // Sample falls within range of current samples; discard it
        return;
    }

    if (addToBack)
        m_samples.push_back(sample);
    else
        m_samples.push_front(sample);

    if (m_samples.size() > 1)
    {
        // Calculate a bounding radius for this segment. No point on the curve will
        // be further from the start point than the bounding radius.
        if (addToBack)
        {
            const CurvePlotSample& lastSample = m_samples[m_samples.size() - 2];
            double dt = sample.t - lastSample.t;
            Matrix4d coeff = cubicHermiteCoefficients(zeroExtend(lastSample.position),
                                                      zeroExtend(sample.position),
                                                      zeroExtend(lastSample.velocity * dt),
                                                      zeroExtend(sample.velocity * dt));
            Vector4d extents = coeff.cwiseAbs() * Vector4d(0.0, 1.0, 1.0, 1.0);
            m_samples[m_samples.size() - 1].boundingRadius = extents.norm();
        }
        else
        {
            const CurvePlotSample& nextSample = m_samples[1];
            double dt = nextSample.t - sample.t;
            Matrix4d coeff = cubicHermiteCoefficients(zeroExtend(sample.position),
                                                      zeroExtend(nextSample.position),
                                                      zeroExtend(sample.velocity * dt),
                                                      zeroExtend(nextSample.velocity * dt));
            Vector4d extents = coeff.cwiseAbs() * Vector4d(0.0, 1.0, 1.0, 1.0);
            m_samples[1].boundingRadius = extents.norm();
        }
    }
}
开发者ID:nisselarsson,项目名称:Celestia,代码行数:57,代码来源:curveplot.cpp


示例20: quaternionFromRot

Vector4d rigidBodyDynamics::quaternionFromRot(Matrix3d& R) const{
	Vector4d q;
	double div1, div2, div3, div4;

	double numerical_limit = 1.0e-4;

	if (abs(R.determinant()-1) > numerical_limit ) {
		std::cerr << "R does not have a determinant of +1" << std::endl;
	} else {
		div1 = 0.5*sqrt(1+R(0,0)+R(1,1)+R(2,2));
		div2 = 0.5*sqrt(1+R(0,0)-R(1,1)-R(2,2));
		div3 = 0.5*sqrt(1-R(0,0)-R(1,1)+R(2,2));
		div4 = 0.5*sqrt(1-R(0,0)+R(1,1)-R(2,2));

		//if (div1 > div2 && div1 > div3 && div1 > div4) {
		if (fabs(div1) > numerical_limit) {
			q(3) = div1;
			q(0) = 0.25*(R(1,2)-R(2,1))/q(3);
			q(1) = 0.25*(R(2,0)-R(0,2))/q(3);
			q(2) = 0.25*(R(0,1)-R(1,0))/q(3);
		} else if (fabs(div2) > numerical_limit) {
		//} else if (div2 > div1 && div2 > div3 && div2 > div4) {
			q(0) = div2;
			q(1) = 0.25*(R(0,1)+R(1,0))/q(0);
			q(2) = 0.25*(R(0,2)+R(2,0))/q(0);
			q(3) = 0.25*(R(1,2)+R(2,1))/q(0);
		} else if (fabs(div3) > numerical_limit) {
		//} else if (div3 > div1 && div3 > div2 && div3 > div4) {
			q(2) = div3;
			q(0) = 0.25*(R(0,2)+R(2,0))/q(2);
			q(1) = 0.25*(R(1,2)+R(2,1))/q(2);
			q(3) = 0.25*(R(0,1)-R(1,0))/q(2);
		//} else {
		} else if (fabs(div4) > numerical_limit) {
			q(1) = div4;
			q(0) = 0.25*(R(0,1)+R(1,0))/q(1);
			q(2) = 0.25*(R(1,2)+R(2,1))/q(1);
			q(3) = 0.25*(R(2,0)-R(0,2))/q(1);
		} else {
			std::cerr << "quaternionFromRot didn't convert: [" << div1 << ", " << div2 << ", " << div3 << ", " << div4 << std::endl;
			std::cerr << "Rotation Matrix: " << R << std::endl;
		}
	}
/*
	if (q(3) < 0) {
		q *= -1;
	}
*/
	q /=q.norm();

	return q;
}
开发者ID:Gabs48,项目名称:HaloLinux_Software,代码行数:52,代码来源:rigidBodyDynamics.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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