本文整理汇总了C#中Box2D.Common.Vec2.MulLocal方法的典型用法代码示例。如果您正苦于以下问题:C# Vec2.MulLocal方法的具体用法?C# Vec2.MulLocal怎么用?C# Vec2.MulLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box2D.Common.Vec2
的用法示例。
在下文中一共展示了Vec2.MulLocal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeCentroidToOut
public void ComputeCentroidToOut(Vec2[] vs, int count, Vec2 result)
{
Debug.Assert(count >= 3);
result.Set(0.0f, 0.0f);
float area = 0.0f;
// pRef is the reference point for forming triangles.
// It's location doesn't change the result (except for rounding error).
Vec2 pRef = pool1;
pRef.SetZero();
Vec2 e1 = pool2;
Vec2 e2 = pool3;
const float inv3 = 1.0f / 3.0f;
for (int i = 0; i < count; ++i)
{
// Triangle vertices.
Vec2 p1 = pRef;
Vec2 p2 = vs[i];
Vec2 p3 = i + 1 < count ? vs[i + 1] : vs[0];
e1.Set(p2).SubLocal(p1);
e2.Set(p3).SubLocal(p1);
float D = Vec2.Cross(e1, e2);
float triangleArea = 0.5f * D;
area += triangleArea;
// Area weighted centroid
e1.Set(p1).AddLocal(p2).AddLocal(p3).MulLocal(triangleArea * inv3);
result.AddLocal(e1);
}
// Centroid
Debug.Assert(area > Settings.EPSILON);
result.MulLocal(1.0f / area);
}
示例2: GetReactionForce
/// <seealso cref="Joint.GetReactionForce(float, Vec2)"></seealso>
public override void GetReactionForce(float inv_dt, Vec2 argOut)
{
argOut.Set(m_impulse.X, m_impulse.Y);
argOut.MulLocal(inv_dt);
}