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


C++ Vec::projectOnAxis方法代码示例

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


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

示例1: constrainTranslation

/*! Depending on translationConstraintType(), constrain \p translation to be along an axis or
  limited to a plane defined in the world coordinate system by
  translationConstraintDirection(). */
void WorldConstraint::constrainTranslation(Vec& translation, Frame* const frame)
{
  Vec proj;
  switch (translationConstraintType())
    {
    case AxisPlaneConstraint::FREE:
      break;
    case AxisPlaneConstraint::PLANE:
      if (frame->referenceFrame())
	{
	  proj = frame->referenceFrame()->transformOf(translationConstraintDirection());
	  translation.projectOnPlane(proj);
	}
      else
	translation.projectOnPlane(translationConstraintDirection());
      break;
    case AxisPlaneConstraint::AXIS:
      if (frame->referenceFrame())
	{
	  proj = frame->referenceFrame()->transformOf(translationConstraintDirection());
	  translation.projectOnAxis(proj);
	}
      else
	translation.projectOnAxis(translationConstraintDirection());
      break;
    case AxisPlaneConstraint::FORBIDDEN:
      translation = Vec(0.0, 0.0, 0.0);
      break;
    }
}
开发者ID:SoumyajitG,项目名称:VolRoverN,代码行数:33,代码来源:constraint.cpp

示例2: projectOnLine

/*! Translates the Frame so that its position() lies on the line defined by \p origin and \p
  direction (defined in the world coordinate system).

Simply uses an orthogonal projection. \p direction does not need to be normalized. */
void Frame::projectOnLine(const Vec& origin, const Vec& direction)
{
	// If you are trying to find a bug here, because of memory problems, you waste your time.
	// This is a bug in the gcc 3.3 compiler. Compile the library in debug mode and test.
	// Uncommenting this line also seems to solve the problem. Horrible.
	// cout << "position = " << position() << endl;
	// If you found a problem or are using a different compiler, please let me know.
	const Vec shift = origin - position();
	Vec proj = shift;
	proj.projectOnAxis(direction);
	translate(shift-proj);
}
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:16,代码来源:frame.cpp

示例3: constrainRotation

	virtual void constrainRotation(Quaternion& q, Frame * const fr)
	{
		const Vec up = fr->transformOf(Vec(0.0, 0.0, 1.0));
		Vec axis = q.axis();
		float angle = 2.0*acos(q[3]);
		if (fabs(axis*up) > fabs(axis.x))
			axis.projectOnAxis(up);
		else
		{
			angle = (axis.x > 0.0) ? angle : -angle;
			axis.setValue(fabs(axis.x), 0.0, 0.0);
			const float currentAngle = asin(fr->inverseTransformOf(Vec(0.0, 0.0, -1.0)).z);
			if (currentAngle + angle > -0.2)
				angle = -0.2 - currentAngle; // Not too low
			if (currentAngle + angle < -M_PI/2.0)
				angle = -M_PI/2.0 - currentAngle; // Do not pass on the other side
		}
		q = Quaternion(axis, angle);
	}
开发者ID:Sabouh,项目名称:CurvRecProject,代码行数:19,代码来源:agoraViewer.cpp

示例4: constrainRotation

/*! When rotationConstraintType() is AxisPlaneConstraint::AXIS, constrain \p rotation to be a rotation
  around an axis whose direction is defined in the camera() coordinate system by
  rotationConstraintDirection(). */
void CameraConstraint::constrainRotation(Quaternion& rotation, Frame* const frame)
{
  switch (rotationConstraintType())
    {
    case AxisPlaneConstraint::FREE:
      break;
    case AxisPlaneConstraint::PLANE:
      break;
    case AxisPlaneConstraint::AXIS:
      {
	Vec axis = frame->transformOf(camera()->frame()->inverseTransformOf(rotationConstraintDirection()));
	Vec quat = Vec(rotation[0], rotation[1], rotation[2]);
	quat.projectOnAxis(axis);
	rotation = Quaternion(quat, 2.0*acos(rotation[3]));
      }
      break;
    case AxisPlaneConstraint::FORBIDDEN:
      rotation = Quaternion(); // identity
      break;
    }
}
开发者ID:SoumyajitG,项目名称:VolRoverN,代码行数:24,代码来源:constraint.cpp

示例5: constrainTranslation

void ManipulatedFrameSetConstraint::constrainTranslation(Vec& translation, Frame* const) 
{
   // Filter the translation
   switch (translationConstraintType()) {
      case AXIS:
         translation.projectOnAxis(translationConstraintDirection());
         break;

      case PLANE:
         translation.projectOnPlane(translationConstraintDirection());
         break;

     default:
         break;
   }

   QList<GLObject*>::iterator iter, end;
   for (iter = m_primitives.begin(), end = m_primitives.end(); iter != end; ++iter) {
       (*iter)->m_frame.translate(translation);
   }
}
开发者ID:baneofblabs,项目名称:IQmol,代码行数:21,代码来源:ManipulatedFrameSetConstraint.C

示例6: constrainRotation

// Contrainte de rotation de la caméra
void MyConstraint::constrainRotation(Quaternion &rotation, Frame *const frame)
{
    Vec axis = rotation.axis();
    double angle = rotation.angle();

    //printf("[%lf %lf] \n", frame->orientation().angle(), rotation.angle());
    //printf("/%lf %lf %lf\\\n", frame->orientation().axis().x, frame->orientation().axis().y, frame->orientation().axis().z) ;
    // printf("<%lf %lf %lf>\n", frame->position().x, frame->position().y, frame->position().z);
    //printf("|%lf %lf %lf|\n", rotation.axis().x, rotation.axis().y, rotation.axis().z);
    //axis.z = 0;

    /*
    if ((frame->orientation().angle() + angle) > 3.14/2.0)
    {
        rotation.setAxisAngle(rotation.axis(), -rotation.angle());
        //frame->rotate(Quaternion(frame->orientation().axis(),0.0));
    }
    */
    /*
    Vec quat = Vec(rotation[0], rotation[1], rotation[3]);
    quat.projectOnAxis(axis);

    if (frame->position().y <= 0.3)
    angle = -angle;

    rotation = Quaternion(quat, angle);
    */

    Vec axisC (0.0,1.0,0.0);

    axis = frame->transformOf(camera()->frame()->inverseTransformOf(axisC));
    Vec quat = Vec(rotation[0], rotation[1], rotation[2]);
    quat.projectOnAxis(axis);
    rotation = Quaternion(quat, 2.0*acos(rotation[3]));
    // printf("|%lf %lf %lf|\n", rotation.axis().x, rotation.axis().y, rotation.axis().z);
}
开发者ID:axlefranc,项目名称:HomeCreator3D,代码行数:37,代码来源:myconstraint.cpp


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