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


C++ Cylinder类代码示例

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


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

示例1: drawLimb

void Frog::drawLimb(float * begin, float * length) {
   Sphere joint;
   Cylinder limb;

   float end[3] = {begin[0] + length[0], begin[1] + length[1], begin[2] + length[2]};
   float mag = sqrt(length[0]*length[0] + length[1]*length[1] + length[2]*length[2]);
   float norm[3] = {length[0]/mag, length[1]/mag, length[2]/mag};
   float cross[3] = {norm[2], 0, -1*norm[0]};
   float angle = acos(norm[1]) * 180 / 3.14159f;

   glColor3f(color[0], color[1], color[2]);
   glPushMatrix();
   glTranslatef(begin[0], begin[1], begin[2]);
   glRotatef(angle, cross[0], cross[1], cross[2]);
   glScalef(.1, mag, .1);
   limb.draw();
   glPopMatrix();

   glColor3f(color[0], color[1], color[2]);
   glPushMatrix();
   glTranslatef(begin[0], begin[1], begin[2]);
   glScalef(.1, .1, .1);
   joint.draw();
   glPopMatrix();

   glPushMatrix();
   glTranslatef(end[0], end[1], end[2]);
   glScalef(.1, .1, .1);
   joint.draw();
   glPopMatrix();
}
开发者ID:regality,项目名称:opengl-turret,代码行数:31,代码来源:Frog.cpp

示例2: GraphicsCallback

//
// The Graphics Callback runs in the application "client thread" (qhStart) and sets the transformations
// for the Red Sphere and Green Line of the Cursor. Also, this callback sets the WorldToDevice matrix
// for use in the ServoLoopCallback.
//
void GraphicsCallback(void)
{
    QHGLUT* localDisplayObject = QHGLUT::searchWindow("Coulomb Field Demo");//Get a Pointer to the display object
    Cursor* localDeviceCursor = Cursor::searchCursor("devCursor");//Get a pointer to the cursor
    Cylinder* localForceArrow = Cylinder::searchCylinder("forceArrow");//get a pointer to the cylinder
    Cone* localForceArrowTip = Cone::searchCone("forceArrowTip");//get a pointer to the cylinder
	Sphere* localCursorSphere = Sphere::searchSphere("cursorSphere");//get a pointer top the Sphere

	if( localDisplayObject == NULL || localDeviceCursor == NULL || localForceArrow == NULL || localCursorSphere == NULL)
		return;

	hduMatrix CylinderTransform;//Transformation for the Cylinder. This transform makes it point toward the Model
	hduVector3Dd localCursorPosition;
	hduVector3Dd DirectionVecX;
	hduVector3Dd PointOnPlane;
	hduVector3Dd DirectionVecY;
	hduVector3Dd DirectionVecZ;

	//Compute the world to device transform
    WorldToDevice = localDisplayObject->getWorldToDeviceTransform();

	// Set transform for Red Sphere
    localCursorPosition = localDeviceCursor->getPosition();//Get the local cursor position in World Space
	
	hduVector3Dd localCursorSpherePos = localCursorSphere->getTranslation();
	localCursorSphere->setTranslation(-localCursorSpherePos);
	localCursorSphere->setTranslation(localCursorPosition);//Set the position of the Sphere the same as the cursor
    
	////////////////////////////////////////////////////////////////////////////////////////////
	//Code to calculate the transform of the green cylinder to point along the force direction
	////////////////////////////////////////////////////////////////////////////////////////////
	hduMatrix DeviceToWorld = WorldToDevice.getInverse();
	HDdouble ForceMagnitude = forceVec.magnitude();
	DeviceToWorld[3][0] = 0.0;			   
	DeviceToWorld[3][1] = 0.0;			   
	DeviceToWorld[3][2] = 0.0;
	DirectionVecX = forceVec * DeviceToWorld;
    DirectionVecX.normalize();
    PointOnPlane.set(0.0,0.0,(DirectionVecX[0]*localCursorPosition[0] + DirectionVecX[1]*localCursorPosition[1] + DirectionVecX[2]*localCursorPosition[2])/DirectionVecX[2]);
    DirectionVecY = PointOnPlane  - localCursorPosition;
    DirectionVecY.normalize();

    DirectionVecZ = -DirectionVecY.crossProduct(DirectionVecX);

    CylinderTransform[0][0] = DirectionVecZ[0]; CylinderTransform[0][1] = DirectionVecZ[1]; CylinderTransform[0][2] = DirectionVecZ[2]; CylinderTransform[0][3] = 0.0;
    CylinderTransform[1][0] = DirectionVecX[0]; CylinderTransform[1][1] = DirectionVecX[1]; CylinderTransform[1][2] = DirectionVecX[2]; CylinderTransform[1][3] = 0.0;
    CylinderTransform[2][0] = DirectionVecY[0]; CylinderTransform[2][1] = DirectionVecY[1]; CylinderTransform[2][2] = DirectionVecY[2]; CylinderTransform[2][3] = 0.0;
    CylinderTransform[3][0] = 0.0             ; CylinderTransform[3][1] = 0.0             ; CylinderTransform[3][2] = 0.0             ; CylinderTransform[3][3] = 1.0;
    CylinderTransform = CylinderTransform * hduMatrix::createTranslation(localCursorPosition[0], localCursorPosition[1], localCursorPosition[2]);
    
    localForceArrow->update(chargeRadius/4, ForceMagnitude*50, 15);
    localForceArrow->setTranslation(localCursorPosition);
    localForceArrow->setTransform(CylinderTransform);

     hduMatrix ConeTransform = CylinderTransform * hduMatrix::createTranslation(DirectionVecX[0]
     * ForceMagnitude*50,DirectionVecX[1] * ForceMagnitude*50,DirectionVecX[2] * ForceMagnitude*50 );

    localForceArrowTip->setTransform(ConeTransform);
	/////////////////////////////////////////////
}
开发者ID:danepowell,项目名称:openhaptics,代码行数:65,代码来源:main.cpp

