Module maths

Source
Expand description

Vec2, 3 and4, Quat and Matrix, Bounds, Plane and Ray related structs, enums and functions.

§Examples

which are also unit tests:

Matrix Bounds Plane Pose Sphere Ray Intersect Meshes Intersect Model

Modules§

units

Structs§

Bounds
Bounds is an axis aligned bounding box type that can be used for storing the sizes of objects, calculating containment, intersections, and more!
Plane
Planes are really useful for collisions, intersections, and visibility testing!
Pose
Pose represents a location and orientation in space, excluding scale! The default value of a Pose use Pose.Identity . https://stereokit.net/Pages/StereoKit/Pose.html
Quat
Quaternions are efficient and robust mathematical objects for representing rotations! Understanding the details of how a quaternion works is not generally necessary for using them effectively, so don’t worry too much if they seem weird to you. They’re weird to me too.
Ray
A position and a direction indicating a ray through space! This is a great tool for intersection testing with geometrical shapes. https://stereokit.net/Pages/StereoKit/Ray.html
Rect
A pretty straightforward 2D rectangle, defined by the top left corner of the rectangle, and its width/height. https://stereokit.net/Pages/StereoKit/Rect.html
Sphere
Represents a sphere in 3D space! Composed of a center point and a radius, can be used for raycasting, collision, visibility, and other things! https://stereokit.net/Pages/StereoKit/Sphere.html
Vec2
A vector with 2 components: x and y. This can represent a point in 2D space, a directional vector, or any other sort of value with 2 dimensions to it! https://stereokit.net/Pages/StereoKit/Vec2.html
Vec3
A vector with 3 components: x, y, z. This can represent a point in space, a directional vector, or any other sort of value with 3 dimensions to it!
Vec4
A vector with 4 components: x, y, z, and w. Can be useful for things like shaders, where the registers are aligned to 4 float vectors.

Functions§

angle_dist
Calculates the minimum angle ‘distance’ between two angles. This covers wraparound cases like: the minimum distance between 10 and 350 is 20. https://stereokit.net/Pages/StereoKit/SKMath/AngleDist.html
bounds_capsule_contains
bounds_grow_to_fit_box
bounds_grow_to_fit_pt
bounds_line_contains
bounds_point_contains
bounds_ray_intersect
bounds_transform
lerp
Blends (Linear Interpolation) between two scalars, based on a ‘blend’ value, where 0 is a, and 1 is b. Doesn’t clamp percent for you. https://stereokit.net/Pages/StereoKit/SKMath/Lerp.html
matrix_decompose
matrix_extract_pose
matrix_extract_rotation
matrix_extract_scale
matrix_extract_translation
matrix_inverse
matrix_invert
matrix_mul
matrix_mul_direction
matrix_orthographic
matrix_perspective
matrix_r
matrix_s
matrix_t
matrix_to_angles
matrix_transform_dir
matrix_transform_pose
matrix_transform_pt
matrix_transform_pt4
matrix_transform_quat
matrix_transform_ray
matrix_transpose
matrix_trs
matrix_trs_out
matrix_ts
plane_from_points
plane_from_ray
plane_line_intersect
plane_point_closest
plane_ray_intersect
pose_matrix_out
quat_difference
quat_from_angles
quat_inverse
quat_lookat
quat_lookat_up
quat_mul
quat_mul_vec
quat_normalize
quat_slerp
quat_to_axis_angle
ray_from_mouse
ray_intersect_plane
ray_point_closest
sphere_point_contains
sphere_ray_intersect
vec3_cross

Type Aliases§

Bool32T
Native code use this as bool

Unions§

Matrix
A Matrix in StereoKit is a 4x4 grid of numbers that is used to represent a transformation for any sort of position or vector! This is an oversimplification of what a matrix actually is, but it’s accurate in this case.