Add math functions back to the prelude (#6595)
* Add math functions back to the prelude * Update output * Update docs
This commit is contained in:
@ -1307,7 +1307,7 @@ part001 = startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [3, 4], tag = $seg01)
|
||||
|> line(end = [
|
||||
math::min([segLen(seg01), myVar]),
|
||||
min([segLen(seg01), myVar]),
|
||||
-legLen(hypotenuse = segLen(seg01), leg = myVar)
|
||||
])
|
||||
"#;
|
||||
@ -1322,7 +1322,7 @@ part001 = startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [3, 4], tag = $seg01)
|
||||
|> line(end = [
|
||||
math::min([segLen(seg01), myVar]),
|
||||
min([segLen(seg01), myVar]),
|
||||
legLen(hypotenuse = segLen(seg01), leg = myVar)
|
||||
])
|
||||
"#;
|
||||
@ -1662,7 +1662,7 @@ shape = layer() |> patternTransform(instances = 10, transform = transform)
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_math_execute_with_functions() {
|
||||
let ast = r#"myVar = 2 + math::min([100, -1 + legLen(hypotenuse = 5, leg = 3)])"#;
|
||||
let ast = r#"myVar = 2 + min([100, -1 + legLen(hypotenuse = 5, leg = 3)])"#;
|
||||
let result = parse_execute(ast).await.unwrap();
|
||||
assert_eq!(
|
||||
5.0,
|
||||
|
@ -2081,10 +2081,10 @@ o = 3mm / 3
|
||||
p = 3_ / 4
|
||||
q = 4inch / 2_
|
||||
|
||||
r = math::min([0, 3, 42])
|
||||
s = math::min([0, 3mm, -42])
|
||||
t = math::min([100, 3in, 142mm])
|
||||
u = math::min([3rad, 4in])
|
||||
r = min([0, 3, 42])
|
||||
s = min([0, 3mm, -42])
|
||||
t = min([100, 3in, 142mm])
|
||||
u = min([3rad, 4in])
|
||||
"#;
|
||||
|
||||
let result = parse_execute(program).await.unwrap();
|
||||
@ -2137,10 +2137,10 @@ b = 180 / PI * a + 360
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn cos_coercions() {
|
||||
let program = r#"
|
||||
a = math::cos(units::toRadians(30))
|
||||
a = cos(units::toRadians(30))
|
||||
b = 3 / a
|
||||
c = math::cos(30deg)
|
||||
d = math::cos(30)
|
||||
c = cos(30deg)
|
||||
d = cos(30)
|
||||
"#;
|
||||
|
||||
let result = parse_execute(program).await.unwrap();
|
||||
|
Reference in New Issue
Block a user