示例3: getParent

void DepotChest::postAddNotification(Thing* thing, const Cylinder* oldParent, int32_t index, cylinderlink_t)
{
	Cylinder* parent = getParent();
	if (parent != nullptr) {
		parent->postAddNotification(thing, oldParent, index, LINK_PARENT);
	}
}
开发者ID:Caduceus,项目名称:DecapitatedSoul,代码行数:7,代码来源:depotchest.cpp

示例4: switch

void Parser::parseCylinder(Scene* scene, TransformNode* transform, const Material& mat)
{
  Cylinder* cylinder = 0;
  Material* newMat = 0;

  _tokenizer.Read( CYLINDER );
  _tokenizer.Read( LBRACE );

  for( ;; )
  {
    const Token* t = _tokenizer.Peek();

    switch( t->kind() )
    {
      case MATERIAL:
        delete newMat;
        newMat = parseMaterialExpression( scene, mat );
        break;
      case NAME:
        parseIdentExpression();
        break;
      case RBRACE:
         _tokenizer.Read( RBRACE );
        cylinder = new Cylinder(scene, newMat ? newMat : new Material(mat));
        cylinder->setTransform( transform );
        scene->add( cylinder );
        return;
      default:
        throw SyntaxErrorException( "Expected: cylinder attributes", _tokenizer );
    }
  }

}
开发者ID:easchner,项目名称:cs354,代码行数:33,代码来源:Parser.cpp

示例5: intersect

int Line::intersect(std::list<Kernel::V3D> &PntOut, const Cylinder &Cyl) const
/**
For the line that intersects the cylinder generate
add the point to the VecOut, return number of points
added. It does not check the points for validity.

@param PntOut :: Vector of points found by the line/cylinder intersection
@param Cyl :: Cylinder to intersect line with
@return Number of points found by intersection
*/
{
    const Kernel::V3D Cent = Cyl.getCentre();
    const Kernel::V3D Ax = Origin - Cent;
    const Kernel::V3D N = Cyl.getNormal();
    const double R = Cyl.getRadius();
    const double vDn = N.scalar_prod(Direct);
    const double vDA = N.scalar_prod(Ax);
    // First solve the equation of intersection
    double C[3];
    C[0] = 1.0 - (vDn * vDn);
    C[1] = 2.0 * (Ax.scalar_prod(Direct) - vDA * vDn);
    C[2] = Ax.scalar_prod(Ax) - (R * R + vDA * vDA);
    std::pair<std::complex<double>, std::complex<double>> SQ;
    const int ix = solveQuadratic(C, SQ);
    // This takes the centre displacement into account:
    return lambdaPair(ix, SQ, PntOut);
}
开发者ID:tyronerees,项目名称:mantid,代码行数:27,代码来源:Line.cpp

示例6: getParent

void Reward::postRemoveNotification(Thing* thing, const Cylinder* newParent, int32_t index, cylinderlink_t)
{
	Cylinder* parent = getParent();
	if (parent != nullptr) {
		parent->postRemoveNotification(thing, newParent, index, LINK_PARENT);
	}
}
开发者ID:Caduceus,项目名称:DecapitatedSoul,代码行数:7,代码来源:reward.cpp

示例7: Assembly

