← Standard library

float2

struct float2

Available 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.

Vectors.wax:8

Members

xfield

public float x

The x component.

Vectors.wax:12

yfield

public float y

The y component.

Vectors.wax:16

constructorconstructor

public constructor (float x, float y)

Stores the supplied components in order.

Vectors.wax:21

FromScalarconstructor

public constructor FromScalar (float value)

Copies the same scalar into every component.

Vectors.wax:29

From3constructor

public constructor From3 (float3 v)

Copies the supplied vector components and any remaining scalar component in order.

Vectors.wax:37

From4constructor

public constructor From4 (float4 v)

Copies the leading components, discarding the unused trailing components.

Vectors.wax:45

Zerogetter

public static get Zero() : float2

The all-zero vector.

Vectors.wax:54

Onegetter

public static get One() : float2

The all-one vector.

Vectors.wax:61

UnitXgetter

public static get UnitX() : float2

The unit vector along the X axis; all other components are zero.

Vectors.wax:68

UnitYgetter

public static get UnitY() : float2

The unit vector along the Y axis; all other components are zero.

Vectors.wax:75

lengthSquaredgetter

public get lengthSquared() : float

Returns the sum of squared components without taking a square root.

Vectors.wax:83

lengthgetter

public get length() : float

Returns the Euclidean magnitude.

Vectors.wax:90

normalizedgetter

public get normalized() : float2

Divides by the Euclidean magnitude. A zero magnitude returns the zero vector.

Vectors.wax:97

isZerogetter

public get isZero() : bool

Tests whether every component is exactly zero; uses no tolerance.

Vectors.wax:108

Dotmethod

public static fn Dot(float2 a, float2 b) : float

Returns the sum of component-wise products.

Vectors.wax:116

Distancemethod

public static fn Distance(float2 a, float2 b) : float

Returns the Euclidean distance between vectors.

Vectors.wax:123

DistanceSquaredmethod

public static fn DistanceSquared(float2 a, float2 b) : float

Returns squared Euclidean distance, avoiding a square root.

Vectors.wax:132

Lerpmethod

public static fn Lerp(float2 a, float2 b, float t) : float2

Interpolates component-wise as a + t*(b-a). Does not clamp t.

Vectors.wax:141

Reflectmethod

public static fn Reflect(float2 v, float2 normal) : float2

Reflects v around the supplied unit normal. Does not normalize normal.

Vectors.wax:148

Minmethod

public static fn Min(float2 a, float2 b) : float2

Takes the scalar Math.Min of each component pair, including its NaN and signed-zero rules.

Vectors.wax:156

Maxmethod

public static fn Max(float2 a, float2 b) : float2

Takes the scalar Math.Max of each component pair, including its NaN and signed-zero rules.

Vectors.wax:163

Absmethod

public static fn Abs(float2 v) : float2

Takes the absolute value of every component.

Vectors.wax:170

Clampmethod

public static fn Clamp(float2 v, float2 lo, float2 hi) : float2

Clamps each component between the corresponding ordered lo and hi bounds.

Vectors.wax:177

SmoothStepmethod

public static fn SmoothStep(float2 a, float2 b, float t) : float2

Clamps t to [0, 1], applies the cubic tt(3-2*t), and interpolates between a and b.

Vectors.wax:187

MoveTowardsmethod

public static fn MoveTowards(float2 current, float2 target, float maxDistanceDelta) : float2

Moves toward target by at most maxDistanceDelta in Euclidean distance without overshooting. Supply a nonnegative delta.

Vectors.wax:196

xxgetter

public get xx() : float2

Vectors.wax:208

xygetter

public get xy() : float2

Vectors.wax:209

xysetter

public set xy(float2 value) : void

Vectors.wax:210

yxgetter

public get yx() : float2

Vectors.wax:211

yxsetter

public set yx(float2 value) : void

Vectors.wax:212

yygetter

public get yy() : float2

Vectors.wax:213

xxxgetter

public get xxx() : float3

Vectors.wax:214

xxygetter

public get xxy() : float3

Vectors.wax:215

xyxgetter

public get xyx() : float3

Vectors.wax:216

xyygetter

public get xyy() : float3

Vectors.wax:217

yxxgetter

public get yxx() : float3

Vectors.wax:218

yxygetter

public get yxy() : float3

Vectors.wax:219

yyxgetter

public get yyx() : float3

Vectors.wax:220

yyygetter

public get yyy() : float3

Vectors.wax:221

xxxxgetter

public get xxxx() : float4

Vectors.wax:222

xxxygetter

public get xxxy() : float4

Vectors.wax:223

xxyxgetter

public get xxyx() : float4

Vectors.wax:224

xxyygetter

public get xxyy() : float4

Vectors.wax:225

xyxxgetter

public get xyxx() : float4

Vectors.wax:226

xyxygetter

public get xyxy() : float4

Vectors.wax:227

xyyxgetter

public get xyyx() : float4

Vectors.wax:228

xyyygetter

public get xyyy() : float4

Vectors.wax:229

yxxxgetter

public get yxxx() : float4

Vectors.wax:230

yxxygetter

public get yxxy() : float4

Vectors.wax:231

yxyxgetter

public get yxyx() : float4

Vectors.wax:232

yxyygetter

public get yxyy() : float4

Vectors.wax:233

yyxxgetter

public get yyxx() : float4

Vectors.wax:234

yyxygetter

public get yyxy() : float4

Vectors.wax:235

yyyxgetter

public get yyyx() : float4

Vectors.wax:236

yyyygetter

public get yyyy() : float4

Vectors.wax:237

ToStringmethod

public fn ToString() : string

Provided by the compiler.

ToStringBuffermethod

public fn ToStringBuffer(StringBuilder builder) : int32

Provided by the compiler.