API Docs for: 0.5.5
Show:

kick.math.Vec3 Class

Defined in: kick/math/Vec3.js:14
Module: kick.math

Vec3 - 3 Dimensional Vector

Item Index

Methods

Methods

add

(
  • out
  • a
  • b
)
kick.math.Vec3 static

Adds two vec3's

Parameters:

Returns:

array

(
  • count
  • ref
)
kick.math.Vec3 static

Create a continuous array in memory mapped to vec3.

Example

Parameters:

  • count Number

    Number of vec 3 to be layed out in memory

  • ref Object

    Optional, if set a memory reference is set to ref.mem

Returns:

kick.math.Vec3:

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
)
kick.math.Vec3 static

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:

Returns:

clone

(
  • a
)
kick.math.Vec3 static

Parameters:

Returns:

kick.math.Vec3:

a new 3D vector

copy

(
  • out
  • a
)
kick.math.Vec3 static

Copy the values from one vec3 to another

Parameters:

Returns:

create

() kick.math.Vec3 static

Creates a new, empty vec3

Returns:

kick.math.Vec3:

New vec3

cross

(
  • out
  • a
  • b
)
kick.math.Vec3 static

Generates the cross product of two vec3s

Parameters:

Returns:

direction

(
  • out
  • vec
  • vec2
)
kick.math.Vec3 static

Generates a unit vector pointing from one vector to another

Parameters:

Returns:

kick.math.Vec3:

dest if specified, vec otherwise

dist

(
  • vec
  • vec2
)
Number static

Calculates the euclidean distance between two vec3

Parameters:

Returns:

Number:

distance between vec and vec2

distance

(
  • a
  • b
)
Number static

Calculates the euclidian distance between two vec3's

Parameters:

Returns:

Number:

distance between a and b

divide

(
  • out
  • a
  • b
)
kick.math.Vec3 static

Divides two vec3's

Parameters:

Returns:

dot

(
  • a
  • b
)
Number static

Calculates the dot product of two vec3s

Parameters:

Returns:

Number:

dot product of a and b

equal

(
  • vec
  • vec2
  • epsilon
)
Boolean static

Test to see if vectors are equal (difference is less than epsilon)

Parameters:

Returns:

Boolean:

true if two vectors are equals

forEach

(
  • a
  • stride
  • offset
  • count
  • fn
  • [arg]
)
Array static

Perform some operation over an array of vec3s.

Parameters:

  • a Array

    the array of vectors to iterate over

  • stride Number

    Number of elements between the start of each vec3. If 0 assumes tightly packed

  • offset Number

    Number of elements to skip at the beginning of the array

  • count Number

    Number of vec3s to iterate over. If 0 iterates over entire array

  • fn Function

    Function to call for each vector in the array

  • [arg] Object optional

    additional argument to pass to fn

Returns:

Array:

a

fromValues

(
  • x
  • y
  • z
)
kick.math.Vec3 static

Creates a new vec3 initialized with the given values

Parameters:

  • x Number

    X component

  • y Number

    Y component

  • z Number

    Z component

Returns:

kick.math.Vec3:

a new 3D vector

length

(
  • a
)
Number static

Calculates the length of a vec3

Parameters:

Returns:

Number:

Length of vec

lerp

(
  • out
  • a
  • b
  • t
)
kick.math.Vec3 static

Performs a linear interpolation between two vec3

Parameters:

Returns:

max

(
  • out
  • a
  • b
)
kick.math.Vec3 static

Returns the maximum of two vec3's

Parameters:

Returns:

min

(
  • out
  • a
  • b
)
kick.math.Vec3 static

Returns the minimum of two vec3's

Parameters:

Returns:

multiply

(
  • out
  • a
  • b
)
kick.math.Vec3 static

Multiplies two vec3's

Parameters:

Returns:

negate

(
  • out
  • a
)
kick.math.Vec3 static

Negates the components of a vec3

Parameters:

Returns:

normalize

(
  • out
  • a
)
kick.math.Vec3 static

Normalize a vec3

Parameters:

Returns:

scale

(
  • out
  • a
  • b
)
kick.math.Vec3 static

Scales a vec3 by a scalar number

Parameters:

Returns:

set

(
  • out
  • x
  • y
  • z
)
kick.math.Vec3 static

Set the components of a vec3 to the given values

Parameters:

  • out kick.math.Vec3

    the receiving vector

  • x Number

    X component

  • y Number

    Y component

  • z Number

    Z component

Returns:

sphericalToCarterian

(
  • out
  • spherical
)
kick.math.Vec3 static

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:

Returns:

kick.math.Vec3:

position in cartesian angles

squaredDistance

(
  • a
  • b
)
Number static

Calculates the squared euclidian distance between two vec3's

Parameters:

Returns:

Number:

squared distance between a and b

squaredLength

(
  • a
)
Number static

Calculates the squared length of a vec3

Parameters:

Returns:

Number:

Squared length of vec

str

(
  • vec
)
String static

Returns a string representation of a vector

Parameters:

Returns:

String:

string representation of vec

subtract

(
  • out
  • a
  • b
)
kick.math.Vec3 static

Subtracts two vec3's

Parameters:

Returns:

transformMat4

(
  • out
  • a
  • m
)
kick.math.Vec3 static

Transforms the vec3 with a mat4. 4th vector component is implicitly '1'

Parameters:

Returns:

transformQuat

(
  • out
  • a
  • q
)
kick.math.Vec3 static

Transforms the vec3 with a quat

Parameters:

Returns:

unproject

(
  • out
  • vec
  • modelView
  • proj
  • viewportRect
)
kick.math.Vec3 static

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:

Returns:

kick.math.Vec3:

dest if specified, vec otherwise

wrapArray

(
  • array
)
Array_kick.math.Vec3 static

See kick.math.Vec4.wrapArray

Parameters:

  • array Float32Array

Returns:

Array_kick.math.Vec3:

of vec3