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


C++ Cylinder::getBase方法代码示例

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


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

示例1: 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

示例2: TestCylinderCylinder

ContainmentResult  TestCylinderCylinder ( Cylinder const & A,
                                          Cylinder const & B )
{
	Vector delta = B.getBase() - A.getBase();
	delta.y = 0;

	real dist = delta.magnitude();

	Range AD( dist - A.getRadius(), dist + A.getRadius() );
	Range BD( -B.getRadius(), B.getRadius() );

	ContainmentResult hTest = Containment1d::TestRangeRange( AD, BD );
	ContainmentResult vTest = Containment1d::TestRangeRange( A.getRangeY(), B.getRangeY() );

	// ----------

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

示例3: ComposeAxisTests

ContainmentResult  TestPointCylinder    ( Vector const & V,
                                          Cylinder const & C )
{
	Vector delta = V - C.getBase();
	delta.y = 0;

	real dist = delta.magnitude();
	real radius = C.getRadius();

	ContainmentResult rTest = Containment1d::TestFloatLess(dist,radius);
	ContainmentResult vTest = Containment1d::TestFloatRange(V.y, C.getRangeY());

	// ----------

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

示例4: TestYLineCylinder

bool TestYLineCylinder ( Vector const & V, Cylinder const & C )
{
	return Distance2d::Distance2PointPoint(V,C.getBase()) < sqr(C.getRadius());
}
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:4,代码来源:Overlap3d.cpp

示例5: TestSphereCylinder

ContainmentResult  TestSphereCylinder ( Sphere const & S,
									    Cylinder const & C )
{
	Vector delta = C.getBase() - S.getCenter();
	delta.y = 0;

	real dist = delta.magnitude();

	Range SD( dist - S.getRadius(), dist + S.getRadius() );

	Range CD( -C.getRadius(), C.getRadius() );

	ContainmentResult hTest = Containment1d::TestRangeRange( SD, CD );
	ContainmentResult hTest2 = Containment1d::TestFloatRange( dist, CD );

	ContainmentResult vTest = Containment1d::TestRangeRange( S.getRangeY(), C.getRangeY() );
	ContainmentResult cTest = Containment1d::TestFloatRange( S.getCenter().y, C.getRangeY() );

	// ----------

	if(hTest == CR_Outside)
	{
		// Sphere can't possibly touch the cylinder

		return CR_Outside;
	}
	else if((hTest == CR_TouchingOutside) || (hTest == CR_Boundary))
	{
		// Sphere is touching the outside of the cylinder's tube if its
		// center is inside the vertical range of the cylinder

		if((cTest == CR_Inside) || (cTest == CR_Boundary))
		{
			return CR_TouchingOutside;
		}
		else
		{
			return CR_Outside;
		}
	}
	else if((hTest == CR_Inside) || (hTest == CR_TouchingInside))
	{
		// Sphere is in the tube of the cylinder. It touches the cylinder
		// if its vertical range touches the vertical range of the cylinder

		return Containment::ComposeAxisTests(hTest,vTest);
	}
	else
	{
		// hTest == CR_Overlap

		if(vTest == CR_Outside)
		{
			return CR_Outside;
		}
		else if((vTest == CR_Inside) || (vTest == CR_TouchingInside))
		{
			return CR_Overlap;
		}
		else if (vTest == CR_Boundary)
		{
			// This really shouldn't be happening
			return CR_Boundary;
		}
		else if (vTest == CR_TouchingOutside)
		{
			if(hTest2 == CR_Inside)
			{
				// Sphere is touching a cap of the cylinder
				return CR_TouchingOutside;
			}
			else if(hTest2 == CR_Boundary)
			{
				// Sphere is touching the edge of the cap of the cylinder
				return CR_TouchingOutside;
			}
			else
			{
				// Sphere isn't touching the cap
				return CR_Outside;
			}
		}
		else
		{
			// vTest == CR_Overlap

			if((cTest == CR_Inside) || (cTest == CR_Boundary))
			{
				// The ranges overlap vertically and horizontally, and the center of
				// the sphere is inside the vertical range - the sphere overlaps the
				// cylinder

				return CR_Overlap;
			}
			else
			{
				// The sphere is inside both ranges, but its center is outside both
				// ranges. The sphere overlaps the cylinder if the closest point
				// on the cylinder is inside the sphere.

//.........这里部分代码省略.........
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:101,代码来源:Containment3d.cpp


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