本文整理汇总了C#中Loon.Core.Geom.Vector2f.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2f.Add方法的具体用法?C# Vector2f.Add怎么用?C# Vector2f.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loon.Core.Geom.Vector2f
的用法示例。
在下文中一共展示了Vector2f.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVelocity
public static Vector2f GetVelocity(Vector2f velocity, Vector2f force,
float mass) {
Vector2f acceleration = new Vector2f(force.GetX() / mass, force.GetY()
/ mass);
velocity.Add(acceleration);
return velocity;
}
示例2: GetVelocity
public static Vector2f GetVelocity(Vector2f velocity, List<Vector2f> forces)
{
foreach (Vector2f v in forces)
{
velocity.Add(v);
}
return velocity;
}
示例3: Intersects
public bool Intersects(Line other) {
Vector2f lineSegmentStart = new Vector2f(other.GetX1(), other.GetY1());
Vector2f lineSegmentEnd = new Vector2f(other.GetX2(), other.GetY2());
Vector2f circleCenter = new Vector2f(GetCenterX(), GetCenterY());
Vector2f closest;
Vector2f segv = lineSegmentEnd.Sub(lineSegmentStart);
Vector2f ptv = circleCenter.Sub(lineSegmentStart);
float segvLength = segv.Len();
float projvl = ptv.Dot(segv) / segvLength;
if (projvl < 0) {
closest = lineSegmentStart;
} else if (projvl > segvLength) {
closest = lineSegmentEnd;
} else {
Vector2f projv = segv.Mul(projvl / segvLength);
closest = lineSegmentStart.Add(projv);
}
bool intersects = circleCenter.Sub(closest).LengthSquared() <= GetRadius()
* GetRadius();
return intersects;
}
示例4: Sum
public static Vector2f Sum(Vector2f a, Vector2f b) {
Vector2f answer = new Vector2f(a);
return answer.Add(b);
}
示例5: Sum
public static Vector2f Sum(IList<Vector2f> summands)
{
Vector2f result = new Vector2f(0, 0);
for (IEnumerator<Vector2f> it = summands.GetEnumerator(); it.MoveNext(); )
{
Vector2f v = it.Current;
result.Add(v);
}
return result;
}