pwu::Vector2

Utility functions for two dimensional vectors, which are represented as a list of two real values.

Summary
pwu::Vector2Utility functions for two dimensional vectors, which are represented as a list of two real values.
Static Actions
zeroReturn the 2 dimensional zero vector
setReturn a vector with the given x and y components
indexReturn the value of the vector at the given index
xReturn the x component of the vector
yReturn the y component of the vector
equalCheck if two vectors are equal
notEqualCheck if two vectors are not equal
addAdd two vectors together and return the result
subtractSubtract one vector from another and return the result
negateReturn the negation of a vector
scaleScale a vector by a single scalar value
divideScale a vector by inverse of a single scalar value
multiplyReturn a vector that is the components of two vectors multiplied together
dotCalculate the dot product of two vectors
normalizeReturn the normalization of a vector
lengthReturn the length of the vector
minimumReturn a vector that has the minimum components of two vectors
maximumReturn a vector that has the maximum components of two vectors

Static Actions

zero

pwu::Vector2 zero

Return the 2 dimensional zero vector

Parameters

none

Returns

a vector with the given x and y

set

pwu::Vector2 set x y

Return a vector with the given x and y components

Parameters

xthe x component
ythe y component

Returns

a vector with the given x and y

index

pwu::Vector2 index vec i

Return the value of the vector at the given index

Parameters

vecthe vector
ithe index to get; [0, 1]

Returns

the value of the vector at the given index

x

pwu::Vector2 x vec

Return the x component of the vector

Parameters

vecthe vector

Returns

the x component of the vector

y

pwu::Vector2 y vec

Return the y component of the vector

Parameters

vecthe vector

Returns

the y component of the vector

equal

pwu::Vector2 equal ?-tolerance tol? vec1 vec2

Check if two vectors are equal

Parameters

tolthe tolerance to check equality, 0.0 is used if not given
vec1the first vector
vec2the second vector

Returns

true if the vectors are equal within tolerance

notEqual

pwu::Vector2 notEqual ?-tolerance tol? vec1 vec2

Check if two vectors are not equal

Parameters

tolthe tolerance to check equality, 0.0 is used if not given
vec1the first vector
vec2the second vector

Returns

true if the vectors are not equal within tolerance

add

pwu::Vector2 add vec1 vec2

Add two vectors together and return the result

Parameters

vec1the first vector
vec2the second vector

Returns

the sum of the two vectors

subtract

pwu::Vector2 subtract vec1 vec2

Subtract one vector from another and return the result

Parameters

vec1the first vector
vec2the second vector

Returns

the difference of the two vectors

negate

pwu::Vector2 negate vec

Return the negation of a vector

Parameters

vecthe vector

Returns

the negated vector

scale

pwu::Vector2 scale vec scalar

Scale a vector by a single scalar value

Parameters

vecthe vector
scalara scalar value

Returns

a vector scaled by the scalar

divide

pwu::Vector2 divide vec scalar

Scale a vector by inverse of a single scalar value

Parameters

vecthe vector
scalara scalar value

Returns

a vector divided by the scalar

multiply

pwu::Vector2 multiply vec1 vec2

Return a vector that is the components of two vectors multiplied together

Parameters

vec1the first vector
vec2the second vector

Returns

the component multiply of the two vectors

dot

pwu::Vector2 dot vec1 vec2

Calculate the dot product of two vectors

Parameters

vec1the first vector
vec2the second vector

Returns

the dot product of the two vectors

normalize

pwu::Vector2 normalize ?-length lenVar? vec

Return the normalization of a vector

Parameters

vecthe vector
lenVara variable name to set the length of the vector before being normalized

Returns

the normalized vector

length

pwu::Vector2 length vec

Return the length of the vector

Parameters

vecthe vector

Returns

the length of the vector

minimum

pwu::Vector2 minimum vec1 vec2

Return a vector that has the minimum components of two vectors

Parameters

vec1the first vector
vec2the second vector

Returns

the minimum vector

maximum

pwu::Vector2 maximum vec1 vec2

Return a vector that has the maximum components of two vectors

Parameters

vec1the first vector
vec2the second vector

Returns

the maximum vector

pwu::Vector2 zero
Return the 2 dimensional zero vector
pwu::Vector2 set x y
Return a vector with the given x and y components
pwu::Vector2 index vec i
Return the value of the vector at the given index
pwu::Vector2 x vec
Return the x component of the vector
pwu::Vector2 y vec
Return the y component of the vector
pwu::Vector2 equal ?-tolerance tol? vec1 vec2
Check if two vectors are equal
pwu::Vector2 notEqual ?-tolerance tol? vec1 vec2
Check if two vectors are not equal
pwu::Vector2 add vec1 vec2
Add two vectors together and return the result
pwu::Vector2 subtract vec1 vec2
Subtract one vector from another and return the result
pwu::Vector2 negate vec
Return the negation of a vector
pwu::Vector2 scale vec scalar
Scale a vector by a single scalar value
pwu::Vector2 divide vec scalar
Scale a vector by inverse of a single scalar value
pwu::Vector2 multiply vec1 vec2
Return a vector that is the components of two vectors multiplied together
pwu::Vector2 dot vec1 vec2
Calculate the dot product of two vectors
pwu::Vector2 normalize ?-length lenVar? vec
Return the normalization of a vector
pwu::Vector2 length vec
Return the length of the vector
pwu::Vector2 minimum vec1 vec2
Return a vector that has the minimum components of two vectors
pwu::Vector2 maximum vec1 vec2
Return a vector that has the maximum components of two vectors
Close