slint/tests/cases/expr/trigo.slint
Nigel Breslaw 482308f5da
Add Math.atan2 to the inbuilt math function
Math.atan2(y, x) -> angle
2024-08-30 09:55:10 +02:00

43 lines
1.2 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
TestCase := Rectangle {
property <bool> verify:
sin(0) == 0 &&
cos(0) == 1 &&
round(1000* cos(360deg)) == 1000 && round(1000*sin(360deg)) == 0 &&
round(1000* sin(180deg)) == 0 && round(1000*cos(180deg)) == -1000 &&
round(1000 * sin(90deg)) == 1000 && round(1000*cos(90deg)) == 0 &&
round(atan(tan(45deg))/0.1deg) == 450 &&
round(asin(sin(45deg))/0.1deg) == 450 &&
round(acos(cos(45deg))/0.1deg) == 450 &&
atan2(0, 0) == 0 &&
atan2(0, 10) == 0deg &&
atan2(10, 10) == 45deg &&
atan2(10, 0) == 90deg &&
atan2(10, -10) == 135deg &&
atan2(0, -10) == 180deg &&
atan2(-10, -10) == -135deg &&
atan2(-10, 0) == -90deg &&
atan2(-10, 10) == -45deg &&
true;
property <bool> test: verify;
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_verify());
```
```rust
let instance = TestCase::new().unwrap();
assert!(instance.get_verify());
```
```js
var instance = new slint.TestCase({});
assert(instance.verify);
```
*/