class Jitter3dUtilsInterface

Utilities for Jitter 3D manipulations

It is not necessary to instantiate this interface directly; it is available globally as a Jitter3DUtils object and methods can be called like Jitter3DUtils.vadd().

Methods

add_quats

Add three 4D vectors (quaternions)

add_quats(q1: Jitter3dUtilsTypes.vec4, q2: Jitter3dUtilsTypes.vec4, q3: Jitter3dUtilsTypes.vec4): void;
NameTypeDescription
q1Jitter3dUtilsTypes.vec4first quaternion
q2Jitter3dUtilsTypes.vec4second quaternion
q3Jitter3dUtilsTypes.vec4third quaternion

axis_to_quat

Convert an angle/axis rotation to a quaternion

axis_to_quat(axis: Jitter3dUtilsTypes.vec3, quat: Jitter3dUtilsTypes.vec4): void;
NameTypeDescription
axisJitter3dUtilsTypes.vec3axis rotation
quatJitter3dUtilsTypes.vec4output quaternion

build_rotmatrix

Build a rotation matrix for a given quaternion

build_rotmatrix(m: Jitter3dUtilsTypes.vec4, q: Jitter3dUtilsTypes.vec4): void;
NameTypeDescription
mJitter3dUtilsTypes.vec4rotation matrix
qJitter3dUtilsTypes.vec4quaternion

closest_line_sphere

Set p1 to the point on a sphere closest to a line segment

(x3 - x1)(x2 - x1) + (y3 - y1)(y2 - y1) + (z3 - z1)(z2 - z1)
-----------------------------------------------------------
(x2 - x1)(x2 - x1) + (y2 - y1)(y2 - y1) + (z2 - z1)(z2 - z1)
closest_line_sphere(lineA: Jitter3dUtilsTypes.vec3, lineB: Jitter3dUtilsTypes.vec3, center: Jitter3dUtilsTypes.vec3, r: number, p1: Jitter3dUtilsTypes.vec3): void;
NameTypeDescription
lineAJitter3dUtilsTypes.vec3first line point
lineBJitter3dUtilsTypes.vec3second line point
centerJitter3dUtilsTypes.vec3center point
rnumbersphere radius
p1Jitter3dUtilsTypes.vec3point to set

intersect_line_quad

Returns whether the ray defined by the line's two points intersect the quad defined by a position, rotation, and scale. Sets p2 to the point of intersection with the quad plane in unit coordinates and sets p1 to the same point in world coordinates.

intersect_line_quad(lineA: Jitter3dUtilsTypes.vec3, lineB: Jitter3dUtilsTypes.vec3, pos: Jitter3dUtilsTypes.vec3, rot: Jitter3dUtilsTypes.vec3, scale: Jitter3dUtilsTypes.vec3, p1: Jitter3dUtilsTypes.vec3, p2: Jitter3dUtilsTypes.vec3): boolean;
NameTypeDescription
lineAJitter3dUtilsTypes.vec3first line point
lineBJitter3dUtilsTypes.vec3second line point
posJitter3dUtilsTypes.vec3quad position
rotJitter3dUtilsTypes.vec3quad rotation
scaleJitter3dUtilsTypes.vec3quad scale
p1Jitter3dUtilsTypes.vec3world coordinate intersection point
p2Jitter3dUtilsTypes.vec3unit coordinate intersection point
Return Valueboolean

intersect_line_sphere

Returns whether the ray defined by the line's two points intersect with the sphere of given center and radius. Sets p1 to the closest point of intersection.

intersect_line_sphere(lineA: Jitter3dUtilsTypes.vec3, lineB: Jitter3dUtilsTypes.vec3, center: Jitter3dUtilsTypes.vec3, r: number, p1: Jitter3dUtilsTypes.vec3): boolean;
NameTypeDescription
lineAJitter3dUtilsTypes.vec3first line point
lineBJitter3dUtilsTypes.vec3second line point
centerJitter3dUtilsTypes.vec3sphere center
rnumbersphere radius
p1Jitter3dUtilsTypes.vec3closest point of intersection
Return Valueboolean

normalize_quat

Normalize a quaternion

normalize_quat(quat: Jitter3dUtilsTypes.vec4): void;
NameTypeDescription
quatJitter3dUtilsTypes.vec4a quaternion to normalize

quat_to_axis

Convert a quaternion to an angle/axis rotation

quat_to_axis(quat: Jitter3dUtilsTypes.vec4, axis: Jitter3dUtilsTypes.vec3): void;
NameTypeDescription
quatJitter3dUtilsTypes.vec4quaternion to convert
axisJitter3dUtilsTypes.vec3output angle/axis rotation

transform_point

