本文整理汇总了C#中System.Vector2.DotProduct方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.DotProduct方法的具体用法?C# Vector2.DotProduct怎么用?C# Vector2.DotProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector2
的用法示例。
在下文中一共展示了Vector2.DotProduct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateGeometry
/// <summary>
///
/// </summary>
/// <param name="timeSinceLastFrame"></param>
public void UpdateGeometry(float timeSinceLastFrame)
{
// Calculate wind offset
Vector2 cameraDirection = new Vector2(_vclouds.Camera.DerivedDirection.x, _vclouds.Camera.DerivedDirection.z);
float offset = -cameraDirection.DotProduct(_vclouds.WindDirectionAsVector2) * _vclouds.WindSpeed * timeSinceLastFrame;
_worldOffset += _vclouds.WindDirectionAsVector2 * _vclouds.WindSpeed * timeSinceLastFrame;
// Calculate camera offset
Vector2 cameraOffset = new Vector2(_vclouds.Camera.DerivedPosition.x - _lastCameraPosition.x, _vclouds.Camera.DerivedPosition.z - _lastCameraPosition.z);
offset -= cameraOffset.DotProduct(cameraDirection);
_worldOffset += cameraOffset;
for (int k = 0; k < _numberOfBlocks; k++)
{
_geometryBlocks[k].Update(offset);
_geometryBlocks[k].WorldOffset = _worldOffset;
}
}
示例2: angleBetween
// *
// * Equivalent of Ogre::Vector3::angleBetween, applied to Ogre::Vector2
//
public static Radian angleBetween(Vector2 v1, Vector2 v2) {
float lenProduct = v1.Length * v2.Length;
// Divide by zero check
if (lenProduct < 1e-6f)
lenProduct = 1e-6f;
float f = v1.DotProduct(v2) / lenProduct;
f = Math_Clamp(f, -1.0f, 1.0f);
return Math.ACos(f);
}