public readonly struct Vector2A two-component vector: texture coordinates, screen positions, sizes, and the layout engine's currency.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
UV origin is top-left, so V increases downward. See Conventions.md.
Fields and properties (10)
public const int ComponentCountNumber of components.
public readonly float XThe X component.
public readonly float YThe Y component.
public static Vector2 ZeroAll components zero.
public static Vector2 OneAll components one.
public static Vector2 UnitXThe X axis.
public static Vector2 UnitYThe Y axis.
public float this[int index]The component at .
public bool IsZeroWhether every component is zero.
public bool IsNaNWhether any component is NaN.
Methods (36)
public Vector2(float x, float y)Builds a vector from its components.
public Vector2(float value)Builds a vector with every component set to .
public ReadOnlySpan<float> AsSpan()The components as a span. Valid as long as the vector it came from.
public void CopyTo(Span<float> destination)Copies the components into a caller-owned span.
public float Length()The length of the vector.
public float LengthSquared()The squared length, which avoids a square root where only comparison matters.
public static Vector2 Normalize(Vector2 value)The vector scaled to unit length; Zero if it is degenerate.
public static float Dot(Vector2 left, Vector2 right)The dot product.
public static float Cross(Vector2 left, Vector2 right)The Z component of the 3D cross product — the signed area of the parallelogram, positive when is counter-clockwise from .
public static float Distance(Vector2 left, Vector2 right)The distance between two points.
public static float DistanceSquared(Vector2 left, Vector2 right)The squared distance between two points.
public static Vector2 Lerp(Vector2 from, Vector2 to, float amount)Linearly interpolates between two vectors.
public static Vector2 Min(Vector2 left, Vector2 right)The component-wise minimum.
public static Vector2 Max(Vector2 left, Vector2 right)The component-wise maximum.
public static Vector2 Clamp(Vector2 value, Vector2 min, Vector2 max)Constrains each component to the matching interval.
public static Vector2 Abs(Vector2 value)The component-wise absolute value.
public static bool NearEqual(Vector2 left, Vector2 right, float tolerance = 1E-06)Whether two vectors agree to within a tolerance, component by component.
public static Vector2 operator +(Vector2 left, Vector2 right)Adds two vectors.
public static Vector2 operator -(Vector2 left, Vector2 right)Subtracts one vector from another.
public static Vector2 operator -(Vector2 value)Negates a vector.
public static Vector2 operator *(Vector2 left, Vector2 right)Multiplies component by component.
public static Vector2 operator *(Vector2 value, float scale)Scales a vector.
public static Vector2 operator *(float scale, Vector2 value)Scales a vector.
public static Vector2 operator /(Vector2 left, Vector2 right)Divides component by component.
public static Vector2 operator /(Vector2 value, float divisor)Divides a vector by a scalar.
public static bool operator ==(Vector2 left, Vector2 right)Exact component-wise equality, IEEE semantics. See NearEqual.
public static bool operator !=(Vector2 left, Vector2 right)The negation of op_Equality.
public static implicit operator Vector2(Vector2 value)Converts to the BCL vector, which has the same layout.
public static implicit operator Vector2(Vector2 value)Converts from the BCL vector, which has the same layout.
public void Deconstruct(out float x, out float y)Splits the vector into its components.
public bool Equals(Vector2 other)Indicates whether the current object is equal to another object of the same type.
public override bool Equals(object? obj)Indicates whether this instance and a specified object are equal.
public override int GetHashCode()Returns the hash code for this instance.
public override string ToString()Returns the fully qualified type name of this instance.
public string ToString(string? format, IFormatProvider? formatProvider)Formats the value of the current instance using the specified format.
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider? provider = null)Tries to format the value of the current instance into the provided span of characters.
Used by (409, showing 40)
- CharacterAnimationThirdPersonShooter
- VirtualGeometryGameVirtualGeometry
- ActionPlayerInputVixen.Engine
- AmbientOcclusionRendererVixen.Rendering.PostFx
- BipedGaitModelVixen.Animation
- BladeVertexVixen.Rendering.Terrain
- BlendTree2DVixen.Animation
- BlendTree2DChildVixen.Animation
- BlendTreeTestsVixen.Animation.Tests
- BloomConstantsVixen.Rendering
- BloomKeysVixen.Rendering
- BloomRendererVixen.Rendering.PostFx
- BloomTestsVixen.Rendering.PostFx.Tests
- BoundsVixen.Engine.Tests
- BoxStyleVixen.Ui
- BrushFootprintVixen.Terrain
- BrushStampVixen.Terrain
- BrushStrokeVixen.Terrain
- BrushStrokeTestsVixen.Terrain.Tests
- BuilderVixen.Rendering
- CameraFramingVixen.Engine
- CardGeneratorVixen.Rendering.SurfaceCache
- CaseVixen.Rendering.Tests
- CellVixen.Rendering
- ClampProcessorVixen.Input
- ClusterAttributeTestsVixen.Rendering.Tests
- ClusterAttributesVixen.Rendering
- ClusterCullingDeviceTestsVixen.Graphics.Golden.Tests
- ClusterGridVixen.Rendering
- ClusteredLightingTestsVixen.Rendering.Tests
- CodeEditorVixen.Ui.Controls.Advanced
- CodeEditorTestsVixen.Ui.Controls.Advanced.Tests
- ColorFieldVixen.Ui.Controls.Advanced
- ColorPickerVixen.Ui.Controls.Advanced
- ColorPickerTestsVixen.Ui.Controls.Advanced.Tests
- ColorStripVixen.Ui.Controls.Advanced
- ComposerAimVixen.Engine
- CompositorImageTestsVixen.Graphics.Golden.Tests
- ConsoleTestsVixen.Engine.Tests
- ConstantMaskVixen.Terrain.Tests