Back to class index

Class float2

Summary

A vector of form (x,y).

Member Reference

float2A vector of form (x,y).
xThe x component.
yThe y component.
zero[static][const]Specifies a compile-time constant float2 with value (0, 0).
one[static][const]Specifies a compile-time constant float2 with value (1, 1).
unitX[static][const]Specifies a compile-time constant float2 with value (1, 0).
unitY[static][const]Specifies a compile-time constant float2 with value (0, 1).
nan[static][const]A compile-time constant float2 with value (NaN, NaN).
inf[static][const]A compile-time constant float2 with value (+infinity, +infinity).
ctor (+3 overloads)The default constructor does not initialize any members of this class.
ptr() (+1 overload)Casts this float2 to a C array.
operator[](index) (+1 overload)Accesses an element of this vector using array notation.
At(index) (+1 overload)Accesses an element of this vector.
operators +,-,*,/(v)[const] (+1 overload)Adds two vectors.
operators +=,-=,*=,/=(v)Adds a vector to this vector, in-place.
Add/Sub/Mul/Div(v)[const] (+1 overload)Adds a vector to this vector.
xx/xy/yx/yy()[const]Performs a 2D swizzled access to this vector.
Swizzled(i,j,k,l)[const] (+2 overloads)Performs a swizzled access to this vector.
SetFromScalar(scalar)Fills each entry of this float2 by the given scalar.
Set(x,y)Sets all elements of this vector.
SetFromPolarCoordinates(theta,length) (+1 overload)Converts the given vector represented in polar coordinates to an euclidean float2 (x,y) pair.
ToPolarCoordinates()[const]Converts this euclidean (x,y) float2 to polar coordinates representation in the form (theta, length).
AimedAngle()[const]Returns the aimed angle direction of this vector, in radians.
Length()[const]Computes the length of this vector.
LengthSq()[const]Computes the squared length of this vector.
Normalize()Normalizes this float2.
Normalized()[const]Returns a normalized copy of this vector.
ScaleToLength(newLength)Scales this vector so that its new length is as given.
ScaledToLength(newLength)[const]Returns a scaled copy of this vector which has its new length as given.
IsNormalized(epsilonSq)[const]Tests if the length of this vector is one, up to the given epsilon.
IsZero(epsilonSq)[const]Tests if this is the null vector, up to the given epsilon.
IsFinite()[const]Tests if this vector contains valid finite elements.
IsPerpendicular(other,epsilonSq)[const]Tests if two vectors are perpendicular to each other.
Equals(other,epsilon)[const] (+1 overload)Tests if two vectors are equal, up to the given epsilon.
BitEquals(other)[const]Compares whether this float2 and the given float2 are identical bit-by-bit in the underlying representation.
ToString()[const]Returns "(x, y)".
SerializeToString()[const]Returns "x,y". This is the preferred format for the float2 if it has to be serialized to a string for machine transfer.
SerializeToCodeString()[const]Returns a string of C++ code that can be used to construct this object. Useful for generating test cases from badly behaving objects.
SumOfElements()[const]Returns x + y.
ProductOfElements()[const]Returns x * y.
AverageOfElements()[const]Returns (x+y)/2.
MinElement()[const]Returns min(x, y).
MinElementIndex()[const]Returns the index that has the smallest value in this vector.
MaxElement()[const]Returns max(x, y).
MaxElementIndex()[const]Returns the index that has the smallest value in this vector.
Abs()[const]Takes the element-wise absolute value of this vector.
Neg()[const]Returns a copy of this vector with each element negated.
Recip()[const]Computes the element-wise reciprocal of this vector.
Min(ceil)[const] (+1 overload)Returns an element-wise minimum of this and the vector (ceil, ceil, ceil).
Max(floor)[const] (+1 overload)Returns an element-wise maximum of this and the vector (floor, floor, floor).
Clamp(floor,ceil)[const] (+1 overload)Returns a vector that has floor <= this[i] <= ceil for each element.
Clamp01()[const]Limits each element of this vector in the range [0, 1].
Distance(point)[const]Computes the distance between this and the given float2.
DistanceSq(point)[const]Computes the squared distance between this and the given point.
Dot(v)[const]Computes the dot product of this and the given vector.
Perp()[const]Returns this vector with the "perp" operator applied to it.
PerpDot(rhs)[const]Computes the perp-dot product of this and the given float2 in the order this^perp (dot) rhs.
Rotate90CW()Rotates this vector 90 degrees clock-wise.
Rotated90CW()[const]Returns a vector that is perpendicular to this vector (rotated 90 degrees clock-wise).
Rotate90CCW()Rotates this vector 90 degrees counterclock-wise .
Rotated90CCW()[const]Returns a vector that is perpendicular to this vector (rotated 90 degrees counter-clock-wise).
Reflect(normal)[const]Returns this vector reflected about a plane with the given normal.
Refract(...)[const]Refracts this vector about a plane with the given normal.
ProjectTo(direction)[const]Projects this vector onto the given unnormalized direction vector.
ProjectToNorm(direction)[const]Projects this vector onto the given normalized direction vector.
AngleBetween(other)[const]Returns the angle between this vector and the specified vector, in radians.
AngleBetweenNorm(normalizedVector)[const]Returns the angle between this vector and the specified normalized vector, in radians.
Decompose(...)[const]Breaks this vector down into parallel and perpendicular components with respect to the given direction.
Lerp(b,t)[const]Linearly interpolates between this and the vector b.
FromScalar(scalar)[static]Generates a new float2 by filling its entries by the given scalar.
FromPolarCoordinates(theta,length)[static] (+1 overload)
FromString(str,outEndStr)[static] (+1 overload)Parses a string that is of form "x,y" or "(x,y)" or "(x;y)" or "x y" to a new float2.
Lerp(a,b,t)[static]This function is the same as calling a.Lerp(b, t).
Orthogonalize(a,b)[static]Makes the given vectors linearly independent.
AreOrthogonal(a,b,epsilon)[static]Returns true if the given vectors are orthogonal to each other.
Orthonormalize(a,b)[static]Makes the given vectors linearly independent and normalized in length.
OrientedCCW(a,b,c)[static]Tests if the triangle a->b->c is oriented counter-clockwise.
ConvexHull(...)[static]Computes the 2D convex hull of the given point set.
ConvexHullInPlace(...)[static]Computes the 2D convex hull of the given point set, in-place.
ConvexHullContains(...)[static]Tests whether a 2D convex hull contains the given point.
MinAreaRectInPlace(...)[static]Computes the minimum-area rectangle that bounds the given point set. [noscript].
RandomDir(lcg,length)[static]Generates a direction vector of the given length pointing at a uniformly random direction.
RandomBox(...)[static]Returns a random float3 with each entry randomized between the range [minElem, maxElem].
Back to class index