Math module

math_struct_printer

procedure · 1 overloadSource

A struct printer for the types of this module: a vector or quaternion prints as (x, y, z), a plane as its four coefficients and a matrix one row per line (via print_matrix), every number with six decimal places. It returns false for any other type, so the default formatting applies. Install it with context.print_style.struct_printer = math_struct_printer; to make print("%", v) use it.

ExampleOpen in playground ↗
#import "Basic";
context.print_style.struct_printer = math_struct_printer;
text := tprint("%", xyz(1, 2, 3.5));
assert(text == "(1.000000, 2.000000, 3.500000)");
assert(tprint("%", Quaternion.{}) == "(0.000000, 0.000000, 0.000000, 1.000000)");
math_struct_printer :: (
    builder: *String_Builder,
    any: Any,
    user_data: *void
) -> bool

A struct printer for the math types: matrices, vectors, quaternions and planes. Returns false for any other type.

Parameters

builder: *String_Builder
where the text is appended.
any: Any
the value being printed.
user_data: *void
unused.

Returns

bool

See also