float2
struct float2Available without an import.
A two-component floating-point vector with x and y fields. Arithmetic is component-wise. Swizzle getters such as yx or xxy select components in their written order and may repeat them. Swizzles with no repeated component also have setters; assigning yx writes value.x to y and value.y to x.
Members
xfield
public float xThe x component.
yfield
public float yThe y component.
constructorconstructor
public constructor (float x, float y)Stores the supplied components in order.
FromScalarconstructor
public constructor FromScalar (float value)Copies the same scalar into every component.
From3constructor
public constructor From3 (float3 v)Copies the supplied vector components and any remaining scalar component in order.
From4constructor
public constructor From4 (float4 v)Copies the leading components, discarding the unused trailing components.
Zerogetter
public static get Zero() : float2The all-zero vector.
Onegetter
public static get One() : float2The all-one vector.
UnitXgetter
public static get UnitX() : float2The unit vector along the X axis; all other components are zero.
UnitYgetter
public static get UnitY() : float2The unit vector along the Y axis; all other components are zero.
lengthSquaredgetter
public get lengthSquared() : floatReturns the sum of squared components without taking a square root.
lengthgetter
public get length() : floatReturns the Euclidean magnitude.
normalizedgetter
public get normalized() : float2Divides by the Euclidean magnitude. A zero magnitude returns the zero vector.
isZerogetter
public get isZero() : boolTests whether every component is exactly zero; uses no tolerance.
Dotmethod
public static fn Dot(float2 a, float2 b) : floatReturns the sum of component-wise products.
Distancemethod
public static fn Distance(float2 a, float2 b) : floatReturns the Euclidean distance between vectors.
DistanceSquaredmethod
public static fn DistanceSquared(float2 a, float2 b) : floatReturns squared Euclidean distance, avoiding a square root.
Lerpmethod
public static fn Lerp(float2 a, float2 b, float t) : float2Interpolates component-wise as a + t*(b-a). Does not clamp t.
Reflectmethod
public static fn Reflect(float2 v, float2 normal) : float2Reflects v around the supplied unit normal. Does not normalize normal.
Minmethod
public static fn Min(float2 a, float2 b) : float2Takes the scalar Math.Min of each component pair, including its NaN and signed-zero rules.
Maxmethod
public static fn Max(float2 a, float2 b) : float2Takes the scalar Math.Max of each component pair, including its NaN and signed-zero rules.
Absmethod
public static fn Abs(float2 v) : float2Takes the absolute value of every component.
Clampmethod
public static fn Clamp(float2 v, float2 lo, float2 hi) : float2Clamps each component between the corresponding ordered lo and hi bounds.
SmoothStepmethod
public static fn SmoothStep(float2 a, float2 b, float t) : float2Clamps t to [0, 1], applies the cubic tt(3-2*t), and interpolates between a and b.
MoveTowardsmethod
public static fn MoveTowards(float2 current, float2 target, float maxDistanceDelta) : float2Moves toward target by at most maxDistanceDelta in Euclidean distance without overshooting. Supply a nonnegative delta.
xxgetter
public get xx() : float2xygetter
public get xy() : float2xysetter
public set xy(float2 value) : voidyxgetter
public get yx() : float2yxsetter
public set yx(float2 value) : voidyygetter
public get yy() : float2xxxgetter
public get xxx() : float3xxygetter
public get xxy() : float3xyxgetter
public get xyx() : float3xyygetter
public get xyy() : float3yxxgetter
public get yxx() : float3yxygetter
public get yxy() : float3yyxgetter
public get yyx() : float3yyygetter
public get yyy() : float3xxxxgetter
public get xxxx() : float4xxxygetter
public get xxxy() : float4xxyxgetter
public get xxyx() : float4xxyygetter
public get xxyy() : float4xyxxgetter
public get xyxx() : float4xyxygetter
public get xyxy() : float4xyyxgetter
public get xyyx() : float4xyyygetter
public get xyyy() : float4yxxxgetter
public get yxxx() : float4yxxygetter
public get yxxy() : float4yxyxgetter
public get yxyx() : float4yxyygetter
public get yxyy() : float4yyxxgetter
public get yyxx() : float4yyxygetter
public get yyxy() : float4yyyxgetter
public get yyyx() : float4yyyygetter
public get yyyy() : float4ToStringmethod
public fn ToString() : stringProvided by the compiler.
ToStringBuffermethod
public fn ToStringBuffer(StringBuilder builder) : int32Provided by the compiler.