glam 0.5.0

Port of glam-rs: fixed-point vector, matrix and quaternion math for provable games (facade over glam_core, glam_int, glam_swizzles, glam_int_swizzles)

Readme

glam

Port of glam-rs 0.33.8 to Cairo on top of the fixed Q32.32 scalar (registry package fixed 0.5.0): Vec2/3/4, Mat2/3/4, Quat, Affine2/3, BVec*, IVec*, UVec*. Same module, type and method names as glam-rs.

glam is a facade: it re-exports glam_core (vectors, matrices, quaternions, affines, camera, the integer vector types), glam_int (the integer vector methods), glam_swizzles and glam_int_swizzles under the paths of a single crate (glam::vec3::Vec3, glam::Vec3Trait, glam::swizzles::Vec3Swizzles, ...). Depend on glam for everything, or on the smaller crates to pay for less code (glam_core alone is about 18 500 library lines). All five crates share the workspace version.

Progress: docs/PORTING_STATUS.md. Compatible with Cairo 2.20.0.

Gas

Sierra gas (l2 gas, what a transaction pays) and prover cost (steps, range checks) of one call, net of the test overhead (X__op - X__base, see scripts/bench.py), measured with scarb 2.20.1, starknet-foundry 0.64.0 (.tool-versions). Source of truth: gas/*.snap; this region is generated by scripts/gas_tables.py, do not edit it.

Vec2

op l2 gas steps range checks add 2 480 22 4 mul_scalar 4 160 36 8 dot 1 880 16 4 perp_dot 1 880 16 4 length 2 220 18 6 normalize 6 820 57 16 rotate 4 560 40 8 from_angle 31 300 243 62 to_angle 29 630 215 46

Vec3

op l2 gas steps range checks add 3 320 29 6 mul_scalar 5 840 50 12 dot 2 080 18 4 cross 6 440 56 12 length 3 220 28 6 normalize 8 600 72 20 distance 3 520 31 6 lerp 6 740 59 12 reflect 9 560 83 18 angle_between 40 370 312 70

Vec4

op l2 gas steps range checks add 4 160 36 8 mul_scalar 7 520 64 16 dot 3 080 28 4 length 3 420 30 6 normalize 10 380 87 24 lerp 8 720 76 16

Mat2

op l2 gas steps range checks mul_vec2 4 560 40 8 mul_mat2 8 320 72 16 determinant 1 880 16 4 inverse 13 310 105 24 transpose 400 4 0 from_angle 31 700 247 62

Mat3

op l2 gas steps range checks mul_vec3 7 040 62 12 mul_mat3 19 520 170 36 determinant 3 680 34 4 inverse 39 530 328 80 transpose 900 9 0 from_quat 20 540 176 42 from_axis_angle 50 560 409 100 from_rotation_z 32 200 252 62

Mat4

op l2 gas steps range checks mul_vec4 9 920 88 16 mul_mat4 36 480 320 64 transform_point3 7 640 68 12 project_point3 20 470 171 32 determinant 16 260 143 28 inverse 102 490 868 208 transpose 2 400 24 0 from_quat 21 240 183 42 from_rotation_translation 21 240 183 42 look_at_rh 43 770 370 82

Quat

op l2 gas steps range checks mul_quat 9 920 88 16 mul_vec3 9 240 84 12 conjugate 1 000 10 0 normalize 10 380 87 24 slerp 122 180 923 225 lerp 24 120 196 47 from_axis_angle 40 350 312 78 from_rotation_arc 53 610 178 44 from_mat3 19 770 163 42 to_axis_angle 46 080 304 69

Affine2

op l2 gas steps range checks transform_point2 4 960 44 8 transform_vector2 4 560 40 8 mul_affine2 12 480 108 24 inverse 20 630 167 40 from_angle_translation 31 900 249 62

Affine3

op l2 gas steps range checks transform_point3 7 640 68 12 transform_vector3 7 040 62 12 mul_affine3 26 360 230 48 inverse 48 370 408 92 inverse_rigid 8 240 74 12 from_rotation_translation 20 840 179 42 look_to_rh 42 650 363 76

Euler angles (EulerRot, worst case: generic order)

op l2 gas steps range checks Quat::from_euler 110 800 874 214 Quat::to_euler 122 060 898 181 Mat3::from_euler 114 170 897 218 Mat3::to_euler 98 690 704 139 Mat4::from_euler 114 870 904 218

Camera (glam::camera)

op l2 gas steps range checks rh::proj::opengl::perspective 51 350 415 98 rh::proj::vulkan::perspective 50 070 405 94 rh::proj::vulkan::perspective_infinite_reverse 43 650 351 81 rh::proj::opengl::orthographic 22 320 189 48 rh::proj::opengl::frustum 24 390 206 52 rh::view::look_at_mat4 38 640 329 82 rh::view::look_to_mat4 28 620 247 56

Metadata

Version 0.5.0

Uploaded 1 week ago

License MIT

Cairo version ^2.20.0

Size 233.2 KB

Installation

Run the following command in your project dir

scarb add glam@0.5.0

Or add the following line to your Scarb.toml

glam = "0.5.0"

Monthly downloads

Links

Owners