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


C# Vector3d.Normalize方法代码示例

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


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

示例1: ChooseRotation

 public Quaternion ChooseRotation(Vector3d r, Vector3d f, Vector3d u)
 {
     // find a reference frame that is close to the given possibly
     // non-orthogonal frame
     u = u + Vector3d.Normalize (Vector3d.Cross (f, r));
     u.Normalize ();
     r = Vector3d.Normalize (r - Vector3d.Dot (r, u) * u);
     f = Vector3d.Normalize (f - Vector3d.Dot (f, u) * u);
     f = Vector3d.Normalize (f + Vector3d.Cross (r, u));
     return Quaternion.LookRotation (f, u);
 }
开发者ID:Goldenpsp,项目名称:Extraplanetary-Launchpads,代码行数:11,代码来源:SurveyStation.cs

示例2: AngleAboutAxis

		static double AngleAboutAxis(Vector3d v1, Vector3d v2, Vector3d axis)
		{
			axis.Normalize();

			v1 = (v1 - Vector3d.Dot(axis, v1) * axis).normalized;
			v2 = (v2 - Vector3d.Dot(axis, v2) * axis).normalized;

			return Math.Atan2(Vector3d.Dot(axis, Vector3d.Cross(v1, v2)), Vector3d.Dot(v1, v2));
		}
开发者ID:CliftonMarien,项目名称:MechJeb2,代码行数:9,代码来源:TransferCalculator.cs

示例3: SetNeededVelocity

 void SetNeededVelocity(Vector3d nV)
 {
     needed_velocity = CFG.MaxNavSpeed;
     if(CFG.MaxNavSpeed.Equals(0))
         VSL.HorizontalSpeed.SetNeeded(Vector3d.zero);
     else if(nV.sqrMagnitude > 0.1 && CFG.MaxNavSpeed > 0)
     {
         nV.Normalize();
         VSL.HorizontalSpeed.SetNeeded(nV*CFG.MaxNavSpeed);
         BRC.UpdateBearing((float)VSL.Physics.Bearing(nV));
     }
     else VSL.HorizontalSpeed.SetNeeded(BRC.ForwardDirection*CFG.MaxNavSpeed);
 }
开发者ID:Kerbas-ad-astra,项目名称:ThrottleControlledAvionics,代码行数:13,代码来源:CruiseControl.cs

示例4: IntersectConePlane

		// Compute the two intersecting lines of a cone with a corner at (0,0,0) with a plane passing by (0,0,0)
		// If there is no intersection, return the line on the plane closest to the cone (assumes cone_angle > pi/2)
		static void IntersectConePlane(Vector3d cone_direction, double cone_angle, Vector3d plane_normal, out Vector3d intersect_1, out Vector3d intersect_2)
		{
			intersect_1 = Vector3d.zero;
			intersect_2 = Vector3d.zero;

			cone_direction.Normalize();
			plane_normal.Normalize();

			// Change the frame of reference:
			// x = cone_direction
			// y = plane_normal projected on the plane normal to cone_direction
			// z = x * y
			Vector3d x = cone_direction;
			Vector3d z = Vector3d.Cross(x, plane_normal).normalized;
			Vector3d y = Vector3d.Cross(z, x);

			// transition matrix from the temporary frame to the global frame
			Matrix3x3f M_i_tmp = new Matrix3x3f();
			for (int i = 0; i < 3; i++)
			{
				M_i_tmp[i, 0] = (float)x[i];
				M_i_tmp[i, 1] = (float)y[i];
				M_i_tmp[i, 2] = (float)z[i];
			}

			Vector3d n = M_i_tmp.transpose() * plane_normal;
			double cos_phi = -n.x / (n.y * Math.Tan(cone_angle));

			if (Math.Abs(cos_phi) <= 1.0f)
			{
				intersect_1.x = Math.Cos(cone_angle);
				intersect_1.y = Math.Sin(cone_angle) * cos_phi;
				intersect_1.z = Math.Sin(cone_angle) * Math.Sqrt(1 - cos_phi * cos_phi);
			}
			else
			{
				intersect_1.x = -n.y;
				intersect_1.y = n.x;
				intersect_1.z = 0.0;
			}

			intersect_2.x = intersect_1.x;
			intersect_2.y = intersect_1.y;
			intersect_2.z = -intersect_1.z;

			intersect_1 = M_i_tmp * intersect_1;
			intersect_2 = M_i_tmp * intersect_2;
		}
开发者ID:CliftonMarien,项目名称:MechJeb2,代码行数:50,代码来源:TransferCalculator.cs


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