pwu:: Vector3

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

Summary
Utility functions for three dimensional vectors, which are represented as a list of three real values.
Return the 3 dimensional zero vector
Return a vector with the given x, y and z components
Return the value of the vector at the given index
Return the x component of the vector
Return the y component of the vector
Return the z component of the vector
Check if two vectors are equal
Check if two vectors are not equal
Add two vectors together and return the result
Subtract one vector from another and return the result
Return the negation of a vector
Scale a vector by a single scalar value
Scale a vector by inverse of a single scalar value
Return a vector that is the components of two vectors multiplied together
Return the cross product of two vectors
Calculate the dot product of two vectors
Return the normalization of a vector
Return the length of the vector
Return the distance of the vector to a line
Return a vector that has the minimum components of two vectors
Return a vector that has the maximum components of two vectors
Return a vector that is the affine combination of two vectors
Return a vector that has the barycentric coordinates of the given point in the frame of the given three vectors

Static Actions

zero

pwu::Vector3 zero

Return the 3 dimensional zero vector

Parameters

none

Returns

a vector with the given x and y

set

pwu::Vector3 set x y z

Return a vector with the given x, y and z components

Parameters

xthe x component
ythe y component
zthe z component

Returns

a vector with the given x and y

index

pwu::Vector3 index vec i

Return the value of the vector at the given index

Parameters

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

Returns

the value of the vector at the given index

x

pwu::Vector3 x vec

Return the x component of the vector

Parameters

vecthe vector

Returns

the x component of the vector

y

pwu::Vector3 y vec

Return the y component of the vector

Parameters

vecthe vector

Returns

the y component of the vector

z

pwu::Vector3 z vec

Return the z component of the vector

Parameters

vecthe vector

Returns

the z component of the vector

equal

pwu::Vector3 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::Vector3 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::Vector3 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::Vector3 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::Vector3 negate vec

Return the negation of a vector

Parameters

vecthe vector

Returns

the negated vector

scale

pwu::Vector3 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::Vector3 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::Vector3 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

cross

pwu::Vector3 cross vec1 vec2

Return the cross product of two vectors

Parameters

vec1the first vector
vec2the second vector

Returns

the cross product of the two vectors

dot

pwu::Vector3 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::Vector3 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::Vector3 length vec

Return the length of the vector

Parameters

vecthe vector

Returns

the length of the vector

distanceToLine

pwu::Vector3 distanceToLine vec pt dir

Return the distance of the vector to a line

Parameters

vecthe vector
ptthe origin point of the line
dirthe direction vector of the line

Returns

the perpendicular distance of the vector to the line

minimum

pwu::Vector3 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::Vector3 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

affine

pwu::Vector3 affine s vec1 vec2

Return a vector that is the affine combination of two vectors

Parameters

sthe affine scalar
vec1the first vector
vec2the second vector

Returns

the affine combination vector

barycentric

pwu::Vector3 barycentric pt vec1 vec2 vec3

Return a vector that has the barycentric coordinates of the given point in the frame of the given three vectors

Parameters

ptthe point to find the barycentric coordinates of
vec1the first vector
vec2the second vector
vec3the third vector

Returns

the barycentric coordinates vector

pwu::Vector3 zero
Return the 3 dimensional zero vector
pwu::Vector3 set x y z
Return a vector with the given x, y and z components
pwu::Vector3 index vec i
Return the value of the vector at the given index
pwu::Vector3 x vec
Return the x component of the vector
pwu::Vector3 y vec
Return the y component of the vector
pwu::Vector3 z vec
Return the z component of the vector
pwu::Vector3 equal ?-tolerance tol? vec1 vec2
Check if two vectors are equal
pwu::Vector3 notEqual ?-tolerance tol? vec1 vec2
Check if two vectors are not equal
pwu::Vector3 add vec1 vec2
Add two vectors together and return the result
pwu::Vector3 subtract vec1 vec2
Subtract one vector from another and return the result
pwu::Vector3 negate vec
Return the negation of a vector
pwu::Vector3 scale vec scalar
Scale a vector by a single scalar value
pwu::Vector3 divide vec scalar
Scale a vector by inverse of a single scalar value
pwu::Vector3 multiply vec1 vec2
Return a vector that is the components of two vectors multiplied together
pwu::Vector3 cross vec1 vec2
Return the cross product of two vectors
pwu::Vector3 dot vec1 vec2
Calculate the dot product of two vectors
pwu::Vector3 normalize ?-length lenVar? vec
Return the normalization of a vector
pwu::Vector3 length vec
Return the length of the vector
pwu::Vector3 distanceToLine vec pt dir
Return the distance of the vector to a line
pwu::Vector3 minimum vec1 vec2
Return a vector that has the minimum components of two vectors
pwu::Vector3 maximum vec1 vec2
Return a vector that has the maximum components of two vectors
pwu::Vector3 affine s vec1 vec2
Return a vector that is the affine combination of two vectors
pwu::Vector3 barycentric pt vec1 vec2 vec3
Return a vector that has the barycentric coordinates of the given point in the frame of the given three vectors