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


C# System.Numerics.Vector3.TruncateLength方法代码示例

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


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

示例1: ConvertLinearToCurvedSpaceGlobal

		// QQQ new utility 2-25-04 -- may replace inline code elsewhere
		//
		// Given a location in this vehicle's linear local space, convert it into
		// the curved space defined by the vehicle's current path curvature.  For
		// example, forward() gets mapped on a point 1 unit along the circle
		// centered on the current center of curvature and passing through the
		// vehicle's position().
		//
	    private Vector3 ConvertLinearToCurvedSpaceGlobal(Vector3 linear)
		{
			Vector3 trimmedLinear = linear.TruncateLength(MaxForce);

			// ---------- this block imported from steerToAvoidObstaclesOnMap
			float signedRadius = 1 / (NonZeroCurvatureQQQ() /*QQQ*/ * 1);
			Vector3 localCenterOfCurvature = Side * signedRadius;
			Vector3 center = Position + localCenterOfCurvature;
			float sign = signedRadius < 0 ? 1.0f : -1.0f;
			float arcLength = Vector3.Dot(trimmedLinear, Forward);
			//
			float arcRadius = signedRadius * -sign;
			const float TWO_PI = 2 * (float)Math.PI;
			float circumference = TWO_PI * arcRadius;
			float arcAngle = TWO_PI * arcLength / circumference;
			// ---------- this block imported from steerToAvoidObstaclesOnMap

			// ---------- this block imported from scanObstacleMap
			// vector from center of curvature to position of vehicle
			Vector3 initialSpoke = Position - center;
			// rotate by signed arc angle
			Vector3 spoke = initialSpoke.RotateAboutGlobalY(arcAngle * sign);
			// ---------- this block imported from scanObstacleMap

	        Vector3 fromCenter = Vector3.Normalize(-localCenterOfCurvature);
			float dRadius = Vector3.Dot(trimmedLinear, fromCenter);
			float radiusChangeFactor = (dRadius + arcRadius) / arcRadius;
			Vector3 resultLocation = center + (spoke * radiusChangeFactor);
			{
				Vector3 center2 = Position + localCenterOfCurvature;
				AnnotationXZArc(Position, center2, Speed * sign * -3, 20, Color.White);
			}
			// return the vector from vehicle position to the coimputed location
			// of the curved image of the original linear offset
			return resultLocation - Position;
		}
开发者ID:cupsster,项目名称:SharpSteer2,代码行数:44,代码来源:MapDriver.cs


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