kick.math.Vec3 Class
Vec3 - 3 Dimensional Vector
Item Index
Methods
- add static
- array static
- cartesianToSpherical static
- clone static
- copy static
- create static
- cross static
- direction static
- dist static
- distance static
- divide static
- dot static
- equal static
- forEach static
- fromValues static
- length static
- lerp static
- max static
- min static
- multiply static
- negate static
- normalize static
- scale static
- set static
- sphericalToCarterian static
- squaredDistance static
- squaredLength static
- str static
- subtract static
- transformMat4 static
- transformQuat static
- unproject static
- wrapArray static
Methods
add
-
out
-
a
-
b
Adds two vec3's
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the first operand
-
b
kick.math.Vec3the second operand
Returns:
out
array
-
count
-
ref
Create a continuous array in memory mapped to vec3.
Example
Parameters:
-
count
NumberNumber of vec 3 to be layed out in memory
-
ref
ObjectOptional, if set a memory reference is set to ref.mem
Returns:
New vec3
Example:
var ref = {};
var v = kick.math.Vec3.array(2,ref);
v[1][1] = 1;
ref.mem[4] == v[1][1];
Will be layed out like this:
[vec3][vec3) = [0][1][2][3][4][5]
cartesianToSpherical
-
out
-
cartesian
Converts from cartesian coordinates to spherical coordinates (in radians)
Spherical coordinates are mapped so vec[0] is radius, vec[1] is polar and vec[2] is elevation
Parameters:
-
out
kick.math.Vec3 -
cartesian
kick.math.Vec3
Returns:
clone
-
a
Parameters:
-
a
kick.math.Vec3vector to clone
Returns:
a new 3D vector
copy
-
out
-
a
Copy the values from one vec3 to another
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the source vector
Returns:
out
cross
-
out
-
a
-
b
Generates the cross product of two vec3s
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the first operand
-
b
kick.math.Vec3the second operand
Returns:
out
direction
-
out
-
vec
-
vec2
Generates a unit vector pointing from one vector to another
Parameters:
-
out
kick.math.Vec3vec3 receiving operation result.
-
vec
kick.math.Vec3origin vec3
-
vec2
kick.math.Vec3vec3 to point to
Returns:
dest if specified, vec otherwise
dist
-
vec
-
vec2
Calculates the euclidean distance between two vec3
Parameters:
-
vec
kick.math.Vec3first vector
-
vec2
kick.math.Vec3second vector
Returns:
distance between vec and vec2
distance
-
a
-
b
Calculates the euclidian distance between two vec3's
Parameters:
-
a
kick.math.Vec3the first operand
-
b
kick.math.Vec3the second operand
Returns:
distance between a and b
divide
-
out
-
a
-
b
Divides two vec3's
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the first operand
-
b
kick.math.Vec3the second operand
Returns:
out
dot
-
a
-
b
Calculates the dot product of two vec3s
Parameters:
-
a
kick.math.Vec3the first operand
-
b
kick.math.Vec3the second operand
Returns:
dot product of a and b
equal
-
vec
-
vec2
-
epsilon
Test to see if vectors are equal (difference is less than epsilon)
Parameters:
-
vec
kick.math.Vec3first operand
-
vec2
kick.math.Vec3second operand
-
epsilon
NumberOptional - default value is
Returns:
true if two vectors are equals
forEach
-
a
-
stride
-
offset
-
count
-
fn
-
[arg]
Perform some operation over an array of vec3s.
Parameters:
-
a
Arraythe array of vectors to iterate over
-
stride
NumberNumber of elements between the start of each vec3. If 0 assumes tightly packed
-
offset
NumberNumber of elements to skip at the beginning of the array
-
count
NumberNumber of vec3s to iterate over. If 0 iterates over entire array
-
fn
FunctionFunction to call for each vector in the array
-
[arg]
Object optionaladditional argument to pass to fn
Returns:
a
fromValues
-
x
-
y
-
z
Creates a new vec3 initialized with the given values
Parameters:
-
x
NumberX component
-
y
NumberY component
-
z
NumberZ component
Returns:
a new 3D vector
length
-
a
Calculates the length of a vec3
Parameters:
-
a
kick.math.Vec3vector to calculate length of
Returns:
Length of vec
lerp
-
out
-
a
-
b
-
t
Performs a linear interpolation between two vec3
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the first operand
-
b
kick.math.Vec3the second operand
-
t
Numberinterpolation amount between the two inputs
Returns:
out
max
-
out
-
a
-
b
Returns the maximum of two vec3's
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the first operand
-
b
kick.math.Vec3the second operand
Returns:
out
min
-
out
-
a
-
b
Returns the minimum of two vec3's
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the first operand
-
b
kick.math.Vec3the second operand
Returns:
out
multiply
-
out
-
a
-
b
Multiplies two vec3's
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the first operand
-
b
kick.math.Vec3the second operand
Returns:
out
negate
-
out
-
a
Negates the components of a vec3
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3vector to negate
Returns:
out
normalize
-
out
-
a
Normalize a vec3
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3vector to normalize
Returns:
out
scale
-
out
-
a
-
b
Scales a vec3 by a scalar number
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the vector to scale
-
b
Numberamount to scale the vector by
Returns:
out
set
-
out
-
x
-
y
-
z
Set the components of a vec3 to the given values
Parameters:
-
out
kick.math.Vec3the receiving vector
-
x
NumberX component
-
y
NumberY component
-
z
NumberZ component
Returns:
out
sphericalToCarterian
-
out
-
spherical
Converts the spherical coordinates (in radians) to carterian coordinates.
Spherical coordinates are mapped so vec[0] is radius, vec[1] is polar and vec[2] is elevation
Parameters:
-
out
kick.math.Vec3 -
spherical
kick.math.Vec3spherical coordinates
Returns:
position in cartesian angles
squaredDistance
-
a
-
b
Calculates the squared euclidian distance between two vec3's
Parameters:
-
a
kick.math.Vec3the first operand
-
b
kick.math.Vec3the second operand
Returns:
squared distance between a and b
squaredLength
-
a
Calculates the squared length of a vec3
Parameters:
-
a
kick.math.Vec3vector to calculate squared length of
Returns:
Squared length of vec
str
-
vec
Returns a string representation of a vector
Parameters:
-
vec
kick.math.Vec3vec3 to represent as a string
Returns:
string representation of vec
subtract
-
out
-
a
-
b
Subtracts two vec3's
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the first operand
-
b
kick.math.Vec3the second operand
Returns:
out
transformMat4
-
out
-
a
-
m
Transforms the vec3 with a mat4. 4th vector component is implicitly '1'
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the vector to transform
-
m
kick.math.Mat4matrix to transform with
Returns:
out
transformQuat
-
out
-
a
-
q
Transforms the vec3 with a quat
Parameters:
-
out
kick.math.Vec3the receiving vector
-
a
kick.math.Vec3the vector to transform
-
q
kick.math.Quatquaternion to transform with
Returns:
out
unproject
-
out
-
vec
-
modelView
-
proj
-
viewportRect
Projects the specified vec3 from screen space into object space Based on Mesa gluUnProject implementation at: http://webcvs.freedesktop.org/mesa/Mesa/src/glu/mesa/project.c?revision=1.4&view=markup
Parameters:
-
out
kick.math.Vec3vec3 receiving unprojected result.
-
vec
kick.math.Vec3screen-space vector to project
-
modelView
kick.math.Mat4Model-View matrix
-
proj
kick.math.Mat4Projection matrix
-
viewportRect
kick.math.Vec4Viewport as given to gl.viewport [x, y, width, height]
Returns:
dest if specified, vec otherwise
wrapArray
-
array
See kick.math.Vec4.wrapArray
Parameters:
-
array
Float32Array
Returns:
of vec3