abs :: (v: Vec) -> Vec(v.N, v.T)
area :: (c: Circle) -> float
area :: (r: Rect) -> float
ceil :: (l: Vec) -> Vec(l.N, l.T)
clamp :: (v: Vec, low: v.T, high: v.T) -> Vec(v.N, v.T)
collides :: (t: Triangle, l: Line) -> bool #symmetric
collides :: (r: Rect, l: Line) -> bool #symmetric
collides :: (c: Circle, r: Rect) -> bool #symmetric
collides :: (r1: Rect, r2: Rect) -> bool
collides :: (t1: Triangle, t2: Triangle) -> bool
collides :: (t: Triangle, c: Circle) -> bool #symmetric
collides :: (t: Triangle, r: Rect) -> bool #symmetric
collides :: (c: Circle, seg: Line) -> bool #symmetric
collides :: (s1: Line, s2: Line) -> bool
collides :: (c1: Circle, c2: Circle) -> bool
cross :: (a: Vec3, b: Vec3) -> Vec3
cut_bottom :: (rect: *Rect, want: RECT_TYPE) -> Rect
cut_left :: (rect: *Rect, want: RECT_TYPE) -> Rect
cut_right :: (rect: *Rect, want: RECT_TYPE) -> Rect
cut_top :: (rect: *Rect, want: RECT_TYPE) -> Rect
determinate :: (m: Mat4) -> float
determinate :: (m: Mat2) -> float
dot :: (a: Vec, b: Vec(a.N, a.T)) -> a.T
dot :: (a: Quat, b: Quat) -> float
ease :: (progress: $T, $$ease: Ease = .linear, $$transition: Transition = .in) -> T
float_eq :: (f: float, with: float) -> bool
floor :: (l: Vec) -> Vec(l.N, l.T)
gjk :: (s1: []Vec2, s2: []Vec2) -> bool
inside :: (c: Circle, p: Vec2) -> bool #symmetric
inside :: (r: Rect, p: Vec2) -> bool #symmetric
inside :: (t: Triangle, p: Vec2) -> bool #symmetric
inverse :: (q: Quat) -> Quat
inverse :: (m: Mat4) -> Mat4
inverse :: (m: Mat2) -> Mat2
inverse_unit :: (q: Quat) -> Quat
length :: (q: Quat) -> float
length :: (v: Vec) -> float
length_squared :: (v: Vec) -> float
length_squared :: (q: Quat) -> float
lerp :: (a: Vec, b: Vec(a.N, a.T), t: float) -> Vec(a.N, a.T)
make_look_at :: (camera: Vec3, at: Vec3, up_vector: Vec3) -> Mat4
make_rect :: (x: RECT_TYPE, y: RECT_TYPE, w: RECT_TYPE, h: RECT_TYPE) -> Rect
max :: (l: Vec, r: l.T) -> Vec(l.N, l.T)
max :: (x: float, y: float) -> float
max :: (l: Vec, r: Vec(l.N, l.T)) -> Vec(l.N, l.T)
min :: (l: Vec, r: Vec(l.N, l.T)) -> Vec(l.N, l.T)
min :: (l: Vec, r: l.T) -> Vec(l.N, l.T)
min :: (x: float, y: float) -> float
mul_sse :: (a: Mat4, b: Mat4) -> Mat4
mul_sse_aligned :: (dst: *Mat4, a: *Mat4, b: *Mat4)
normalize :: (v: Vec) -> Vec(v.N, v.T)
operator* :: (q: Quat, v: Vec3) -> Vec3 #symmetric
operator* :: (a: Mat2, b: Mat2) -> Mat2
operator* :: (a: Mat2, b: Vec2) -> Vec2
operator* :: (q: Quat, r: $T) -> Quat #symmetric
operator* :: (a: Mat4, v: Vec4) -> Vec4
operator* :: (a: Quat, b: Quat) -> Quat
operator* :: (a: Mat4, b: Mat4) -> Mat4
operator* :: (l: Vec, r: $R) -> Vec(l.N, l.T) #symmetric
operator* :: (l: Vec, r: Vec(l.N, l.T)) -> Vec(l.N, l.T)
operator*[] :: (v: *Vec, $$idx: int) -> *v.T
operator*[] :: (m: *Mat4, $$idx: int) -> *Vec4
operator*[] :: (m: *Mat2, $$idx: int) -> *Vec2
operator+ :: (a: Quat, b: Quat) -> Quat
operator+ :: (l: Vec, r: $R) -> Vec(l.N, l.T) #symmetric
operator+ :: (l: Vec, r: Vec(l.N, l.T)) -> Vec(l.N, l.T)
operator- :: (l: Vec, r: $R) -> Vec(l.N, l.T)
operator- :: (q: Quat) -> Quat
operator- :: (v: Vec) -> Vec(v.N, v.T)
operator- :: (l: Vec, r: Vec(l.N, l.T)) -> Vec(l.N, l.T)
operator- :: (l: $R, r: Vec) -> Vec(l.N, l.T)
operator/ :: (l: Vec, r: Vec(l.N, l.T)) -> Vec(l.N, l.T)
operator/ :: (l: Quat, r: $T) -> Quat
operator/ :: (l: Vec, r: $R) -> Vec(l.N, l.T)
operator== :: (l: Vec, r: Vec(l.N, l.T)) -> bool
operator== :: (l: Quat, r: Quat) -> bool
operator== :: (a: Mat2, b: Mat2) -> bool
operator== :: (a: Mat4, b: Mat4) -> bool
operator[] :: (v: Vec, $$idx: int) -> v.T
operator[]= :: (m: *Mat4, $$idx: int, value: Vec4)
operator[]= :: (v: *Vec, $$idx: int, value: v.T)
operator[]= :: (m: *Mat2, $$idx: int, value: Vec2)
orthographic_projection :: (left: float, right: float, top: float, bottom: float, near: float, far: float, $$depth_01: bool) -> Mat4
perspective_projection :: (aspect: float, fov: float, near: float, far: float, $$depth_01: bool) -> Mat4
perspective_projection_left_handed :: (aspect: float, fov: float, near: float, far: float, $$depth_01: bool) -> Mat4
reflect :: (v: Vec2, p: Vec2) -> Vec2
reflect :: (v: Vec3, p: Vec3) -> Vec3
rotation_mat2 :: (angle: float) -> Mat2
rotation_mat4 :: (q: Quat) -> Mat4
rotation_mat4 :: (axis: Vec3, angle: float) -> Mat4
rotation_quat :: (theta: float, axis: Vec3) -> Quat
round :: (v: Vec($N, $T)) -> Vec(N, T)
same_dir :: (a: Vec2, b: Vec2) -> bool
same_dir :: (a: Vec3, b: Vec3) -> bool
sign :: (x: float) -> float
slerp :: (a: Quat, _b: Quat, t: float) -> Quat
translate :: (with: Vec3) -> Mat4
translate :: (from: Mat4, with: Vec3) -> Mat4
transpose :: (m: Mat2) -> Mat2
transpose :: (m: Mat4) -> Mat4
v2_eq :: (a: Vec2, b: Vec2) -> bool
v3_eq :: (a: Vec3, b: Vec3) -> bool
v4_eq :: (a: Vec4, b: Vec4) -> bool
asin :: (ang: float) -> float #expand
atan2 :: (y: float, x: float) -> float #expand
conjugate :: (q: Quat) -> Quat #expand
cos :: (ang: float) -> float #expand
deg_to_rad :: (deg: float) -> float #expand
deg_to_rad :: (deg: float64) -> float #expand
for_expansion :: (v: *Vec, body: Code, flags: For_Flags) #expand
m2 :: (r0: Vec2, r1: Vec2) -> Mat2 #expand
m2 :: (_xx: float, xy: float, yx: float, yy: float) -> Mat2 #expand
m2d :: (diag: float) -> Mat2 #expand
m4 :: (r0: Vec4, r1: Vec4, r2: Vec4, r3: Vec4) -> Mat4 #expand
m4d :: (diag: float) -> Mat4 #expand
operator[] :: (m: Mat2, idx: int) -> Vec2 #expand
operator[] :: (m: Mat4, idx: int) -> Vec4 #expand
quat :: (xyz: Vec3, w: float) -> Quat #expand
quat :: (x: float = 0, y: float = 0, z: float = 0, w: float = 1) -> Quat #expand
rad_to_deg :: (rad: float) -> float #expand
rad_to_deg :: (rad: float64) -> float #expand
rad_to_rad :: (rad: float) -> float #expand
rad_to_rad :: (rad: float64) -> float #expand
rad_to_turn :: (rad: float64) -> float #expand
rad_to_turn :: (rad: float) -> float #expand
sin :: (ang: float) -> float #expand
turn_to_rad :: (turns: float) -> float #expand
turn_to_rad :: (turns: float64) -> float #expand
v2f :: (x: $T = 0, y: T = 0) -> Vec2 #expand
v2i :: (x: $T = 0, y: T = 0) -> Vec(2, T) #expand
v3f :: (x: $T = 0, y: T = 0, z: T = 0) -> Vec3 #expand
v3i :: (x: $T = 0, y: T = 0, z: T = 0) -> Vec(3, T) #expand
v4f :: (v: Vec3, $$w: float) -> Vec4 #expand
v4f :: (x: $T = 0, y: T = 0, z: T = 0, w: T = 0) -> Vec4 #expand
v4i :: (x: $T = 0, y: T = 0, z: T = 0, w: T = 0) -> Vec(4, T) #expand
Circle :: struct {
x,y,r: float;
#place x;
pos: Vec2;
}
Ease :: enum {
linear;
quad;
cubic;
quart;
quint;
expo;
sine;
circ;
back;
elastic;
}
Line :: struct {
x0,y0,x1,y1: float;
#place x0;
a: Vec2;
#place x1;
b: Vec2;
#place x0;
e: [2]Vec2;
}
Mat2 :: #type,distinct Vec(2 * 2, float);
Mat4 :: #type,distinct Vec(4 * 4, float);
Quat :: #type,distinct Vec4; // Note(Jesse): I Had to make this distinct, otherwise operators stomp on eachother
Rect :: #type,distinct Vec(4, RECT_TYPE);
Transition :: enum {
in;
out;
in_out;
}
Vec :: struct(N: int, T: Type)
#modify {
info := T.(*Type_Info);
return info.type == .INTEGER || info.type == .FLOAT, "Vec T must be a numeric type (int or float)";
} {
#assert (N > 0) "Vec N cannot be <= 0";
// Vecs are backed by an array internally. The #insert block below
// generates #place'd unions of named fields or cN fields when N is > 4.
#as components: [N]T;
#insert -> string {
b: basic.String_Builder;
basic.append(*b, "#place components;\n");
fields :: []string.[
string.[ "x", "r", "u", "min_x", "" ],
string.[ "y", "g", "v", "min_y", "" ],
string.[ "z", "b", "d", "max_x", "width" ],
string.[ "w", "a", "" , "max_y", "height" ],
];
for i: 0..N - 1 {
if i < fields.count {
basic.append(*b, "union {\n");
for field: fields[i] if field.count != 0 {
basic.print_to_builder(*b, "\t%: T = ---;\n", field);
}
basic.print_to_builder(*b, "\tc%: T = ---;\n", i);
basic.append(*b, "};\n");
}
else {
basic.print_to_builder(*b, "c%: T = ---;\n", i);
}
}
// compound accessors
basic.append(*b, "#place components;\n");
if N >= 4 {
basic.append(*b, "union {\n");
basic.append(*b, "\txy: Vec2 = ---;\n");
basic.append(*b, "\txyz: Vec3 = ---;\n");
basic.append(*b, "};");
}
else if N >= 3 {
basic.append(*b, "xy: T = ---;\n");
}
// Vec4 row accessors (Possibly becoming/used as SIMD lanes)
if N/4 > 1 {
basic.append(*b, "#place components;\n");
basic.print_to_builder(*b, "v4: [%]Vec4 = ---;\n", N/4);
}
// Matrix Accessors
if N == 4 { // Mat2
basic.append(*b, "#place components;\n");
for i: 0..3 {
basic.print_to_builder(*b, "_%0%: T = ---;\n", i/2, i%2);
}
}
if N == 16 { // Mat4
basic.append(*b, "#place components;\n");
for i: 0..15 {
basic.print_to_builder(*b, "_%0%: T = ---;\n", i/4, i%4);
}
}
return basic.builder_to_string(*b);
};
}