mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
0.5.5 Disallow multiple `_` in a row in digits, e.g. `1__000`. #1138. Fixed toposort example. Struct/union members now correctly rejects members without storage size #1147. `math::pow` will now correctly promote integer arguments. `math::pow` will now correctly promote integer arguments. Added `new_aligned` and `alloc_aligned` functions to prevent accidental under-alignment when allocating simd. Pointer difference would fail where alignment != size (structs etc) #1150. Add test that overalignment actually works for lists. Fixed array calculation for npot2 vectors. Use native aligned alloc on Windows and POSIX. Deprecates "offset". Simplification of the Allocator interface.
38 lines
1.3 KiB
Plaintext
38 lines
1.3 KiB
Plaintext
module math_quaternion @test;
|
|
import std::math;
|
|
|
|
fn void test()
|
|
{
|
|
{|
|
|
Quaternion rotation = QUATERNION_IDENTITY;
|
|
Quaternionf rotation_f = QUATERNIONF_IDENTITY;
|
|
assert(rotation.v == {0,0,0,1});
|
|
assert(rotation.v == {0,0,0,1});
|
|
|};
|
|
|
|
{|
|
|
Quaternion rotation = QUATERNION_IDENTITY;
|
|
Matrix4 identity_matrix = MATRIX4_IDENTITY;
|
|
|
|
Quaternionf rotation_f = QUATERNIONF_IDENTITY;
|
|
Matrix4f identity_matrix_f = MATRIX4F_IDENTITY;
|
|
|
|
assert((double[<16>])rotation.to_matrix().m == (double[<16>])identity_matrix.m);
|
|
assert((float[<16>])rotation_f.to_matrixf().m == (float[<16>])identity_matrix_f.m);
|
|
|};
|
|
|
|
{|
|
|
Matrix4 result = {
|
|
0.428571, -0.285714, 0.857143, 0.000000,
|
|
0.857143, 0.428571, -0.285714, 0.000000,
|
|
-0.285714, 0.857143, 0.428571, 0.000000,
|
|
0.000000, 0.000000, 0.000000, 1.000000
|
|
};
|
|
|
|
Matrix4 rotation = Quaternion {0.5, 0.5, 0.5, 1}.to_matrix();
|
|
Matrix4f rotation_f = Quaternionf {0.5, 0.5, 0.5, 1}.to_matrixf();
|
|
|
|
assert(math::round_to_decimals((double[<16>])result.m, 2) == math::round_to_decimals((double[<16>])rotation.m, 2));
|
|
assert(math::round_to_decimals((float[<16>])result.m, 2) == math::round_to_decimals((float[<16>])rotation_f.m, 2));
|
|
|};
|
|
} |