Assembly *GraspGLObjects::CreateVisualTool( double magnifier ) {

	Assembly *tool = new Assembly();

	// Create a set of 'fingers', each of which is a 'capsule' composed of a tube with rounded caps.
	static int n_fingers = target_balls-1;

	double radius = finger_ball_radius * magnifier;
	double length = finger_length * magnifier;

	double spacing = radius * 2.0;

	for ( int trg = - n_fingers; trg <= n_fingers ; trg++ ){


		// Each finger is a 'capsule' composed of a cylinder that is capped on each end with a sphere.
		Assembly *finger = new Assembly();
		Sphere *sphere = new Sphere( radius );
		sphere->SetPosition( 0.0, 0.0, 0.0 );
		finger->AddComponent( sphere );
		Cylinder *cylinder = new Cylinder( radius, radius, length );
		cylinder->SetPosition( 0.0, 0.0, - length / 2 );
		finger->AddComponent( cylinder );
		sphere = new Sphere( radius );
		sphere->SetPosition( 0.0, 0.0, - length );
		finger->AddComponent( sphere );

		// Space the fingers vertically.
		finger->SetPosition( 0.0, spacing * trg, 0.0 );
		tool->AddComponent( finger );
	}
	SetHandColor( tool, true );

	return tool;
}
开发者ID:PsyPhy,项目名称:GRASPonISS,代码行数:35,代码来源:GraspGLObjects.cpp

示例8: ClosestPointCylinder

Vector ClosestPointCylinder ( Vector const & V, Cylinder const & C )
{
	Vector delta = V - C.getBase();

	delta.y = 0.0f;

	real dist = delta.magnitude();

	Vector point = V;

	// clamp the x-z coords of the point so they're inside the tube

	IGNORE_RETURN( delta.normalize() );
	delta *= std::min( C.getRadius(), dist );
	
	point = C.getBase() + delta;

	// and clamp the y coord so it's inside also

	real min = C.getBase().y;
	real max = min + C.getHeight();

	point.y = clamp( min, V.y, max );

	return point;
}
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:26,代码来源:Distance3d.cpp

示例9: random_position

inline typename Cylinder<T>::position_type
random_position(Cylinder<T> const& shape, Trng& rng)
{
    // -1 < rng() < 1. See for example CylindricalSurface.hpp.
    return add(shape.position(),
               multiply(shape.unit_z(), rng() * shape.half_length()));
}
开发者ID:YetAnotherTomek,项目名称:egfrd,代码行数:7,代码来源:Cylinder.hpp

示例10: getParent

void DepotChest::postRemoveNotification(Thing* thing, const Cylinder* newParent, int32_t index, bool isCompleteRemoval, cylinderlink_t)
{
	Cylinder* parent = getParent();
	if (parent != nullptr) {
		parent->postRemoveNotification(thing, newParent, index, isCompleteRemoval, LINK_PARENT);
	}
}
开发者ID:A-Dirty-Rag,项目名称:forgottenserver,代码行数:7,代码来源:depotchest.cpp

示例11: EncloseABox

AxialBox EncloseABox ( Cylinder const & C )
{
	Vector center = C.getCenter();

	Vector extent( C.getExtentX(), C.getExtentY(), C.getExtentZ() );

	return AxialBox(center-extent,center+extent);
}
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:8,代码来源:Containment3d.cpp

示例12: CylinderPrimitiveShape

PrimitiveShape *CylinderPrimitiveShapeConstructor::Deserialize(
    std::istream *i, bool binary) const
{
    Cylinder cylinder;
    cylinder.Init(binary, i);
    CylinderPrimitiveShape *shape = new CylinderPrimitiveShape(cylinder);
    return shape;
}
开发者ID:ihmcrobotics,项目名称:ihmc-open-robotics-software,代码行数:8,代码来源:CylinderPrimitiveShapeConstructor.cpp

示例13: EncloseSphere

Sphere EncloseSphere ( Cylinder const & shape )
{
	float x = shape.getExtentX();
	float y = shape.getExtentY();

    float radius = sqrt( x*x + y*y );

    return Sphere( shape.getCenter(), radius );
}
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:9,代码来源:Containment3d.cpp

示例14: TestCylinderABox

ContainmentResult     TestCylinderABox ( Cylinder const & C,
									 	 AxialBox const & B )
{
	ContainmentResult test2d = Containment2d::TestCircleABox(C.getBaseCircle(),B);

	ContainmentResult testY = Containment1d::TestRangeRange( C.getRangeY(), B.getRangeY() );

	return Containment::ComposeAxisTests( test2d, testY );
}
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:9,代码来源:Containment3d.cpp

示例15: getTopParent

Tile* Item::getTile()
{
	Cylinder* cylinder = getTopParent();
	//get root cylinder
	if (cylinder->getParent()) {
		cylinder = cylinder->getParent();
	}
	return dynamic_cast<Tile*>(cylinder);
}
开发者ID:HeberPcL,项目名称:forgottenserver,代码行数:9,代码来源:item.cpp


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