Add a format function to vector and matrix structs #1240

Open
opened 2024-08-07 21:44:17 +00:00 by hordurj · 0 comments
hordurj commented 2024-08-07 21:44:17 +00:00 (Migrated from github.com)

It would be convenient to include a format function in Vec and Mat structs (and other similar types) for easy printing of these types (std.debug.print, allocPrint, etc).

Default for Vec2 is:
math.vec.Vec(2,f32){ .v = { 1e0, 2e0 } }

A more compact Vec2 output:
[1.0 2.1]
or
1.0, 2.1
or
1.0 2.1

Mat2x2:
1.0, 0.0], [0.0, 1.0
or
[1.0 0.0] [0.0, 1.0]

Or something along these lines.

https://ziglang.org/documentation/master/std/#std.fmt.Formatter

It would be convenient to include a format function in Vec and Mat structs (and other similar types) for easy printing of these types (std.debug.print, allocPrint, etc). Default for Vec2 is: math.vec.Vec(2,f32){ .v = { 1e0, 2e0 } } A more compact Vec2 output: [1.0 2.1] or 1.0, 2.1 or 1.0 2.1 Mat2x2: [[1.0, 0.0], [0.0, 1.0]] or [1.0 0.0] [0.0, 1.0] Or something along these lines. https://ziglang.org/documentation/master/std/#std.fmt.Formatter
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#1240
No description provided.