transform_point(point: Jitter3dUtilsTypes.vec4, matrix: Jitter3dUtilsTypes.mat16): void;
NameTypeDescription
pointJitter3dUtilsTypes.vec4a point to transform
matrixJitter3dUtilsTypes.mat16a 4x4 matrix

vadd

Add two 3D vectors

vadd(src1: Jitter3dUtilsTypes.vec3, src2: Jitter3dUtilsTypes.vec3, dst: Jitter3dUtilsTypes.vec3): void;
NameTypeDescription
src1Jitter3dUtilsTypes.vec3first vector
src2Jitter3dUtilsTypes.vec3second vector
dstJitter3dUtilsTypes.vec3output vector to store sum of src1 + src2

vcopy

Copy one vector to another

vcopy(v1: Jitter3dUtilsTypes.vec3, v2: Jitter3dUtilsTypes.vec3): void;
NameTypeDescription
v1Jitter3dUtilsTypes.vec3source
v2Jitter3dUtilsTypes.vec3destination

vcross

Calculate the cross product of two 3D vectors

vcross(v1: Jitter3dUtilsTypes.vec3, v2: Jitter3dUtilsTypes.vec3, cross: Jitter3dUtilsTypes.vec3): void;
NameTypeDescription
v1Jitter3dUtilsTypes.vec3first vector
v2Jitter3dUtilsTypes.vec3second vector
crossJitter3dUtilsTypes.vec3cross product

vdiv

Divide src1 and src2 (element-wise) and store the result in dst

vdiv(src1: Jitter3dUtilsTypes.vec3, src2: Jitter3dUtilsTypes.vec3, dst: Jitter3dUtilsTypes.vec3): void;
NameTypeDescription
src1Jitter3dUtilsTypes.vec3first vector
src2Jitter3dUtilsTypes.vec3second vector
dstJitter3dUtilsTypes.vec3destination vector

vdot

Calculate the dot product of two 3D vectors

vdot(v1: Jitter3dUtilsTypes.vec3, v2: Jitter3dUtilsTypes.vec3): number;
NameTypeDescription
v1Jitter3dUtilsTypes.vec3first vector
v2Jitter3dUtilsTypes.vec3second vector
Return Valuenumber

vlength

Compute the squared distance of a 3D vector

vlength(v: Jitter3dUtilsTypes.vec3): number;
NameTypeDescription
vJitter3dUtilsTypes.vec3vector
Return Valuenumber

vlength2

A cheaper distance-squared calculation

vlength2(v: Jitter3dUtilsTypes.vec3): number;
NameTypeDescription
vJitter3dUtilsTypes.vec3vector
Return Valuenumber

vmul

Multiply src1 and src2 (element-wise) and store the result in dst

vmul(src1: Jitter3dUtilsTypes.vec3, src2: Jitter3dUtilsTypes.vec3, dst: Jitter3dUtilsTypes.vec3): void;
NameTypeDescription
src1Jitter3dUtilsTypes.vec3first vector
src2Jitter3dUtilsTypes.vec3second vector
dstJitter3dUtilsTypes.vec3destination vector

vnormal

Normalize a 3D vector

vnormal(v: Jitter3dUtilsTypes.vec3): void;
NameTypeDescription
vJitter3dUtilsTypes.vec3vector

vscale

Scale a vector

vscale(v: Jitter3dUtilsTypes.vec3, scale: number): void;
NameTypeDescription
vJitter3dUtilsTypes.vec3vector
scalenumberscale factor

vset

Set the values of a vector

vset(v: Jitter3dUtilsTypes.vec3, x: number, y: number, z: number): void;
NameTypeDescription
vJitter3dUtilsTypes.vec3vector
xnumbernew x value
ynumbernew y value
znumbernew z value

vsub

Subtract src2 from src1 and store the result in dst

vsub(src1: Jitter3dUtilsTypes.vec3, src2: Jitter3dUtilsTypes.vec3, dst: Jitter3dUtilsTypes.vec3): void;
NameTypeDescription
src1Jitter3dUtilsTypes.vec3first vector
src2Jitter3dUtilsTypes.vec3second vector
dstJitter3dUtilsTypes.vec3destination vector

vzero

Set all elements of a vector to zero

vzero(v: Jitter3dUtilsTypes.vec3): void;
NameTypeDescription
vJitter3dUtilsTypes.vec3vector

xyz_to_axis

Convert rotation in Euler angles (xyz) to angle/axis rotation

xyz_to_axis(v: Jitter3dUtilsTypes.vec3, axis: Jitter3dUtilsTypes.vec3): void;
NameTypeDescription
vJitter3dUtilsTypes.vec3rotation in Euler angles
axisJitter3dUtilsTypes.vec3output angle/axis rotation