本文整理汇总了C#中Vector2F类的典型用法代码示例。如果您正苦于以下问题:C# Vector2F类的具体用法?C# Vector2F怎么用?C# Vector2F使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector2F类属于命名空间,在下文中一共展示了Vector2F类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImageBillboard
/// <summary>
/// Initializes a new instance of the <see cref="ImageBillboard"/> class.
/// </summary>
/// <param name="texture">The texture.</param>
public ImageBillboard(PackedTexture texture)
{
Texture = texture;
Size = new Vector2F(1, 1);
_alphaTest = 0;
_blendMode = 1;
}
示例2: OnArrange
/// <inheritdoc/>
protected override void OnArrange(Vector2F position, Vector2F size)
{
// Get extreme positions of arrange area.
float left = position.X;
float top = position.Y;
float right = left + size.X;
float bottom = top + size.Y;
if (Orientation == DigitalRune.Game.UI.Orientation.Horizontal)
{
// ----- Horizontal:
// Each child gets its desired width or the rest of the available space.
foreach (var child in VisualChildren)
{
float availableSize = Math.Max(0.0f, right - left);
float sizeX = Math.Min(availableSize, child.DesiredWidth);
float sizeY = size.Y;
child.Arrange(new Vector2F(left, top), new Vector2F(sizeX, sizeY));
left += sizeX + 10;
}
}
else
{
// ----- Vertical
// Each child gets its desired height or the rest of the available space.
foreach (var child in VisualChildren)
{
float sizeX = size.X;
float availableSize = Math.Max(0.0f, bottom - top);
float sizeY = Math.Min(availableSize, child.DesiredHeight);
child.Arrange(new Vector2F(left, top), new Vector2F(sizeX, sizeY));
top += sizeY + 10;
}
}
}
示例3: Intersects
/// <summary>
/// Checks whether the specified line segment intersects the passed one.
/// </summary>
/// <remarks>
/// See http://www.wyrmtale.com/blog/2013/115/2d-line-intersection-in-c for details.
/// </remarks>
/// <param name="first">Line segment to check.</param>
/// <param name="second">Line segment to check.</param>
/// <param name="intersectionPoint">Intersection point, if found.</param>
/// <returns>
/// <c>true</c>, if both line segments intersect each other, and <c>false</c> otherwise.
/// </returns>
public static bool Intersects(this LineSegment2F first, LineSegment2F second, out Vector2F intersectionPoint)
{
// Get A,B,C of first line - points ps1 to pe1.
var a1 = first.Q.Y - first.P.Y;
var b1 = first.P.X - first.Q.X;
var c1 = a1 * first.P.X + b1 * first.P.Y;
// Get A,B,C of second line - points ps2 to pe2.
var a2 = second.Q.Y - second.P.Y;
var b2 = second.P.X - second.Q.X;
var c2 = a2 * second.P.X + b2 * second.P.Y;
// Get delta and check if the lines are parallel.
var delta = a1 * b2 - a2 * b1;
if (Math.Abs(delta) < float.Epsilon)
{
intersectionPoint = Vector2F.Zero;
return false;
}
// Return intersection point.
intersectionPoint = new Vector2F((b2 * c1 - b1 * c2) / delta, (a1 * c2 - a2 * c1) / delta);
return first.Contains(intersectionPoint) && second.Contains(intersectionPoint);
}
示例4: Addition
public void Addition()
{
Vector2F a = new Vector2F(1.0f, 2.0f);
Vector2F b = new Vector2F(2.0f, 3.0f);
Vector2F c = Vector2F.Add(a, b);
Assert.AreEqual(new Vector2F(3.0f, 5.0f), c);
}
示例5: AdditionOperator
public void AdditionOperator()
{
Vector2F a = new Vector2F(1.0f, 2.0f);
Vector2F b = new Vector2F(2.0f, 3.0f);
Vector2F c = a + b;
Assert.AreEqual(new Vector2F(3.0f, 5.0f), c);
}
示例6: OrientedBox
/// <summary>
/// Initializes a new instance of the <see cref="OrientedBox"/> class using given center point, axes and extents.
/// </summary>
/// <param name="center">The center of the box.</param>
/// <param name="axis1">The first axis.</param>
/// <param name="axis2">The second axis.</param>
/// <param name="extent1">The extent on the first axis.</param>
/// <param name="extent2">The extent on the second axis.</param>
public OrientedBox(Vector2F center, Vector2F axis1, Vector2F axis2, float extent1, float extent2)
{
_center = center;
_axis1 = axis1;
_axis2 = axis2;
_extent1 = extent1;
_extent2 = extent2;
}
示例7: TestPolygonContainsPoint
public void TestPolygonContainsPoint()
{
// ARRANGE.
var point = new Vector2F(3, 3);
// ASSERT.
Assert.IsTrue(this.polygon.Contains(point));
}
示例8: TestRectangleFCenter
public void TestRectangleFCenter()
{
// ARRANGE.
var rectangle = new RectangleF(new Vector2F(2, 3), new Vector2F(6, 8));
var center = new Vector2F(5, 7);
// ASSERT.
Assert.AreEqual(center, rectangle.Center);
}
示例9: Planet
public Planet(IServiceProvider services, SystemMapPlanetViewModel viewModel)
{
ViewModel = viewModel;
Scale = ViewModel.Scale;
ImageControl = new Image();
_content = (ContentController)services.GetService(typeof(ContentController));
ImageControl.Texture = _content.GetContent<Texture2D>(@"SystemMap\Planet1");
Content = ImageControl;
RenderScale = new Vector2F(Scale);
}
示例10: Normalize
public void Normalize()
{
Vector2F v, n1, n2;
float magnitude;
v = new Vector2F(3.0f, 4.0f);
n1 = v.Normalize();
n2 = v.Normalize(out magnitude);
Assert.AreEqual(1.0f, n1.Magnitude, 1e-14);
Assert.AreEqual(1.0f, n2.Magnitude, 1e-14);
Assert.AreEqual(5.0f, magnitude, 1e-14);
}
示例11: Absolute
public void Absolute()
{
Vector2F v = new Vector2F(-1, -2);
v.Absolute();
Assert.AreEqual(1, v.X);
Assert.AreEqual(2, v.Y);
v = new Vector2F(1, 2);
v.Absolute();
Assert.AreEqual(1, v.X);
Assert.AreEqual(2, v.Y);
}
示例12: AbsoluteStatic
public void AbsoluteStatic()
{
Vector2F v = new Vector2F(-1, -2);
Vector2F absoluteV = Vector2F.Absolute(v);
Assert.AreEqual(1, absoluteV.X);
Assert.AreEqual(2, absoluteV.Y);
v = new Vector2F(1, 2);
absoluteV = Vector2F.Absolute(v);
Assert.AreEqual(1, absoluteV.X);
Assert.AreEqual(2, absoluteV.Y);
}
示例13: Update
private void Update(Context context)
{
if (_positionDirty)
{
DisposeVertexArray();
CreateVertexArray(context);
Vector2F[] positions = new Vector2F[] { _position.ToVector2F() };
_positionBuffer.CopyFromSystemMemory(positions);
_positionDirty = false;
}
}
示例14: Subtract
public void Subtract()
{
Vector2F v1 = new Vector2F(1.0f, 2.0f);
Vector2F v2 = new Vector2F(4.0f, 5.0f);
Vector2F v3 = v1 - v2;
Assert.AreEqual(-3.0f, v3.X, 1e-14);
Assert.AreEqual(-3.0f, v3.Y, 1e-14);
Vector2F v4 = v1.Subtract(v2);
Assert.AreEqual(-3.0f, v4.X, 1e-14);
Assert.AreEqual(-3.0f, v4.Y, 1e-14);
}
示例15: Add
public void Add()
{
Vector2F v1 = new Vector2F(1.0f, 2.0f);
Vector2F v2 = new Vector2F(4.0f, 5.0f);
Vector2F v3 = v1 + v2;
Assert.AreEqual(5.0f, v3.X, 1e-14);
Assert.AreEqual(7.0f, v3.Y, 1e-14);
Vector2F v4 = v1.Add(v2);
Assert.AreEqual(5.0f, v4.X, 1e-14);
Assert.AreEqual(7.0f, v4.Y, 1e-14);
}