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


C# Vector3d.Equals方法代码示例

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


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

示例1: AngleInRadian

		/// <summary>
		/// Angle between 2 Vector in radian
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static double AngleInRadian(this Vector3d a, Vector3d b)
		{
			if (a.Equals(Vector3d.Zero) || b.Equals(Vector3d.Zero))
				return (double)(2 * Math.PI);

			Vector3d v = Vector3d.Cross(a, b);
			double d1 = v.Length;//v.Norm();

			double d2 = Vector3d.Dot(a, b);
			double angle = Math.Atan2(d1, d2);
			return (double)angle;
		}
开发者ID:robotsrulz,项目名称:Sardauscan,代码行数:18,代码来源:Vector3Ext.cs

示例2: ApplyDesiredVelocity

    public Vector3d ApplyDesiredVelocity(Vector3d desiredVelocity, double weightMultiplier)
    {
      if (desiredVelocity.Equals(Vector3d.Zero))
      {
        return Vector3d.Zero;
      }
      // Reynold's steering formula: steer = desired - velocity
      desiredVelocity = desiredVelocity - Velocity;

      // Steering ability can be controlled by limiting the magnitude of the steering force.
      desiredVelocity = Util.Vector.Limit(desiredVelocity, MaxForce);
      desiredVelocity = desiredVelocity * weightMultiplier;
      SteerAcceleration += desiredVelocity;
      return desiredVelocity;
    }
开发者ID:lxfschr,项目名称:Quelea,代码行数:15,代码来源:AgentType.cs

示例3: ProjectOnLine

        /// <summary>
        /// Returns the projection of a point on the line defined with two other points.
        /// When the projection is out of the segment, then the closest extremity is returned.
        /// </summary>
        /// <exception cref="ArgumentNullException">None of the arguments can be null.</exception>
        /// <exception cref="ArgumentException">P1 and P2 must be different.</exception>
        /// <param name="Pt">Point to project.</param>
        /// <param name="P1">First point of the line.</param>
        /// <param name="P2">Second point of the line.</param>
        /// <returns>The projected point if it is on the segment / The closest extremity otherwise.</returns>
        public static Vector3d ProjectOnLine(Vector3d Pt, Vector3d P1, Vector3d P2)
        {
            if (Pt == null || P1 == null || P2 == null) throw new ArgumentNullException("None of the arguments can be null.");
            if (P1.Equals(P2)) throw new ArgumentException("P1 and P2 must be different.");
            Vector3d VLine = MakeDiff(P1, P2);
            Vector3d V1Pt = MakeDiff(P1, Pt);
            Vector3d Translation = VLine * VectOR(VLine, V1Pt) / SquareNorm(VLine);
            Vector3d Projection = P1 + Translation;

            Vector3d V1Pjt = MakeDiff(P1, Projection);
            double D1 = VectOR(V1Pjt, VLine);
            if (D1 < 0) return P1;

            Vector3d V2Pjt = MakeDiff(P2, Projection);
            double D2 = VectOR(V2Pjt, VLine);
            if (D2 > 0) return P2;

            return Projection;
        }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:29,代码来源:SimGlobalRoutes.cs

示例4: ColorReflection

        public double[] ColorReflection( IMaterial material, Vector3d normal, Vector3d input, Vector3d output, ReflectionComponent comp )
        {
            if ( !(material is PhongMaterial) ) return null;

              PhongMaterial mat = (PhongMaterial)material;
              int bands = mat.Color.Length;
              double[] result = new double[ bands ];
              bool viewOut = Vector3d.Dot( output, normal ) > 0.0;
              double coef;

              if ( input.Equals( Vector3d.Zero ) )    // ambient term only..
              {
            // dim ambient light if viewer is inside
            coef = viewOut ? mat.Ka : (mat.Ka * mat.Kt);
            for ( int i = 0; i < bands; i++ )
              result[ i ] = coef * mat.Color[ i ];

            return result;
              }

              // directional light source:
              input.Normalize();
              double cosAlpha = Vector3d.Dot( input, normal );
              bool   lightOut = cosAlpha > 0.0;
              double ks = mat.Ks;
              double kd = mat.Kd;
              double kt = mat.Kt;

              Vector3d r = Vector3d.Zero;
              coef       = 1.0;
              if ( viewOut == lightOut )            // viewer and source are on the same side..
              {
            if ( (comp & ReflectionComponent.SPECULAR_REFLECTION) != 0 )
            {
              double cos2 = cosAlpha + cosAlpha;
              r = normal * cos2 - input;

              if ( !lightOut &&                   // total reflection check
               -cosAlpha <= mat.cosTotal )
            if ( (ks += kt) + kd > 1.0 )
              ks = 1.0 - kd;
            }
              }
              else                                  // opposite sides => use specular refraction
              {
            if ( (comp & ReflectionComponent.SPECULAR_REFRACTION) != 0 )
              r = Geometry.SpecularRefraction( normal, mat.n, input );
            coef = kt;
              }

              double diffuse = (comp & ReflectionComponent.DIFFUSE) == 0 ? 0.0 : coef * kd * Math.Abs( cosAlpha );
              double specular = 0.0;

              if ( r != Vector3d.Zero )
              {
            double cosBeta = Vector3d.Dot( r, output );
            if ( cosBeta > 0.0 )
              specular = coef * ks * Arith.Pow( cosBeta, mat.H );
              }

              for ( int i = 0; i < bands; i++ )
            result[i] = diffuse * mat.Color[i] + specular;

              return result;
        }
开发者ID:pepouch,项目名称:PG1Grcis,代码行数:65,代码来源:RayCastingBasic.cs


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