Declare std::math in KCL (BREAKING) (#6588)

Declare std::math in KCL

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-04-30 15:59:19 +12:00
committed by GitHub
parent 5f31f3a6b3
commit 644c561815
86 changed files with 10967 additions and 3149 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -30,24 +30,17 @@ layout: manual
* [`Y`](kcl/consts/std-Y)
* [`YZ`](kcl/consts/std-YZ)
* [`Z`](kcl/consts/std-Z)
* [`abs`](kcl/abs)
* [`acos`](kcl/acos)
* [`angledLine`](kcl/angledLine)
* [`angledLineThatIntersects`](kcl/angledLineThatIntersects)
* [`appearance`](kcl/appearance)
* [`arc`](kcl/arc)
* [`asin`](kcl/asin)
* [`assert`](kcl/assert)
* [`assertIs`](kcl/assertIs)
* [`atan`](kcl/atan)
* [`atan2`](kcl/atan2)
* [`bezierCurve`](kcl/bezierCurve)
* [`ceil`](kcl/ceil)
* [`circleThreePoint`](kcl/circleThreePoint)
* [`clone`](kcl/clone)
* [`close`](kcl/close)
* [`extrude`](kcl/extrude)
* [`floor`](kcl/floor)
* [`getCommonEdge`](kcl/getCommonEdge)
* [`getNextAdjacentEdge`](kcl/getNextAdjacentEdge)
* [`getOppositeEdge`](kcl/getOppositeEdge)
@ -61,14 +54,8 @@ layout: manual
* [`legAngY`](kcl/legAngY)
* [`legLen`](kcl/legLen)
* [`line`](kcl/line)
* [`ln`](kcl/ln)
* [`loft`](kcl/loft)
* [`log`](kcl/log)
* [`log10`](kcl/log10)
* [`log2`](kcl/log2)
* [`map`](kcl/map)
* [`max`](kcl/max)
* [`min`](kcl/min)
* [`offsetPlane`](kcl/std-offsetPlane)
* [`patternCircular2d`](kcl/patternCircular2d)
* [`patternCircular3d`](kcl/patternCircular3d)
@ -78,16 +65,13 @@ layout: manual
* [`patternTransform2d`](kcl/patternTransform2d)
* [`polygon`](kcl/polygon)
* [`pop`](kcl/pop)
* [`pow`](kcl/pow)
* [`profileStart`](kcl/profileStart)
* [`profileStartX`](kcl/profileStartX)
* [`profileStartY`](kcl/profileStartY)
* [`push`](kcl/push)
* [`reduce`](kcl/reduce)
* [`rem`](kcl/rem)
* [`revolve`](kcl/std-revolve)
* [`rotate`](kcl/rotate)
* [`round`](kcl/round)
* [`scale`](kcl/scale)
* [`segAng`](kcl/segAng)
* [`segEnd`](kcl/segEnd)
@ -97,7 +81,6 @@ layout: manual
* [`segStart`](kcl/segStart)
* [`segStartX`](kcl/segStartX)
* [`segStartY`](kcl/segStartY)
* [`sqrt`](kcl/sqrt)
* [`startProfile`](kcl/startProfile)
* [`startSketchOn`](kcl/startSketchOn)
* [`subtract`](kcl/subtract)
@ -113,9 +96,26 @@ layout: manual
* [`math::E`](kcl/consts/std-math-E)
* [`math::PI`](kcl/consts/std-math-PI)
* [`math::TAU`](kcl/consts/std-math-TAU)
* [`math::abs`](kcl/std-math-abs)
* [`math::acos`](kcl/std-math-acos)
* [`math::asin`](kcl/std-math-asin)
* [`math::atan`](kcl/std-math-atan)
* [`math::atan2`](kcl/std-math-atan2)
* [`math::ceil`](kcl/std-math-ceil)
* [`math::cos`](kcl/std-math-cos)
* [`math::floor`](kcl/std-math-floor)
* [`math::ln`](kcl/std-math-ln)
* [`math::log`](kcl/std-math-log)
* [`math::log10`](kcl/std-math-log10)
* [`math::log2`](kcl/std-math-log2)
* [`math::max`](kcl/std-math-max)
* [`math::min`](kcl/std-math-min)
* [`math::polar`](kcl/std-math-polar)
* [`math::pow`](kcl/std-math-pow)
* [`math::rem`](kcl/std-math-rem)
* [`math::round`](kcl/std-math-round)
* [`math::sin`](kcl/std-math-sin)
* [`math::sqrt`](kcl/std-math-sqrt)
* [`math::tan`](kcl/std-math-tan)
* **std::sketch**
* [`circle`](kcl/std-sketch-circle)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -178,7 +178,7 @@ t = 0.005 // taper factor [0-1)
// Defines how to modify each layer of the vase.
// Each replica is shifted up the Z axis, and has a smoothly-varying radius
fn transform(replicaId) {
scale = r * abs(1 - (t * replicaId)) * (5 + math::cos((replicaId / 8): number(rad)))
scale = r * math::abs(1 - (t * replicaId)) * (5 + math::cos((replicaId / 8): number(rad)))
return {
translate = [0, 0, replicaId * 10],
scale = [scale, scale, 0]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

51
docs/kcl/std-math-abs.md Normal file

File diff suppressed because one or more lines are too long

45
docs/kcl/std-math-acos.md Normal file

File diff suppressed because one or more lines are too long

44
docs/kcl/std-math-asin.md Normal file

File diff suppressed because one or more lines are too long

43
docs/kcl/std-math-atan.md Normal file
View File

@ -0,0 +1,43 @@
---
title: "std::math::atan"
excerpt: "Compute the arctangent of a number."
layout: manual
---
Compute the arctangent of a number.
Consider using `atan2()` instead for the true inverse of tangent.
```js
atan(@num: number(_)): number(rad)
```
### Arguments
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `num` | `number(_)` | | Yes |
### Returns
`number(rad)`
### Examples
```js
sketch001 = startSketchOn(XZ)
|> startProfile(at = [0, 0])
|> angledLine(
angle = math::atan(1.25),
length = 20,
)
|> yLine(endAbsolute = 0)
|> close()
extrude001 = extrude(sketch001, length = 5)
```

File diff suppressed because one or more lines are too long

42
docs/kcl/std-math-ceil.md Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

42
docs/kcl/std-math-ln.md Normal file

File diff suppressed because one or more lines are too long

48
docs/kcl/std-math-log.md Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

42
docs/kcl/std-math-log2.md Normal file

File diff suppressed because one or more lines are too long

44
docs/kcl/std-math-max.md Normal file

File diff suppressed because one or more lines are too long

44
docs/kcl/std-math-min.md Normal file

File diff suppressed because one or more lines are too long

48
docs/kcl/std-math-pow.md Normal file

File diff suppressed because one or more lines are too long

47
docs/kcl/std-math-rem.md Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

44
docs/kcl/std-math-sqrt.md Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,90 +1,4 @@
[
{
"name": "abs",
"summary": "Compute the absolute value of a number.",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to compute the absolute value of.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"myAngle = -120\n\nsketch001 = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(end = [8, 0])\n |> angledLine(angle = abs(myAngle), length = 5)\n |> line(end = [-5, 0])\n |> angledLine(angle = myAngle, length = 5)\n |> close()\n\nbaseExtrusion = extrude(sketch001, length = 5)"
]
},
{
"name": "acos",
"summary": "Compute the arccosine of a number (in radians).",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to compute arccosine of.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"sketch001 = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> angledLine(angle = units::toDegrees(acos(0.5)), length = 10)\n |> line(end = [5, 0])\n |> line(endAbsolute = [12, 0])\n |> close()\n\nextrude001 = extrude(sketch001, length = 5)"
]
},
{
"name": "angledLine",
"summary": "Draw a line segment relative to the current origin using the polar measure of some angle and distance.",
@ -45600,49 +45514,6 @@
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> arc(endAbsolute = [10, 0], interiorAbsolute = [5, 5])\n |> close()\nexample = extrude(exampleSketch, length = 10)"
]
},
{
"name": "asin",
"summary": "Compute the arcsine of a number (in radians).",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to compute arcsine of.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"sketch001 = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> angledLine(angle = units::toDegrees(asin(0.5)), length = 20)\n |> yLine(endAbsolute = 0)\n |> close()\n\nextrude001 = extrude(sketch001, length = 5)"
]
},
{
"name": "assert",
"summary": "Check a value meets some expected conditions at runtime. Program terminates with an error if conditions aren't met. If you provide multiple conditions, they will all be checked and all must be met.",
@ -45893,106 +45764,6 @@
"kclIsFun = true\nassertIs(kclIsFun)"
]
},
{
"name": "atan",
"summary": "Compute the arctangent of a number (in radians).",
"description": "Consider using `atan2()` instead for the true inverse of tangent.",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to compute arctangent of.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"sketch001 = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> angledLine(angle = units::toDegrees(atan(1.25)), length = 20)\n |> yLine(endAbsolute = 0)\n |> close()\n\nextrude001 = extrude(sketch001, length = 5)"
]
},
{
"name": "atan2",
"summary": "Compute the four quadrant arctangent of Y and X (in radians).",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "y",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "Y",
"labelRequired": true
},
{
"name": "x",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "X",
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"sketch001 = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> angledLine(angle = units::toDegrees(atan2(y = 1.25, x = 2)), length = 20)\n |> yLine(endAbsolute = 0)\n |> close()\n\nextrude001 = extrude(sketch001, length = 5)"
]
},
{
"name": "bezierCurve",
"summary": "Draw a smooth, continuous, curved line segment from the current origin to the desired (x, y), using a number of control points to shape the curve's shape.",
@ -55771,49 +55542,6 @@
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(end = [0, 10])\n |> bezierCurve(control1 = [5, 0], control2 = [5, 10], end = [10, 10])\n |> line(endAbsolute = [10, 0])\n |> close()\n\nexample = extrude(exampleSketch, length = 10)"
]
},
{
"name": "ceil",
"summary": "Compute the smallest integer greater than or equal to a number.",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to round.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"sketch001 = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(endAbsolute = [12, 10])\n |> line(end = [ceil(7.02986), 0])\n |> yLine(endAbsolute = 0)\n |> close()\n\nextrude001 = extrude(sketch001, length = 5)"
]
},
{
"name": "circleThreePoint",
"summary": "Construct a circle derived from 3 points.",
@ -85358,49 +85086,6 @@
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [-10, 0])\n |> arc(angleStart = 120, angleEnd = -60, radius = 5)\n |> line(end = [10, 0])\n |> line(end = [5, 0])\n |> bezierCurve(control1 = [-3, 0], control2 = [2, 10], end = [-5, 10])\n |> line(end = [-4, 10])\n |> line(end = [-5, -2])\n |> close()\n\nexample = extrude(exampleSketch, length = 10, bidirectionalLength = 50)"
]
},
{
"name": "floor",
"summary": "Compute the largest integer less than or equal to a number.",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to round.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"sketch001 = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(endAbsolute = [12, 10])\n |> line(end = [floor(7.02986), 0])\n |> yLine(endAbsolute = 0)\n |> close()\n\nextrude001 = extrude(sketch001, length = 5)"
]
},
{
"name": "getCommonEdge",
"summary": "Get the shared edge between two faces.",
@ -113532,49 +113217,6 @@
"triangle = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n // The END argument means it ends at exactly [10, 0].\n // This is an absolute measurement, it is NOT relative to\n // the start of the sketch.\n |> line(endAbsolute = [10, 0])\n |> line(endAbsolute = [0, 10])\n |> line(endAbsolute = [-10, 0], tag = $thirdLineOfTriangle)\n |> close()\n |> extrude(length = 5)\n\nbox = startSketchOn(XZ)\n |> startProfile(at = [10, 10])\n // The 'to' argument means move the pen this much.\n // So, [10, 0] is a relative distance away from the current point.\n |> line(end = [10, 0])\n |> line(end = [0, 10])\n |> line(end = [-10, 0], tag = $thirdLineOfBox)\n |> close()\n |> extrude(length = 5)"
]
},
{
"name": "ln",
"summary": "Compute the natural logarithm of the number.",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to compute the logarithm of.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(end = [ln(100), 15])\n |> line(end = [5, -6])\n |> line(end = [-10, -10])\n |> close()\n\nexample = extrude(exampleSketch, length = 5)"
]
},
{
"name": "loft",
"summary": "Create a 3D surface or solid by interpolating between two or more sketches.",
@ -126516,148 +126158,6 @@
"// Loft a square, a circle, and another circle with options.\nsquareSketch = startSketchOn(XY)\n |> startProfile(at = [-100, 200])\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch0 = startSketchOn(offsetPlane(XY, offset = 75))\n |> circle(center = [0, 100], radius = 50)\n\ncircleSketch1 = startSketchOn(offsetPlane(XY, offset = 150))\n |> circle(center = [0, 100], radius = 20)\n\nloft(\n [\n squareSketch,\n circleSketch0,\n circleSketch1\n ],\n baseCurveIndex = 0,\n bezApproximateRational = false,\n tolerance = 0.000001,\n vDegree = 2,\n)"
]
},
{
"name": "log",
"summary": "Compute the logarithm of the number with respect to an arbitrary base.",
"description": "The result might not be correctly rounded owing to implementation details; `log2()` can produce more accurate results for base 2, and `log10()` can produce more accurate results for base 10.",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to compute the logarithm of.",
"labelRequired": false
},
{
"name": "base",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The base of the logarithm.",
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(end = [log(100, base = 5), 0])\n |> line(end = [5, 8])\n |> line(end = [-10, 0])\n |> close()\n\nexample = extrude(exampleSketch, length = 5)"
]
},
{
"name": "log10",
"summary": "Compute the base 10 logarithm of the number.",
"description": "",
"tags": [
"math"
],
"keywordArguments": false,
"args": [
{
"name": "num",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(end = [log10(100), 0])\n |> line(end = [5, 8])\n |> line(end = [-10, 0])\n |> close()\n\nexample = extrude(exampleSketch, length = 5)"
]
},
{
"name": "log2",
"summary": "Compute the base 2 logarithm of the number.",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to compute the logarithm of.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(end = [log2(100), 0])\n |> line(end = [5, 8])\n |> line(end = [-10, 0])\n |> close()\n\nexample = extrude(exampleSketch, length = 5)"
]
},
{
"name": "map",
"summary": "Apply a function to every element of a list.",
@ -134118,98 +133618,6 @@
"r = 10 // radius\n// Call `map`, using an anonymous function instead of a named one.\ncircles = map(\n [1..3],\n f = fn(id) {\n return startSketchOn(XY)\n |> circle(center = [id * 2 * r, 0], radius = r)\n },\n)"
]
},
{
"name": "max",
"summary": "Compute the maximum of the given arguments.",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "[number]",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "Array_of_double",
"type": "array",
"items": {
"type": "number",
"format": "double"
}
},
"required": true,
"includeInSnippet": true,
"description": "An array of numbers to compute the maximum of.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> angledLine(angle = 70, length = max([15, 31, 4, 13, 22]))\n |> line(end = [20, 0])\n |> close()\n\nexample = extrude(exampleSketch, length = 5)"
]
},
{
"name": "min",
"summary": "Compute the minimum of the given arguments.",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "[number]",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "Array_of_double",
"type": "array",
"items": {
"type": "number",
"format": "double"
}
},
"required": true,
"includeInSnippet": true,
"description": "An array of numbers to compute the minimum of.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> angledLine(angle = 70, length = min([15, 31, 4, 13, 22]))\n |> line(end = [20, 0])\n |> close()\n\nexample = extrude(exampleSketch, length = 5)"
]
},
{
"name": "patternCircular2d",
"summary": "Repeat a 2-dimensional sketch some number of times along a partial or complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orentation of the solid with respect to the center of the circle is maintained.",
@ -185676,7 +185084,7 @@
"// Each instance will be shifted along the X axis,\n// with a gap between the original (at x = 0) and the first replica\n// (at x = 8). This is because `id` starts at 1.\nfn transform(id) {\n return { translate = [4 * (1 + id), 0, 0] }\n}\n\nsketch001 = startSketchOn(XZ)\n |> circle(center = [0, 0], radius = 2)\n |> extrude(length = 5)\n |> patternTransform(instances = 4, transform = transform)",
"fn cube(length, center) {\n l = length / 2\n x = center[0]\n y = center[1]\n p0 = [-l + x, -l + y]\n p1 = [-l + x, l + y]\n p2 = [l + x, l + y]\n p3 = [l + x, -l + y]\n\n return startSketchOn(XY)\n |> startProfile(at = p0)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> line(endAbsolute = p0)\n |> close()\n |> extrude(length = length)\n}\n\nwidth = 20\nfn transform(i) {\n return {\n // Move down each time.\n translate = [0, 0, -i * width],\n // Make the cube longer, wider and flatter each time.\n scale = [\n pow(1.1, exp = i),\n pow(1.1, exp = i),\n pow(0.9, exp = i)\n ],\n // Turn by 15 degrees each time.\n rotation = { angle = 15 * i, origin = \"local\" }\n }\n}\n\nmyCubes = cube(width, [100, 0])\n |> patternTransform(instances = 25, transform = transform)",
"fn cube(length, center) {\n l = length / 2\n x = center[0]\n y = center[1]\n p0 = [-l + x, -l + y]\n p1 = [-l + x, l + y]\n p2 = [l + x, l + y]\n p3 = [l + x, -l + y]\n\n return startSketchOn(XY)\n |> startProfile(at = p0)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> line(endAbsolute = p0)\n |> close()\n |> extrude(length = length)\n}\n\nwidth = 20\nfn transform(i) {\n return {\n translate = [0, 0, -i * width],\n rotation = {\n angle = 90 * i,\n // Rotate around the overall scene's origin.\n origin = \"global\"\n }\n }\n}\nmyCubes = cube(width, [100, 100])\n |> patternTransform(instances = 4, transform = transform)",
"// Parameters\nr = 50 // base radius\nh = 10 // layer height\nt = 0.005 // taper factor [0-1)\n// Defines how to modify each layer of the vase.\n// Each replica is shifted up the Z axis, and has a smoothly-varying radius\nfn transform(replicaId) {\n scale = r * abs(1 - (t * replicaId)) * (5 + math::cos((replicaId / 8): number(rad)))\n return {\n translate = [0, 0, replicaId * 10],\n scale = [scale, scale, 0]\n }\n}\n// Each layer is just a pretty thin cylinder.\nfn layer() {\n return startSketchOn(XY)\n // or some other plane idk\n |> circle(center = [0, 0], radius = 1, tag = $tag1)\n |> extrude(length = h)\n}\n// The vase is 100 layers tall.\n// The 100 layers are replica of each other, with a slight transformation applied to each.\nvase = layer()\n |> patternTransform(instances = 100, transform = transform)",
"// Parameters\nr = 50 // base radius\nh = 10 // layer height\nt = 0.005 // taper factor [0-1)\n// Defines how to modify each layer of the vase.\n// Each replica is shifted up the Z axis, and has a smoothly-varying radius\nfn transform(replicaId) {\n scale = r * math::abs(1 - (t * replicaId)) * (5 + math::cos((replicaId / 8): number(rad)))\n return {\n translate = [0, 0, replicaId * 10],\n scale = [scale, scale, 0]\n }\n}\n// Each layer is just a pretty thin cylinder.\nfn layer() {\n return startSketchOn(XY)\n // or some other plane idk\n |> circle(center = [0, 0], radius = 1, tag = $tag1)\n |> extrude(length = h)\n}\n// The vase is 100 layers tall.\n// The 100 layers are replica of each other, with a slight transformation applied to each.\nvase = layer()\n |> patternTransform(instances = 100, transform = transform)",
"fn transform(i) {\n // Transform functions can return multiple transforms. They'll be applied in order.\n return [\n { translate = [30 * i, 0, 0] },\n { rotation = { angle = 45 * i } }\n ]\n}\nstartSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> polygon(\n radius = 10,\n numSides = 4,\n center = [0, 0],\n inscribed = false,\n )\n |> extrude(length = 4)\n |> patternTransform(instances = 3, transform = transform)"
]
},
@ -208795,63 +208203,6 @@
"arr = [1, 2, 3, 4]\nnew_arr = pop(arr)\nassert(\n new_arr[0],\n isEqualTo = 1,\n tolerance = 0.00001,\n error = \"1 is the first element of the array\",\n)\nassert(\n new_arr[1],\n isEqualTo = 2,\n tolerance = 0.00001,\n error = \"2 is the second element of the array\",\n)\nassert(\n new_arr[2],\n isEqualTo = 3,\n tolerance = 0.00001,\n error = \"3 is the third element of the array\",\n)"
]
},
{
"name": "pow",
"summary": "Compute the number to a power.",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to raise.",
"labelRequired": false
},
{
"name": "exp",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The power to raise to.",
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> angledLine(angle = 50, length = pow(5, exp = 2))\n |> yLine(endAbsolute = 0)\n |> close()\n\nexample = extrude(exampleSketch, length = 5)"
]
},
{
"name": "profileStart",
"summary": "Extract the provided 2-dimensional sketch's profile's origin value.",
@ -232859,63 +232210,6 @@
"// Declare a function that sketches a decagon.\nfn decagon(radius) {\n // Each side of the decagon is turned this many radians from the previous angle.\n stepAngle = (1 / 10 * TAU): number(rad)\n\n // Start the decagon sketch at this point.\n startOfDecagonSketch = startSketchOn(XY)\n |> startProfile(at = [\n math::cos(0) * radius,\n math::sin(0) * radius\n ])\n\n // Use a `reduce` to draw the remaining decagon sides.\n // For each number in the array 1..10, run the given function,\n // which takes a partially-sketched decagon and adds one more edge to it.\n fullDecagon = reduce(\n [1..10],\n initial = startOfDecagonSketch,\n f = fn(i, partialDecagon) {\n // Draw one edge of the decagon.\n x = math::cos(stepAngle * i) * radius\n y = math::sin(stepAngle * i) * radius\n return line(partialDecagon, end = [x, y])\n },\n )\n\n return fullDecagon\n}\n\n/* The `decagon` above is basically like this pseudo-code:\nfn decagon(radius):\n stepAngle = ((1/10) * TAU): number(rad)\n plane = startSketchOn(XY)\n startOfDecagonSketch = startProfile(plane, at = [(math::cos(0)*radius), (math::sin(0) * radius)])\n\n // Here's the reduce part.\n partialDecagon = startOfDecagonSketch\n for i in [1..10]:\n x = math::cos(stepAngle * i) * radius\n y = math::sin(stepAngle * i) * radius\n partialDecagon = line(partialDecagon, end = [x, y])\n fullDecagon = partialDecagon // it's now full\n return fullDecagon */\n\n// Use the `decagon` function declared above, to sketch a decagon with radius 5.\ndecagon(5.0)\n |> close()"
]
},
{
"name": "rem",
"summary": "Compute the remainder after dividing `num` by `div`. If `num` is negative, the result will be too.",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "num",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number which will be divided by `divisor`.",
"labelRequired": false
},
{
"name": "divisor",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number which will divide `num`.",
"labelRequired": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"assert(rem(7, divisor = 4), isEqualTo = 3, error = \"remainder is 3\")\nassert(rem(-7, divisor = 4), isEqualTo = -3, error = \"remainder is -3\")\nassert(rem(7, divisor = -4), isEqualTo = 3, error = \"remainder is 3\")\nassert(rem(6, divisor = 2.5), isEqualTo = 1, error = \"remainder is 1\")\nassert(rem(6.5, divisor = 2.5), isEqualTo = 1.5, error = \"remainder is 1.5\")\nassert(rem(6.5, divisor = 2), isEqualTo = 0.5, error = \"remainder is 0.5\")"
]
},
{
"name": "rotate",
"summary": "Rotate a solid or a sketch.",
@ -245921,49 +245215,6 @@
"// Translate and rotate a sketch to create a loft.\nsketch001 = startSketchOn(XY)\n\nfn square() {\n return startProfile(sketch001, at = [-10, 10])\n |> xLine(length = 20)\n |> yLine(length = -20)\n |> xLine(length = -20)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n}\n\nprofile001 = square()\n\nprofile002 = square()\n |> translate(x = 0, y = 0, z = 20)\n |> rotate(axis = [0, 0, 1.0], angle = 45)\n\nloft([profile001, profile002])"
]
},
{
"name": "round",
"summary": "Round a number to the nearest integer.",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to round.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"sketch001 = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(endAbsolute = [12, 10])\n |> line(end = [round(7.02986), 0])\n |> yLine(endAbsolute = 0)\n |> close()\n\nextrude001 = extrude(sketch001, length = 5)"
]
},
{
"name": "scale",
"summary": "Scale a solid or a sketch.",
@ -256155,49 +255406,6 @@
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(end = [20, 0])\n |> line(end = [0, 3], tag = $thing)\n |> line(end = [-10, 0])\n |> line(end = [0, 20 - segStartY(thing)])\n |> line(end = [-10, 0])\n |> close()\n\nexample = extrude(exampleSketch, length = 5)"
]
},
{
"name": "sqrt",
"summary": "Compute the square root of a number.",
"description": "",
"tags": [
"math"
],
"keywordArguments": true,
"args": [
{
"name": "input",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"description": "The number to compute the square root of.",
"labelRequired": false
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double",
"type": "number",
"format": "double"
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"exampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> angledLine(angle = 50, length = sqrt(2500))\n |> yLine(endAbsolute = 0)\n |> close()\n\nexample = extrude(exampleSketch, length = 5)"
]
},
{
"name": "startProfile",
"summary": "Start a new profile at a given point.",

View File

@ -139,7 +139,7 @@ startSketchOn(motorHousing, face = END)
|> extrude(length = -16)
|> appearance(color = "#a55e2c")
|> fillet(
radius = abs(fanSize - mountingHoleSpacing) / 2,
radius = math::abs(fanSize - mountingHoleSpacing) / 2,
tags = [
getNextAdjacentEdge(rectangleSegmentA001),
getNextAdjacentEdge(rectangleSegmentB001),

View File

@ -26,9 +26,9 @@ fn slot(sketch1, start, end, width) {
}
} else {
if end[0] < start[0] {
units::toDegrees(atan((end[1] - start[1]) / (end[0] - start[0]))) + 180
units::toDegrees(math::atan((end[1] - start[1]) / (end[0] - start[0]))) + 180
} else {
units::toDegrees( atan((end[1] - start[1]) / (end[0] - start[0])))
units::toDegrees( math::atan((end[1] - start[1]) / (end[0] - start[0])))
}
}
dist = sqrt(pow(end[1] - start[1], exp = 2) + pow(end[0] - start[0], exp = 2))

View File

@ -28,7 +28,7 @@ rs = map(
angles = map(
rs,
f = fn(r) {
return units::toDegrees( acos(baseDiameter / 2 / r))
return units::toDegrees( math::acos(baseDiameter / 2 / r))
},
)
@ -69,8 +69,8 @@ fn leftInvolute(i, sg) {
}
fn rightInvolute(i, sg) {
x = rs[i] * math::cos(-toothAngle + units::toDegrees(atan(ys[i] / xs[i])))
y = -rs[i] * math::sin(-toothAngle + units::toDegrees(atan(ys[i] / xs[i])))
x = rs[i] * math::cos(-toothAngle + units::toDegrees(math::atan(ys[i] / xs[i])))
y = -rs[i] * math::sin(-toothAngle + units::toDegrees(math::atan(ys[i] / xs[i])))
return line(sg, endAbsolute = [x, y])
}
@ -95,7 +95,7 @@ keywayWidth = 0.250
keywayDepth = keywayWidth / 2
holeDiam = 2
holeRadius = 1
startAngle = asin(keywayWidth / 2 / holeRadius)
startAngle = math::asin(keywayWidth / 2 / holeRadius)
// Sketch the keyway and center hole and extrude
keyWay = startSketchOn(body, face = END)

View File

@ -25,7 +25,7 @@ extrude006 = extrude(sketch006, length = 1)
sketch007 = startSketchOn(extrude006, face = END)
|> circle(
center = [
1.75 * math::cos(axisJ1) / abs(math::cos(axisJ1)),
1.75 * math::cos(axisJ1) / math::abs(math::cos(axisJ1)),
8
],
radius = 2.75,
@ -38,14 +38,14 @@ extrude007 = extrude(sketch007, length = 1.5)
sketch008 = startSketchOn(extrude007, face = END)
|> circle(
center = [
1.75 * math::cos(axisJ1) / abs(math::cos(axisJ1)),
1.75 * math::cos(axisJ1) / math::abs(math::cos(axisJ1)),
6.75
],
radius = 0.2,
)
|> patternCircular2d(
center = [
1.75 * math::cos(axisJ1) / abs(math::cos(axisJ1)),
1.75 * math::cos(axisJ1) / math::abs(math::cos(axisJ1)),
8
],
instances = 4,
@ -57,7 +57,7 @@ extrude008 = extrude(sketch008, length = 0.2)
sketch009 = startSketchOn(extrude007, face = END)
|> circle(
center = [
1.75 * math::cos(axisJ1) / abs(math::cos(axisJ1)),
1.75 * math::cos(axisJ1) / math::abs(math::cos(axisJ1)),
8
],
radius = 0.5,

View File

@ -5,7 +5,7 @@
fn cond(bools) {
return fn(a, b) {
x = min([max([-1, a-b]), 1]) + 1
x = math::min([math::max([-1, a-b]), 1]) + 1
return bools[x]
}
}
@ -75,8 +75,8 @@ fn setLength(state, q) {
fn Gt2(state) { return setLength(state, state.currentLength * state.factor) }
fn Lt2(state) { return setLength(state, state.currentLength / state.factor) }
fn Add(state) { return setAngle(state, rem(state.currentAngle - state.angle, divisor = 360)) }
fn Sub(state) { return setAngle(state, rem(state.currentAngle + state.angle, divisor = 360)) }
fn Add(state) { return setAngle(state, math::rem(state.currentAngle - state.angle, divisor = 360)) }
fn Sub(state) { return setAngle(state, math::rem(state.currentAngle + state.angle, divisor = 360)) }
// Only necessary to get around recursion limitations...
fn F(state, F) {

View File

@ -5,7 +5,7 @@ t = 0.005 // taper factor [0-1)
// Defines how to modify each layer of the vase.
// Each replica is shifted up the Z axis, and has a smoothly-varying radius
fn transform(replicaId) {
scale = r * abs(1 - (t * replicaId)) * (5 + math::cos((replicaId / 8): number(rad)))
scale = r * math::abs(1 - (t * replicaId)) * (5 + math::cos((replicaId / 8): number(rad)))
return {
translate = [0, 0, replicaId * 10],
scale = [scale, scale, 0],

View File

@ -1307,7 +1307,7 @@ part001 = startSketchOn(XY)
|> startProfile(at = [0, 0])
|> line(end = [3, 4], tag = $seg01)
|> line(end = [
min([segLen(seg01), myVar]),
math::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 = [
min([segLen(seg01), myVar]),
math::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 + min([100, -1 + legLen(hypotenuse = 5, leg = 3)])"#;
let ast = r#"myVar = 2 + math::min([100, -1 + legLen(hypotenuse = 5, leg = 3)])"#;
let result = parse_execute(ast).await.unwrap();
assert_eq!(
5.0,

View File

@ -669,8 +669,9 @@ impl NumericType {
meta: meta.clone(),
}),
// We don't actually need to coerce, since we just keep the partially-known type with the value.
(Default { .. }, Default { .. }) => Ok(KclValue::Number {
// If we're coercing to a default, we treat this as coercing to Any since leaving the numeric type unspecified in a coercion situation
// means accept any number rather than force the current default.
(_, Default { .. }) => Ok(KclValue::Number {
value: *value,
ty: ty.clone(),
meta: meta.clone(),
@ -698,16 +699,13 @@ impl NumericType {
(Known(_), Known(_)) => Err(val.into()),
// Known and unknown => we assume the rhs, possibly with adjustment
(Known(UnitType::Count), Default { .. }) | (Default { .. }, Known(UnitType::Count)) => {
Ok(KclValue::Number {
value: *value,
ty: Known(UnitType::Count),
meta: meta.clone(),
})
}
(Default { .. }, Known(UnitType::Count)) => Ok(KclValue::Number {
value: *value,
ty: Known(UnitType::Count),
meta: meta.clone(),
}),
(Known(UnitType::Length(l1)), Default { len: l2, .. })
| (Default { len: l1, .. }, Known(UnitType::Length(l2))) => {
(Default { len: l1, .. }, Known(UnitType::Length(l2))) => {
let (value, ty) = l1.adjust_to(*value, *l2);
Ok(KclValue::Number {
value,
@ -716,8 +714,7 @@ impl NumericType {
})
}
(Known(UnitType::Angle(a1)), Default { angle: a2, .. })
| (Default { angle: a1, .. }, Known(UnitType::Angle(a2))) => {
(Default { angle: a1, .. }, Known(UnitType::Angle(a2))) => {
let (value, ty) = a1.adjust_to(*value, *a2);
Ok(KclValue::Number {
value,
@ -775,7 +772,7 @@ pub enum UnitType {
impl std::fmt::Display for UnitType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
UnitType::Count => write!(f, "_"),
UnitType::Count => write!(f, "Count"),
UnitType::Length(l) => l.fmt(f),
UnitType::Angle(a) => a.fmt(f),
}
@ -2034,7 +2031,7 @@ mod test {
.as_f64()
.unwrap()
.round(),
25.0
1.0
);
assert_eq!(
rads.coerce(&NumericType::default().into(), &mut exec_state)
@ -2042,7 +2039,7 @@ mod test {
.as_f64()
.unwrap()
.round(),
57.0
1.0
);
}
@ -2084,14 +2081,19 @@ o = 3mm / 3
p = 3_ / 4
q = 4inch / 2_
r = min([0, 3, 42])
s = min([0, 3mm, -42])
t = min([100, 3in, 142mm])
u = min([3rad, 4in])
r = math::min([0, 3, 42])
s = math::min([0, 3mm, -42])
t = math::min([100, 3in, 142mm])
u = math::min([3rad, 4in])
"#;
let result = parse_execute(program).await.unwrap();
assert_eq!(result.exec_state.errors().len(), 5);
assert_eq!(
result.exec_state.errors().len(),
5,
"errors: {:?}",
result.exec_state.errors()
);
assert_value_and_type("a", &result, 9.0, NumericType::default());
assert_value_and_type("b", &result, 3.0, NumericType::default());

View File

@ -1,7 +1,6 @@
//! Functions related to mathematics.
use anyhow::Result;
use kcl_derive_docs::stdlib;
use crate::{
errors::KclError,
@ -26,36 +25,11 @@ pub async fn rem(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
"Calling `rem` on numbers which have unknown or incompatible units.\n\nYou may need to add information about the type of the argument, for example:\n using a numeric suffix: `42{ty}`\n or using type ascription: `foo(): number({ty})`"
));
}
let remainder = inner_rem(n, d);
let remainder = n % d;
Ok(args.make_user_val_from_f64_with_type(TyF64::new(remainder, ty)))
}
/// Compute the remainder after dividing `num` by `div`.
/// If `num` is negative, the result will be too.
///
/// ```no_run
/// assert(rem( 7, divisor = 4), isEqualTo = 3, error = "remainder is 3")
/// assert(rem(-7, divisor = 4), isEqualTo = -3, error = "remainder is -3")
/// assert(rem( 7, divisor = -4), isEqualTo = 3, error = "remainder is 3")
/// assert(rem( 6, divisor = 2.5), isEqualTo = 1, error = "remainder is 1")
/// assert(rem( 6.5, divisor = 2.5), isEqualTo = 1.5, error = "remainder is 1.5")
/// assert(rem( 6.5, divisor = 2), isEqualTo = 0.5, error = "remainder is 0.5")
/// ```
#[stdlib {
name = "rem",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
num = {docs = "The number which will be divided by `divisor`."},
divisor = {docs = "The number which will divide `num`."},
}
}]
fn inner_rem(num: f64, divisor: f64) -> f64 {
num % divisor
}
/// Compute the cosine of a number (in radians).
pub async fn cos(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let num: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::angle(), exec_state)?;
@ -80,184 +54,48 @@ pub async fn tan(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
/// Compute the square root of a number.
pub async fn sqrt(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::num_any(), exec_state)?;
let result = inner_sqrt(input.n);
let result = input.n.sqrt();
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, exec_state.current_default_units())))
}
/// Compute the square root of a number.
///
/// ```no_run
/// exampleSketch = startSketchOn("XZ")
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 50,
/// length = sqrt(2500),
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
#[stdlib {
name = "sqrt",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to compute the square root of."},
}
}]
fn inner_sqrt(input: f64) -> f64 {
input.sqrt()
}
/// Compute the absolute value of a number.
pub async fn abs(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::num_any(), exec_state)?;
let result = inner_abs(input.n);
let result = input.n.abs();
Ok(args.make_user_val_from_f64_with_type(input.map_value(result)))
}
/// Compute the absolute value of a number.
///
/// ```no_run
/// myAngle = -120
///
/// sketch001 = startSketchOn('XZ')
/// |> startProfile(at = [0, 0])
/// |> line(end = [8, 0])
/// |> angledLine(
/// angle = abs(myAngle),
/// length = 5,
/// )
/// |> line(end = [-5, 0])
/// |> angledLine(
/// angle = myAngle,
/// length = 5,
/// )
/// |> close()
///
/// baseExtrusion = extrude(sketch001, length = 5)
/// ```
#[stdlib {
name = "abs",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to compute the absolute value of."},
}
}]
fn inner_abs(input: f64) -> f64 {
input.abs()
}
/// Round a number to the nearest integer.
pub async fn round(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::num_any(), exec_state)?;
let result = inner_round(input.n);
let result = input.n.round();
Ok(args.make_user_val_from_f64_with_type(input.map_value(result)))
}
/// Round a number to the nearest integer.
///
/// ```no_run
/// sketch001 = startSketchOn('XZ')
/// |> startProfile(at = [0, 0])
/// |> line(endAbsolute = [12, 10])
/// |> line(end = [round(7.02986), 0])
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
#[stdlib {
name = "round",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to round."},
}
}]
fn inner_round(input: f64) -> f64 {
input.round()
}
/// Compute the largest integer less than or equal to a number.
pub async fn floor(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::num_any(), exec_state)?;
let result = inner_floor(input.n);
let result = input.n.floor();
Ok(args.make_user_val_from_f64_with_type(input.map_value(result)))
}
/// Compute the largest integer less than or equal to a number.
///
/// ```no_run
/// sketch001 = startSketchOn('XZ')
/// |> startProfile(at = [0, 0])
/// |> line(endAbsolute = [12, 10])
/// |> line(end = [floor(7.02986), 0])
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
#[stdlib {
name = "floor",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to round."},
}
}]
fn inner_floor(input: f64) -> f64 {
input.floor()
}
/// Compute the smallest integer greater than or equal to a number.
pub async fn ceil(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::num_any(), exec_state)?;
let result = inner_ceil(input.n);
let result = input.n.ceil();
Ok(args.make_user_val_from_f64_with_type(input.map_value(result)))
}
/// Compute the smallest integer greater than or equal to a number.
///
/// ```no_run
/// sketch001 = startSketchOn('XZ')
/// |> startProfile(at = [0, 0])
/// |> line(endAbsolute = [12, 10])
/// |> line(end = [ceil(7.02986), 0])
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
#[stdlib {
name = "ceil",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to round."},
}
}]
fn inner_ceil(input: f64) -> f64 {
input.ceil()
}
/// Compute the minimum of the given arguments.
pub async fn min(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let nums: Vec<TyF64> = args.get_unlabeled_kw_arg_typed(
"input",
&RuntimeType::Array(Box::new(RuntimeType::num_any()), ArrayLen::None),
&RuntimeType::Array(Box::new(RuntimeType::num_any()), ArrayLen::NonEmpty),
exec_state,
)?;
let (nums, ty) = NumericType::combine_eq_array(&nums);
@ -267,50 +105,22 @@ pub async fn min(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
"Calling `min` on numbers which have unknown or incompatible units.\n\nYou may need to add information about the type of the argument, for example:\n using a numeric suffix: `42{ty}`\n or using type ascription: `foo(): number({ty})`",
));
}
let result = inner_min(nums);
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, ty)))
}
/// Compute the minimum of the given arguments.
///
/// ```no_run
/// exampleSketch = startSketchOn("XZ")
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 70,
/// length = min([15, 31, 4, 13, 22])
/// )
/// |> line(end = [20, 0])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
#[stdlib {
name = "min",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "An array of numbers to compute the minimum of."},
}
}]
fn inner_min(input: Vec<f64>) -> f64 {
let mut min = f64::MAX;
for num in input.iter() {
if *num < min {
min = *num;
let mut result = f64::MAX;
for num in nums {
if num < result {
result = num;
}
}
min
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, ty)))
}
/// Compute the maximum of the given arguments.
pub async fn max(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let nums: Vec<TyF64> = args.get_unlabeled_kw_arg_typed(
"input",
&RuntimeType::Array(Box::new(RuntimeType::num_any()), ArrayLen::None),
&RuntimeType::Array(Box::new(RuntimeType::num_any()), ArrayLen::NonEmpty),
exec_state,
)?;
let (nums, ty) = NumericType::combine_eq_array(&nums);
@ -320,228 +130,60 @@ pub async fn max(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
"Calling `max` on numbers which have unknown or incompatible units.\n\nYou may need to add information about the type of the argument, for example:\n using a numeric suffix: `42{ty}`\n or using type ascription: `foo(): number({ty})`",
));
}
let result = inner_max(nums);
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, ty)))
}
/// Compute the maximum of the given arguments.
///
/// ```no_run
/// exampleSketch = startSketchOn("XZ")
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 70,
/// length = max([15, 31, 4, 13, 22])
/// )
/// |> line(end = [20, 0])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
#[stdlib {
name = "max",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "An array of numbers to compute the maximum of."},
}
}]
fn inner_max(input: Vec<f64>) -> f64 {
let mut max = f64::MIN;
for num in input.iter() {
if *num > max {
max = *num;
let mut result = f64::MIN;
for num in nums {
if num > result {
result = num;
}
}
max
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, ty)))
}
/// Compute the number to a power.
pub async fn pow(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::num_any(), exec_state)?;
let exp: TyF64 = args.get_kw_arg_typed("exp", &RuntimeType::count(), exec_state)?;
let result = inner_pow(input.n, exp.n);
let result = input.n.powf(exp.n);
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, exec_state.current_default_units())))
}
/// Compute the number to a power.
///
/// ```no_run
/// exampleSketch = startSketchOn("XZ")
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 50,
/// length = pow(5, exp = 2),
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
#[stdlib {
name = "pow",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to raise."},
exp = {docs = "The power to raise to."},
}
}]
fn inner_pow(input: f64, exp: f64) -> f64 {
input.powf(exp)
}
/// Compute the arccosine of a number (in radians).
pub async fn acos(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::count(), exec_state)?;
let result = inner_acos(input.n);
let result = input.n.acos();
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, NumericType::radians())))
}
/// Compute the arccosine of a number (in radians).
///
/// ```no_run
/// sketch001 = startSketchOn('XZ')
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = units::toDegrees(acos(0.5)),
/// length = 10,
/// )
/// |> line(end = [5, 0])
/// |> line(endAbsolute = [12, 0])
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
#[stdlib {
name = "acos",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to compute arccosine of."},
}
}]
fn inner_acos(input: f64) -> f64 {
input.acos()
}
/// Compute the arcsine of a number (in radians).
pub async fn asin(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::count(), exec_state)?;
let result = inner_asin(input.n);
let result = input.n.asin();
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, NumericType::radians())))
}
/// Compute the arcsine of a number (in radians).
///
/// ```no_run
/// sketch001 = startSketchOn('XZ')
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = units::toDegrees(asin(0.5)),
/// length = 20,
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
#[stdlib {
name = "asin",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to compute arcsine of."},
}
}]
fn inner_asin(input: f64) -> f64 {
input.asin()
}
/// Compute the arctangent of a number (in radians).
pub async fn atan(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::count(), exec_state)?;
let result = inner_atan(input.n);
let result = input.n.atan();
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, NumericType::radians())))
}
/// Compute the arctangent of a number (in radians).
///
/// Consider using `atan2()` instead for the true inverse of tangent.
///
/// ```no_run
/// sketch001 = startSketchOn('XZ')
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = units::toDegrees(atan(1.25)),
/// length = 20,
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
#[stdlib {
name = "atan",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to compute arctangent of."},
}
}]
fn inner_atan(input: f64) -> f64 {
input.atan()
}
/// Compute the four quadrant arctangent of Y and X (in radians).
pub async fn atan2(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let y = args.get_kw_arg_typed("y", &RuntimeType::length(), exec_state)?;
let x = args.get_kw_arg_typed("x", &RuntimeType::length(), exec_state)?;
let (y, x, _) = NumericType::combine_eq_coerce(y, x);
let result = inner_atan2(y, x);
let result = y.atan2(x);
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, NumericType::radians())))
}
/// Compute the four quadrant arctangent of Y and X (in radians).
///
/// ```no_run
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = units::toDegrees(atan2(y = 1.25, x = 2)),
/// length = 20,
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
#[stdlib {
name = "atan2",
tags = ["math"],
keywords = true,
unlabeled_first = false,
args = {
y = { docs = "Y"},
x = { docs = "X"},
}
}]
fn inner_atan2(y: f64, x: f64) -> f64 {
y.atan2(x)
}
/// Compute the logarithm of the number with respect to an arbitrary base.
///
/// The result might not be correctly rounded owing to implementation
@ -550,166 +192,31 @@ fn inner_atan2(y: f64, x: f64) -> f64 {
pub async fn log(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::num_any(), exec_state)?;
let base: TyF64 = args.get_kw_arg_typed("base", &RuntimeType::count(), exec_state)?;
let result = inner_log(input.n, base.n);
let result = input.n.log(base.n);
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, exec_state.current_default_units())))
}
/// Compute the logarithm of the number with respect to an arbitrary base.
///
/// The result might not be correctly rounded owing to implementation
/// details; `log2()` can produce more accurate results for base 2,
/// and `log10()` can produce more accurate results for base 10.
///
/// ```no_run
/// exampleSketch = startSketchOn("XZ")
/// |> startProfile(at = [0, 0])
/// |> line(end = [log(100, base = 5), 0])
/// |> line(end = [5, 8])
/// |> line(end = [-10, 0])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
#[stdlib {
name = "log",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to compute the logarithm of."},
base = {docs = "The base of the logarithm."},
}
}]
fn inner_log(input: f64, base: f64) -> f64 {
input.log(base)
}
/// Compute the base 2 logarithm of the number.
pub async fn log2(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::num_any(), exec_state)?;
let result = inner_log2(input.n);
let result = input.n.log2();
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, exec_state.current_default_units())))
}
/// Compute the base 2 logarithm of the number.
///
/// ```no_run
/// exampleSketch = startSketchOn("XZ")
/// |> startProfile(at = [0, 0])
/// |> line(end = [log2(100), 0])
/// |> line(end = [5, 8])
/// |> line(end = [-10, 0])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
#[stdlib {
name = "log2",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to compute the logarithm of."},
}
}]
fn inner_log2(input: f64) -> f64 {
input.log2()
}
/// Compute the base 10 logarithm of the number.
pub async fn log10(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::num_any(), exec_state)?;
let result = inner_log10(input.n);
let result = input.n.log10();
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, exec_state.current_default_units())))
}
/// Compute the base 10 logarithm of the number.
///
/// ```no_run
/// exampleSketch = startSketchOn("XZ")
/// |> startProfile(at = [0, 0])
/// |> line(end = [log10(100), 0])
/// |> line(end = [5, 8])
/// |> line(end = [-10, 0])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
#[stdlib {
name = "log10",
tags = ["math"],
}]
fn inner_log10(num: f64) -> f64 {
num.log10()
}
/// Compute the natural logarithm of the number.
pub async fn ln(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input: TyF64 = args.get_unlabeled_kw_arg_typed("input", &RuntimeType::num_any(), exec_state)?;
let result = inner_ln(input.n);
let result = input.n.ln();
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, exec_state.current_default_units())))
}
/// Compute the natural logarithm of the number.
///
/// ```no_run
/// exampleSketch = startSketchOn("XZ")
/// |> startProfile(at = [0, 0])
/// |> line(end = [ln(100), 15])
/// |> line(end = [5, -6])
/// |> line(end = [-10, -10])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
#[stdlib {
name = "ln",
tags = ["math"],
keywords = true,
unlabeled_first = true,
args = {
input = {docs = "The number to compute the logarithm of."},
}
}]
fn inner_ln(input: f64) -> f64 {
input.ln()
}
#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;
use super::*;
#[test]
fn test_inner_max() {
let nums = vec![4.0, 5.0, 6.0];
let result = inner_max(nums);
assert_eq!(result, 6.0);
}
#[test]
fn test_inner_max_with_neg() {
let nums = vec![4.0, -5.0];
let result = inner_max(nums);
assert_eq!(result, 4.0);
}
#[test]
fn test_inner_min() {
let nums = vec![4.0, 5.0, 6.0];
let result = inner_min(nums);
assert_eq!(result, 4.0);
}
#[test]
fn test_inner_min_with_neg() {
let nums = vec![4.0, -5.0];
let result = inner_min(nums);
assert_eq!(result, -5.0);
}
}

View File

@ -104,23 +104,6 @@ lazy_static! {
Box::new(crate::std::edge::GetCommonEdge),
Box::new(crate::std::sweep::Sweep),
Box::new(crate::std::loft::Loft),
Box::new(crate::std::math::Acos),
Box::new(crate::std::math::Asin),
Box::new(crate::std::math::Atan),
Box::new(crate::std::math::Atan2),
Box::new(crate::std::math::Sqrt),
Box::new(crate::std::math::Abs),
Box::new(crate::std::math::Rem),
Box::new(crate::std::math::Round),
Box::new(crate::std::math::Floor),
Box::new(crate::std::math::Ceil),
Box::new(crate::std::math::Min),
Box::new(crate::std::math::Max),
Box::new(crate::std::math::Pow),
Box::new(crate::std::math::Log),
Box::new(crate::std::math::Log2),
Box::new(crate::std::math::Log10),
Box::new(crate::std::math::Ln),
Box::new(crate::std::assert::Assert),
Box::new(crate::std::assert::AssertIs),
Box::new(crate::std::transform::Scale),
@ -176,6 +159,75 @@ pub(crate) fn std_fn(path: &str, fn_name: &str) -> (crate::std::StdFn, StdFnProp
|e, a| Box::pin(crate::std::math::tan(e, a)),
StdFnProps::default("std::math::tan"),
),
("math", "acos") => (
|e, a| Box::pin(crate::std::math::acos(e, a)),
StdFnProps::default("std::math::acos"),
),
("math", "asin") => (
|e, a| Box::pin(crate::std::math::asin(e, a)),
StdFnProps::default("std::math::asin"),
),
("math", "atan") => (
|e, a| Box::pin(crate::std::math::atan(e, a)),
StdFnProps::default("std::math::atan"),
),
("math", "atan2") => (
|e, a| Box::pin(crate::std::math::atan2(e, a)),
StdFnProps::default("std::math::atan2"),
),
("math", "sqrt") => (
|e, a| Box::pin(crate::std::math::sqrt(e, a)),
StdFnProps::default("std::math::sqrt"),
),
("math", "abs") => (
|e, a| Box::pin(crate::std::math::abs(e, a)),
StdFnProps::default("std::math::abs"),
),
("math", "rem") => (
|e, a| Box::pin(crate::std::math::rem(e, a)),
StdFnProps::default("std::math::rem"),
),
("math", "round") => (
|e, a| Box::pin(crate::std::math::round(e, a)),
StdFnProps::default("std::math::round"),
),
("math", "floor") => (
|e, a| Box::pin(crate::std::math::floor(e, a)),
StdFnProps::default("std::math::floor"),
),
("math", "ceil") => (
|e, a| Box::pin(crate::std::math::ceil(e, a)),
StdFnProps::default("std::math::ceil"),
),
("math", "min") => (
|e, a| Box::pin(crate::std::math::min(e, a)),
StdFnProps::default("std::math::min"),
),
("math", "max") => (
|e, a| Box::pin(crate::std::math::max(e, a)),
StdFnProps::default("std::math::max"),
),
("math", "pow") => (
|e, a| Box::pin(crate::std::math::pow(e, a)),
StdFnProps::default("std::math::pow"),
),
("math", "log") => (
|e, a| Box::pin(crate::std::math::log(e, a)),
StdFnProps::default("std::math::log"),
),
("math", "log2") => (
|e, a| Box::pin(crate::std::math::log2(e, a)),
StdFnProps::default("std::math::log2"),
),
("math", "log10") => (
|e, a| Box::pin(crate::std::math::log10(e, a)),
StdFnProps::default("std::math::log10"),
),
("math", "ln") => (
|e, a| Box::pin(crate::std::math::ln(e, a)),
StdFnProps::default("std::math::ln"),
),
("sketch", "circle") => (
|e, a| Box::pin(crate::std::shapes::circle(e, a)),
StdFnProps::default("std::sketch::circle"),

View File

@ -202,7 +202,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// // Defines how to modify each layer of the vase.
/// // Each replica is shifted up the Z axis, and has a smoothly-varying radius
/// fn transform(replicaId) {
/// scale = r * abs(1 - (t * replicaId)) * (5 + math::cos((replicaId / 8): number(rad)))
/// scale = r * math::abs(1 - (t * replicaId)) * (5 + math::cos((replicaId / 8): number(rad)))
/// return {
/// translate = [0, 0, replicaId * 10],
/// scale = [scale, scale, 0],

View File

@ -62,7 +62,7 @@ export TAU = 6.28318530717958647692528676655900577_
/// example = extrude(exampleSketch, length = 5)
/// ```
@(impl = std_rust)
export fn cos(@num: number(Angle)): number(_) {}
export fn cos(@num: number(Angle)): number(Count) {}
/// Compute the sine of a number.
///
@ -79,7 +79,7 @@ export fn cos(@num: number(Angle)): number(_) {}
/// example = extrude(exampleSketch, length = 5)
/// ```
@(impl = std_rust)
export fn sin(@num: number(Angle)): number(_) {}
export fn sin(@num: number(Angle)): number(Count) {}
/// Compute the tangent of a number.
///
@ -96,7 +96,78 @@ export fn sin(@num: number(Angle)): number(_) {}
/// example = extrude(exampleSketch, length = 5)
/// ```
@(impl = std_rust)
export fn tan(@num: number(Angle)): number(_) {}
export fn tan(@num: number(Angle)): number(Count) {}
/// Compute the arccosine of a number.
///
/// ```
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = math::acos(0.5),
/// length = 10,
/// )
/// |> line(end = [5, 0])
/// |> line(endAbsolute = [12, 0])
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
@(impl = std_rust)
export fn acos(@num: number(Count)): number(rad) {}
/// Compute the arcsine of a number.
///
/// ```
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = math::asin(0.5),
/// length = 20,
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
@(impl = std_rust)
export fn asin(@num: number(Count)): number(rad) {}
/// Compute the arctangent of a number.
///
/// Consider using `atan2()` instead for the true inverse of tangent.
///
/// ```no_run
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = math::atan(1.25),
/// length = 20,
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
@(impl = std_rust)
export fn atan(@num: number(Count)): number(rad) {}
/// Compute the four quadrant arctangent of Y and X.
///
/// ```
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = math::atan2(y = 1.25, x = 2),
/// length = 20,
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
@(impl = std_rust)
export fn atan2(y: number(Length), x: number(Length)): number(rad) {}
/// Convert polar/sphere (azimuth, elevation, distance) coordinates to
/// cartesian (x/y/z grid) coordinates.
@ -117,3 +188,241 @@ export fn polar(angle: number(rad), length: number(Length)): Point2d {
y = length * sin(angle)
return [x, y]
}
/// Compute the remainder after dividing `num` by `div`.
/// If `num` is negative, the result will be too.
///
/// ```
/// import rem from "std::math"
///
/// assert(rem( 7, divisor = 4), isEqualTo = 3, error = "remainder is 3")
/// assert(rem(-7, divisor = 4), isEqualTo = -3, error = "remainder is -3")
/// assert(rem( 7, divisor = -4), isEqualTo = 3, error = "remainder is 3")
/// assert(rem( 6, divisor = 2.5), isEqualTo = 1, error = "remainder is 1")
/// assert(rem( 6.5, divisor = 2.5), isEqualTo = 1.5, error = "remainder is 1.5")
/// assert(rem( 6.5, divisor = 2), isEqualTo = 0.5, error = "remainder is 0.5")
/// ```
@(impl = std_rust)
export fn rem(
/// The number which will be divided by `divisor`.
@num: number,
/// The number which will divide `num`.
divisor: number,
): number {}
/// Compute the square root of a number.
///
/// ```
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 50,
/// length = sqrt(2500),
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
@(impl = std_rust)
export fn sqrt(@input: number): number {}
/// Compute the absolute value of a number.
///
/// ```
/// myAngle = -120
///
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(end = [8, 0])
/// |> angledLine(
/// angle = math::abs(myAngle),
/// length = 5,
/// )
/// |> line(end = [-5, 0])
/// |> angledLine(
/// angle = myAngle,
/// length = 5,
/// )
/// |> close()
///
/// baseExtrusion = extrude(sketch001, length = 5)
/// ```
@(impl = std_rust)
export fn abs(@input: number): number {}
/// Round a number to the nearest integer.
///
/// ```
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(endAbsolute = [12, 10])
/// |> line(end = [math::round(7.02986), 0])
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
@(impl = std_rust)
export fn round(@input: number): number {}
/// Compute the largest integer less than or equal to a number.
///
/// ```
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(endAbsolute = [12, 10])
/// |> line(end = [math::floor(7.02986), 0])
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
@(impl = std_rust)
export fn floor(@input: number): number {}
/// Compute the smallest integer greater than or equal to a number.
///
/// ```
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(endAbsolute = [12, 10])
/// |> line(end = [math::ceil(7.02986), 0])
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// extrude001 = extrude(sketch001, length = 5)
/// ```
@(impl = std_rust)
export fn ceil(@input: number): number {}
/// Compute the minimum of the given arguments.
///
/// ```
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 70,
/// length = math::min([15, 31, 4, 13, 22])
/// )
/// |> line(end = [20, 0])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
@(impl = std_rust)
export fn min(
/// An array of numbers to compute the minimum of.
@input: [number; 1+],
): number {}
/// Compute the maximum of the given arguments.
///
/// ```
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 70,
/// length = math::max([15, 31, 4, 13, 22])
/// )
/// |> line(end = [20, 0])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
@(impl = std_rust)
export fn max(
/// An array of numbers to compute the maximum of.
@input: [number; 1+],
): number {}
/// Compute the number to a power.
///
/// ```
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 50,
/// length = math::pow(5, exp = 2),
/// )
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
@(impl = std_rust)
export fn pow(
/// The number to raise.
@input: number,
/// The power to raise to.
exp: number(Count),
): number {}
/// Compute the logarithm of the number with respect to an arbitrary base.
///
/// The result might not be correctly rounded owing to implementation
/// details; `math::log2` can produce more accurate results for base 2,
/// and `math::log10` can produce more accurate results for base 10.
///
/// ```
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(end = [math::log(100, base = 5), 0])
/// |> line(end = [5, 8])
/// |> line(end = [-10, 0])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
@(impl = std_rust)
export fn log(
/// The number to compute the logarithm of.
@input: number,
/// The base of the logarithm.
base: number(Count),
): number {}
/// Compute the base 2 logarithm of the number.
///
/// ```
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(end = [math::log2(100), 0])
/// |> line(end = [5, 8])
/// |> line(end = [-10, 0])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
@(impl = std_rust)
export fn log2(@input: number): number {}
/// Compute the base 10 logarithm of the number.
///
/// ```
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(end = [math::log10(100), 0])
/// |> line(end = [5, 8])
/// |> line(end = [-10, 0])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
@(impl = std_rust)
export fn log10(@input: number): number {}
/// Compute the natural logarithm of the number.
///
/// ```
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(end = [math::ln(100), 15])
/// |> line(end = [5, -6])
/// |> line(end = [-10, -10])
/// |> close()
///
/// example = extrude(exampleSketch, length = 5)
/// ```
@(impl = std_rust)
export fn ln(@input: number): number {}

View File

@ -5,7 +5,7 @@
export import * from "std::types"
export import "std::units"
export import PI, E, TAU from "std::math"
export import PI, E, TAU, pow, sqrt from "std::math"
export import "std::math"
export import * from "std::sketch"
export import * from "std::solid"

View File

@ -1,235 +1,235 @@
```mermaid
flowchart LR
subgraph path5 [Path]
5["Path<br>[1115, 1165, 0]"]
8["Segment<br>[1115, 1165, 0]"]
5["Path<br>[1121, 1171, 0]"]
8["Segment<br>[1121, 1171, 0]"]
220[Solid2d]
end
subgraph path6 [Path]
6["Path<br>[1646, 1683, 0]"]
9["Segment<br>[1330, 1368, 0]"]
10["Segment<br>[1330, 1368, 0]"]
11["Segment<br>[1330, 1368, 0]"]
12["Segment<br>[1330, 1368, 0]"]
13["Segment<br>[1330, 1368, 0]"]
14["Segment<br>[1330, 1368, 0]"]
15["Segment<br>[1330, 1368, 0]"]
16["Segment<br>[1330, 1368, 0]"]
17["Segment<br>[1330, 1368, 0]"]
18["Segment<br>[1330, 1368, 0]"]
19["Segment<br>[1330, 1368, 0]"]
20["Segment<br>[1330, 1368, 0]"]
21["Segment<br>[1330, 1368, 0]"]
22["Segment<br>[1330, 1368, 0]"]
23["Segment<br>[1330, 1368, 0]"]
24["Segment<br>[1330, 1368, 0]"]
25["Segment<br>[1330, 1368, 0]"]
26["Segment<br>[1330, 1368, 0]"]
27["Segment<br>[1330, 1368, 0]"]
28["Segment<br>[1330, 1368, 0]"]
29["Segment<br>[1330, 1368, 0]"]
30["Segment<br>[1330, 1368, 0]"]
31["Segment<br>[1330, 1368, 0]"]
32["Segment<br>[1330, 1368, 0]"]
33["Segment<br>[1330, 1368, 0]"]
34["Segment<br>[1330, 1368, 0]"]
35["Segment<br>[1330, 1368, 0]"]
36["Segment<br>[1330, 1368, 0]"]
37["Segment<br>[1330, 1368, 0]"]
38["Segment<br>[1330, 1368, 0]"]
39["Segment<br>[1330, 1368, 0]"]
40["Segment<br>[1330, 1368, 0]"]
41["Segment<br>[1330, 1368, 0]"]
42["Segment<br>[1330, 1368, 0]"]
43["Segment<br>[1330, 1368, 0]"]
44["Segment<br>[1330, 1368, 0]"]
45["Segment<br>[1330, 1368, 0]"]
46["Segment<br>[1330, 1368, 0]"]
47["Segment<br>[1330, 1368, 0]"]
48["Segment<br>[1330, 1368, 0]"]
49["Segment<br>[1330, 1368, 0]"]
50["Segment<br>[1330, 1368, 0]"]
51["Segment<br>[1330, 1368, 0]"]
52["Segment<br>[1330, 1368, 0]"]
53["Segment<br>[1330, 1368, 0]"]
54["Segment<br>[1330, 1368, 0]"]
55["Segment<br>[1330, 1368, 0]"]
56["Segment<br>[1330, 1368, 0]"]
57["Segment<br>[1330, 1368, 0]"]
58["Segment<br>[1330, 1368, 0]"]
59["Segment<br>[1330, 1368, 0]"]
60["Segment<br>[1330, 1368, 0]"]
61["Segment<br>[1330, 1368, 0]"]
62["Segment<br>[1330, 1368, 0]"]
63["Segment<br>[1330, 1368, 0]"]
64["Segment<br>[1330, 1368, 0]"]
65["Segment<br>[1330, 1368, 0]"]
66["Segment<br>[1330, 1368, 0]"]
67["Segment<br>[1330, 1368, 0]"]
68["Segment<br>[1330, 1368, 0]"]
69["Segment<br>[1330, 1368, 0]"]
70["Segment<br>[1330, 1368, 0]"]
71["Segment<br>[1330, 1368, 0]"]
72["Segment<br>[1330, 1368, 0]"]
73["Segment<br>[1330, 1368, 0]"]
74["Segment<br>[1330, 1368, 0]"]
75["Segment<br>[1330, 1368, 0]"]
76["Segment<br>[1330, 1368, 0]"]
77["Segment<br>[1330, 1368, 0]"]
78["Segment<br>[1330, 1368, 0]"]
79["Segment<br>[1330, 1368, 0]"]
80["Segment<br>[1330, 1368, 0]"]
81["Segment<br>[1330, 1368, 0]"]
82["Segment<br>[1330, 1368, 0]"]
83["Segment<br>[1330, 1368, 0]"]
84["Segment<br>[1330, 1368, 0]"]
85["Segment<br>[1330, 1368, 0]"]
86["Segment<br>[1330, 1368, 0]"]
87["Segment<br>[1330, 1368, 0]"]
88["Segment<br>[1330, 1368, 0]"]
89["Segment<br>[1330, 1368, 0]"]
90["Segment<br>[1330, 1368, 0]"]
91["Segment<br>[1330, 1368, 0]"]
92["Segment<br>[1330, 1368, 0]"]
93["Segment<br>[1330, 1368, 0]"]
94["Segment<br>[1330, 1368, 0]"]
95["Segment<br>[1330, 1368, 0]"]
96["Segment<br>[1330, 1368, 0]"]
97["Segment<br>[1330, 1368, 0]"]
98["Segment<br>[1330, 1368, 0]"]
99["Segment<br>[1330, 1368, 0]"]
100["Segment<br>[1330, 1368, 0]"]
101["Segment<br>[1330, 1368, 0]"]
102["Segment<br>[1330, 1368, 0]"]
103["Segment<br>[1330, 1368, 0]"]
104["Segment<br>[1330, 1368, 0]"]
105["Segment<br>[1330, 1368, 0]"]
106["Segment<br>[1330, 1368, 0]"]
107["Segment<br>[1330, 1368, 0]"]
108["Segment<br>[1330, 1368, 0]"]
109["Segment<br>[1330, 1368, 0]"]
110["Segment<br>[1562, 1592, 0]"]
111["Segment<br>[1562, 1592, 0]"]
112["Segment<br>[1562, 1592, 0]"]
113["Segment<br>[1562, 1592, 0]"]
114["Segment<br>[1562, 1592, 0]"]
115["Segment<br>[1562, 1592, 0]"]
116["Segment<br>[1562, 1592, 0]"]
117["Segment<br>[1562, 1592, 0]"]
118["Segment<br>[1562, 1592, 0]"]
119["Segment<br>[1562, 1592, 0]"]
120["Segment<br>[1562, 1592, 0]"]
121["Segment<br>[1562, 1592, 0]"]
122["Segment<br>[1562, 1592, 0]"]
123["Segment<br>[1562, 1592, 0]"]
124["Segment<br>[1562, 1592, 0]"]
125["Segment<br>[1562, 1592, 0]"]
126["Segment<br>[1562, 1592, 0]"]
127["Segment<br>[1562, 1592, 0]"]
128["Segment<br>[1562, 1592, 0]"]
129["Segment<br>[1562, 1592, 0]"]
130["Segment<br>[1562, 1592, 0]"]
131["Segment<br>[1562, 1592, 0]"]
132["Segment<br>[1562, 1592, 0]"]
133["Segment<br>[1562, 1592, 0]"]
134["Segment<br>[1562, 1592, 0]"]
135["Segment<br>[1562, 1592, 0]"]
136["Segment<br>[1562, 1592, 0]"]
137["Segment<br>[1562, 1592, 0]"]
138["Segment<br>[1562, 1592, 0]"]
139["Segment<br>[1562, 1592, 0]"]
140["Segment<br>[1562, 1592, 0]"]
141["Segment<br>[1562, 1592, 0]"]
142["Segment<br>[1562, 1592, 0]"]
143["Segment<br>[1562, 1592, 0]"]
144["Segment<br>[1562, 1592, 0]"]
145["Segment<br>[1562, 1592, 0]"]
146["Segment<br>[1562, 1592, 0]"]
147["Segment<br>[1562, 1592, 0]"]
148["Segment<br>[1562, 1592, 0]"]
149["Segment<br>[1562, 1592, 0]"]
150["Segment<br>[1562, 1592, 0]"]
151["Segment<br>[1562, 1592, 0]"]
152["Segment<br>[1562, 1592, 0]"]
153["Segment<br>[1562, 1592, 0]"]
154["Segment<br>[1562, 1592, 0]"]
155["Segment<br>[1562, 1592, 0]"]
156["Segment<br>[1562, 1592, 0]"]
157["Segment<br>[1562, 1592, 0]"]
158["Segment<br>[1562, 1592, 0]"]
159["Segment<br>[1562, 1592, 0]"]
160["Segment<br>[1562, 1592, 0]"]
161["Segment<br>[1562, 1592, 0]"]
162["Segment<br>[1562, 1592, 0]"]
163["Segment<br>[1562, 1592, 0]"]
164["Segment<br>[1562, 1592, 0]"]
165["Segment<br>[1562, 1592, 0]"]
166["Segment<br>[1562, 1592, 0]"]
167["Segment<br>[1562, 1592, 0]"]
168["Segment<br>[1562, 1592, 0]"]
169["Segment<br>[1562, 1592, 0]"]
170["Segment<br>[1562, 1592, 0]"]
171["Segment<br>[1562, 1592, 0]"]
172["Segment<br>[1562, 1592, 0]"]
173["Segment<br>[1562, 1592, 0]"]
174["Segment<br>[1562, 1592, 0]"]
175["Segment<br>[1562, 1592, 0]"]
176["Segment<br>[1562, 1592, 0]"]
177["Segment<br>[1562, 1592, 0]"]
178["Segment<br>[1562, 1592, 0]"]
179["Segment<br>[1562, 1592, 0]"]
180["Segment<br>[1562, 1592, 0]"]
181["Segment<br>[1562, 1592, 0]"]
182["Segment<br>[1562, 1592, 0]"]
183["Segment<br>[1562, 1592, 0]"]
184["Segment<br>[1562, 1592, 0]"]
185["Segment<br>[1562, 1592, 0]"]
186["Segment<br>[1562, 1592, 0]"]
187["Segment<br>[1562, 1592, 0]"]
188["Segment<br>[1562, 1592, 0]"]
189["Segment<br>[1562, 1592, 0]"]
190["Segment<br>[1562, 1592, 0]"]
191["Segment<br>[1562, 1592, 0]"]
192["Segment<br>[1562, 1592, 0]"]
193["Segment<br>[1562, 1592, 0]"]
194["Segment<br>[1562, 1592, 0]"]
195["Segment<br>[1562, 1592, 0]"]
196["Segment<br>[1562, 1592, 0]"]
197["Segment<br>[1562, 1592, 0]"]
198["Segment<br>[1562, 1592, 0]"]
199["Segment<br>[1562, 1592, 0]"]
200["Segment<br>[1562, 1592, 0]"]
201["Segment<br>[1562, 1592, 0]"]
202["Segment<br>[1562, 1592, 0]"]
203["Segment<br>[1562, 1592, 0]"]
204["Segment<br>[1562, 1592, 0]"]
205["Segment<br>[1562, 1592, 0]"]
206["Segment<br>[1562, 1592, 0]"]
207["Segment<br>[1562, 1592, 0]"]
208["Segment<br>[1562, 1592, 0]"]
209["Segment<br>[1562, 1592, 0]"]
210["Segment<br>[1562, 1592, 0]"]
211["Segment<br>[1749, 1847, 0]"]
212["Segment<br>[1907, 1914, 0]"]
6["Path<br>[1664, 1701, 0]"]
9["Segment<br>[1336, 1374, 0]"]
10["Segment<br>[1336, 1374, 0]"]
11["Segment<br>[1336, 1374, 0]"]
12["Segment<br>[1336, 1374, 0]"]
13["Segment<br>[1336, 1374, 0]"]
14["Segment<br>[1336, 1374, 0]"]
15["Segment<br>[1336, 1374, 0]"]
16["Segment<br>[1336, 1374, 0]"]
17["Segment<br>[1336, 1374, 0]"]
18["Segment<br>[1336, 1374, 0]"]
19["Segment<br>[1336, 1374, 0]"]
20["Segment<br>[1336, 1374, 0]"]
21["Segment<br>[1336, 1374, 0]"]
22["Segment<br>[1336, 1374, 0]"]
23["Segment<br>[1336, 1374, 0]"]
24["Segment<br>[1336, 1374, 0]"]
25["Segment<br>[1336, 1374, 0]"]
26["Segment<br>[1336, 1374, 0]"]
27["Segment<br>[1336, 1374, 0]"]
28["Segment<br>[1336, 1374, 0]"]
29["Segment<br>[1336, 1374, 0]"]
30["Segment<br>[1336, 1374, 0]"]
31["Segment<br>[1336, 1374, 0]"]
32["Segment<br>[1336, 1374, 0]"]
33["Segment<br>[1336, 1374, 0]"]
34["Segment<br>[1336, 1374, 0]"]
35["Segment<br>[1336, 1374, 0]"]
36["Segment<br>[1336, 1374, 0]"]
37["Segment<br>[1336, 1374, 0]"]
38["Segment<br>[1336, 1374, 0]"]
39["Segment<br>[1336, 1374, 0]"]
40["Segment<br>[1336, 1374, 0]"]
41["Segment<br>[1336, 1374, 0]"]
42["Segment<br>[1336, 1374, 0]"]
43["Segment<br>[1336, 1374, 0]"]
44["Segment<br>[1336, 1374, 0]"]
45["Segment<br>[1336, 1374, 0]"]
46["Segment<br>[1336, 1374, 0]"]
47["Segment<br>[1336, 1374, 0]"]
48["Segment<br>[1336, 1374, 0]"]
49["Segment<br>[1336, 1374, 0]"]
50["Segment<br>[1336, 1374, 0]"]
51["Segment<br>[1336, 1374, 0]"]
52["Segment<br>[1336, 1374, 0]"]
53["Segment<br>[1336, 1374, 0]"]
54["Segment<br>[1336, 1374, 0]"]
55["Segment<br>[1336, 1374, 0]"]
56["Segment<br>[1336, 1374, 0]"]
57["Segment<br>[1336, 1374, 0]"]
58["Segment<br>[1336, 1374, 0]"]
59["Segment<br>[1336, 1374, 0]"]
60["Segment<br>[1336, 1374, 0]"]
61["Segment<br>[1336, 1374, 0]"]
62["Segment<br>[1336, 1374, 0]"]
63["Segment<br>[1336, 1374, 0]"]
64["Segment<br>[1336, 1374, 0]"]
65["Segment<br>[1336, 1374, 0]"]
66["Segment<br>[1336, 1374, 0]"]
67["Segment<br>[1336, 1374, 0]"]
68["Segment<br>[1336, 1374, 0]"]
69["Segment<br>[1336, 1374, 0]"]
70["Segment<br>[1336, 1374, 0]"]
71["Segment<br>[1336, 1374, 0]"]
72["Segment<br>[1336, 1374, 0]"]
73["Segment<br>[1336, 1374, 0]"]
74["Segment<br>[1336, 1374, 0]"]
75["Segment<br>[1336, 1374, 0]"]
76["Segment<br>[1336, 1374, 0]"]
77["Segment<br>[1336, 1374, 0]"]
78["Segment<br>[1336, 1374, 0]"]
79["Segment<br>[1336, 1374, 0]"]
80["Segment<br>[1336, 1374, 0]"]
81["Segment<br>[1336, 1374, 0]"]
82["Segment<br>[1336, 1374, 0]"]
83["Segment<br>[1336, 1374, 0]"]
84["Segment<br>[1336, 1374, 0]"]
85["Segment<br>[1336, 1374, 0]"]
86["Segment<br>[1336, 1374, 0]"]
87["Segment<br>[1336, 1374, 0]"]
88["Segment<br>[1336, 1374, 0]"]
89["Segment<br>[1336, 1374, 0]"]
90["Segment<br>[1336, 1374, 0]"]
91["Segment<br>[1336, 1374, 0]"]
92["Segment<br>[1336, 1374, 0]"]
93["Segment<br>[1336, 1374, 0]"]
94["Segment<br>[1336, 1374, 0]"]
95["Segment<br>[1336, 1374, 0]"]
96["Segment<br>[1336, 1374, 0]"]
97["Segment<br>[1336, 1374, 0]"]
98["Segment<br>[1336, 1374, 0]"]
99["Segment<br>[1336, 1374, 0]"]
100["Segment<br>[1336, 1374, 0]"]
101["Segment<br>[1336, 1374, 0]"]
102["Segment<br>[1336, 1374, 0]"]
103["Segment<br>[1336, 1374, 0]"]
104["Segment<br>[1336, 1374, 0]"]
105["Segment<br>[1336, 1374, 0]"]
106["Segment<br>[1336, 1374, 0]"]
107["Segment<br>[1336, 1374, 0]"]
108["Segment<br>[1336, 1374, 0]"]
109["Segment<br>[1336, 1374, 0]"]
110["Segment<br>[1580, 1610, 0]"]
111["Segment<br>[1580, 1610, 0]"]
112["Segment<br>[1580, 1610, 0]"]
113["Segment<br>[1580, 1610, 0]"]
114["Segment<br>[1580, 1610, 0]"]
115["Segment<br>[1580, 1610, 0]"]
116["Segment<br>[1580, 1610, 0]"]
117["Segment<br>[1580, 1610, 0]"]
118["Segment<br>[1580, 1610, 0]"]
119["Segment<br>[1580, 1610, 0]"]
120["Segment<br>[1580, 1610, 0]"]
121["Segment<br>[1580, 1610, 0]"]
122["Segment<br>[1580, 1610, 0]"]
123["Segment<br>[1580, 1610, 0]"]
124["Segment<br>[1580, 1610, 0]"]
125["Segment<br>[1580, 1610, 0]"]
126["Segment<br>[1580, 1610, 0]"]
127["Segment<br>[1580, 1610, 0]"]
128["Segment<br>[1580, 1610, 0]"]
129["Segment<br>[1580, 1610, 0]"]
130["Segment<br>[1580, 1610, 0]"]
131["Segment<br>[1580, 1610, 0]"]
132["Segment<br>[1580, 1610, 0]"]
133["Segment<br>[1580, 1610, 0]"]
134["Segment<br>[1580, 1610, 0]"]
135["Segment<br>[1580, 1610, 0]"]
136["Segment<br>[1580, 1610, 0]"]
137["Segment<br>[1580, 1610, 0]"]
138["Segment<br>[1580, 1610, 0]"]
139["Segment<br>[1580, 1610, 0]"]
140["Segment<br>[1580, 1610, 0]"]
141["Segment<br>[1580, 1610, 0]"]
142["Segment<br>[1580, 1610, 0]"]
143["Segment<br>[1580, 1610, 0]"]
144["Segment<br>[1580, 1610, 0]"]
145["Segment<br>[1580, 1610, 0]"]
146["Segment<br>[1580, 1610, 0]"]
147["Segment<br>[1580, 1610, 0]"]
148["Segment<br>[1580, 1610, 0]"]
149["Segment<br>[1580, 1610, 0]"]
150["Segment<br>[1580, 1610, 0]"]
151["Segment<br>[1580, 1610, 0]"]
152["Segment<br>[1580, 1610, 0]"]
153["Segment<br>[1580, 1610, 0]"]
154["Segment<br>[1580, 1610, 0]"]
155["Segment<br>[1580, 1610, 0]"]
156["Segment<br>[1580, 1610, 0]"]
157["Segment<br>[1580, 1610, 0]"]
158["Segment<br>[1580, 1610, 0]"]
159["Segment<br>[1580, 1610, 0]"]
160["Segment<br>[1580, 1610, 0]"]
161["Segment<br>[1580, 1610, 0]"]
162["Segment<br>[1580, 1610, 0]"]
163["Segment<br>[1580, 1610, 0]"]
164["Segment<br>[1580, 1610, 0]"]
165["Segment<br>[1580, 1610, 0]"]
166["Segment<br>[1580, 1610, 0]"]
167["Segment<br>[1580, 1610, 0]"]
168["Segment<br>[1580, 1610, 0]"]
169["Segment<br>[1580, 1610, 0]"]
170["Segment<br>[1580, 1610, 0]"]
171["Segment<br>[1580, 1610, 0]"]
172["Segment<br>[1580, 1610, 0]"]
173["Segment<br>[1580, 1610, 0]"]
174["Segment<br>[1580, 1610, 0]"]
175["Segment<br>[1580, 1610, 0]"]
176["Segment<br>[1580, 1610, 0]"]
177["Segment<br>[1580, 1610, 0]"]
178["Segment<br>[1580, 1610, 0]"]
179["Segment<br>[1580, 1610, 0]"]
180["Segment<br>[1580, 1610, 0]"]
181["Segment<br>[1580, 1610, 0]"]
182["Segment<br>[1580, 1610, 0]"]
183["Segment<br>[1580, 1610, 0]"]
184["Segment<br>[1580, 1610, 0]"]
185["Segment<br>[1580, 1610, 0]"]
186["Segment<br>[1580, 1610, 0]"]
187["Segment<br>[1580, 1610, 0]"]
188["Segment<br>[1580, 1610, 0]"]
189["Segment<br>[1580, 1610, 0]"]
190["Segment<br>[1580, 1610, 0]"]
191["Segment<br>[1580, 1610, 0]"]
192["Segment<br>[1580, 1610, 0]"]
193["Segment<br>[1580, 1610, 0]"]
194["Segment<br>[1580, 1610, 0]"]
195["Segment<br>[1580, 1610, 0]"]
196["Segment<br>[1580, 1610, 0]"]
197["Segment<br>[1580, 1610, 0]"]
198["Segment<br>[1580, 1610, 0]"]
199["Segment<br>[1580, 1610, 0]"]
200["Segment<br>[1580, 1610, 0]"]
201["Segment<br>[1580, 1610, 0]"]
202["Segment<br>[1580, 1610, 0]"]
203["Segment<br>[1580, 1610, 0]"]
204["Segment<br>[1580, 1610, 0]"]
205["Segment<br>[1580, 1610, 0]"]
206["Segment<br>[1580, 1610, 0]"]
207["Segment<br>[1580, 1610, 0]"]
208["Segment<br>[1580, 1610, 0]"]
209["Segment<br>[1580, 1610, 0]"]
210["Segment<br>[1580, 1610, 0]"]
211["Segment<br>[1767, 1865, 0]"]
212["Segment<br>[1925, 1932, 0]"]
219[Solid2d]
end
subgraph path7 [Path]
7["Path<br>[2395, 2486, 0]"]
213["Segment<br>[2492, 2519, 0]"]
214["Segment<br>[2525, 2553, 0]"]
215["Segment<br>[2559, 2587, 0]"]
216["Segment<br>[2593, 2716, 0]"]
217["Segment<br>[2722, 2834, 0]"]
218["Segment<br>[2840, 2847, 0]"]
7["Path<br>[2419, 2510, 0]"]
213["Segment<br>[2516, 2543, 0]"]
214["Segment<br>[2549, 2577, 0]"]
215["Segment<br>[2583, 2611, 0]"]
216["Segment<br>[2617, 2740, 0]"]
217["Segment<br>[2746, 2858, 0]"]
218["Segment<br>[2864, 2871, 0]"]
221[Solid2d]
end
1["Plane<br>[168, 185, 0]"]
2["Plane<br>[1092, 1109, 0]"]
3["Plane<br>[1623, 1640, 0]"]
4["StartSketchOnFace<br>[2358, 2389, 0]"]
222["Sweep Extrusion<br>[1171, 1199, 0]"]
223["Sweep Extrusion<br>[1920, 1948, 0]"]
224["Sweep Extrusion<br>[2853, 2882, 0]"]
2["Plane<br>[1098, 1115, 0]"]
3["Plane<br>[1641, 1658, 0]"]
4["StartSketchOnFace<br>[2382, 2413, 0]"]
222["Sweep Extrusion<br>[1177, 1205, 0]"]
223["Sweep Extrusion<br>[1938, 1966, 0]"]
224["Sweep Extrusion<br>[2877, 2906, 0]"]
225[Wall]
226[Wall]
227[Wall]

View File

@ -1047,7 +1047,15 @@ description: Result of parsing import_async.kcl
"start": 0,
"type": "Identifier"
},
"path": [],
"path": [
{
"commentStart": 0,
"end": 0,
"name": "math",
"start": 0,
"type": "Identifier"
}
],
"start": 0,
"type": "Name"
},
@ -2598,7 +2606,15 @@ description: Result of parsing import_async.kcl
"start": 0,
"type": "Identifier"
},
"path": [],
"path": [
{
"commentStart": 0,
"end": 0,
"name": "math",
"start": 0,
"type": "Identifier"
}
],
"start": 0,
"type": "Name"
},
@ -2835,7 +2851,15 @@ description: Result of parsing import_async.kcl
"start": 0,
"type": "Identifier"
},
"path": [],
"path": [
{
"commentStart": 0,
"end": 0,
"name": "math",
"start": 0,
"type": "Identifier"
}
],
"start": 0,
"type": "Name"
},
@ -4129,7 +4153,15 @@ description: Result of parsing import_async.kcl
"start": 0,
"type": "Identifier"
},
"path": [],
"path": [
{
"commentStart": 0,
"end": 0,
"name": "math",
"start": 0,
"type": "Identifier"
}
],
"start": 0,
"type": "Name"
},

View File

@ -28,7 +28,7 @@ rs = map([0..cmo], f = fn(i) {
// Calculate operating pressure angle
angles = map(rs, f = fn(r) {
return units::toDegrees( acos(baseDiameter / 2 / r))
return units::toDegrees( math::acos(baseDiameter / 2 / r))
})
// Calculate the involute function
@ -59,8 +59,8 @@ fn leftInvolute(i, sg) {
}
fn rightInvolute(i, sg) {
x = rs[i] * math::cos(-toothAngle + units::toDegrees(atan(ys[i] / xs[i])))
y = -rs[i] * math::sin(-toothAngle + units::toDegrees(atan(ys[i] / xs[i])))
x = rs[i] * math::cos(-toothAngle + units::toDegrees(math::atan(ys[i] / xs[i])))
y = -rs[i] * math::sin(-toothAngle + units::toDegrees(math::atan(ys[i] / xs[i])))
return line(sg, endAbsolute = [x, y])
}
@ -89,7 +89,7 @@ keywayWidth = 0.250
keywayDepth = keywayWidth / 2
holeDiam = 2
holeRadius = 1
startAngle = asin(keywayWidth / 2 / holeRadius)
startAngle = math::asin(keywayWidth / 2 / holeRadius)
// Sketch the keyway and center hole and extrude
keyWay = startSketchOn(body, face = END)

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,7 @@ rs = map(
angles = map(
rs,
f = fn(r) {
return units::toDegrees( acos(baseDiameter / 2 / r))
return units::toDegrees( math::acos(baseDiameter / 2 / r))
},
)
@ -77,8 +77,8 @@ fn leftInvolute(i, sg) {
}
fn rightInvolute(i, sg) {
x = rs[i] * math::cos(-toothAngle + units::toDegrees(atan(ys[i] / xs[i])))
y = -rs[i] * math::sin(-toothAngle + units::toDegrees(atan(ys[i] / xs[i])))
x = rs[i] * math::cos(-toothAngle + units::toDegrees(math::atan(ys[i] / xs[i])))
y = -rs[i] * math::sin(-toothAngle + units::toDegrees(math::atan(ys[i] / xs[i])))
return line(sg, endAbsolute = [x, y])
}
@ -103,7 +103,7 @@ keywayWidth = 0.250
keywayDepth = keywayWidth / 2
holeDiam = 2
holeRadius = 1
startAngle = asin(keywayWidth / 2 / holeRadius)
startAngle = math::asin(keywayWidth / 2 / holeRadius)
// Sketch the keyway and center hole and extrude
keyWay = startSketchOn(body, face = END)

View File

@ -313,14 +313,14 @@ flowchart LR
265["SweepEdge Adjacent"]
266["SweepEdge Adjacent"]
267["SweepEdge Adjacent"]
268["EdgeCut Fillet<br>[5113, 5624, 8]"]
269["EdgeCut Fillet<br>[5113, 5624, 8]"]
270["EdgeCut Fillet<br>[5113, 5624, 8]"]
271["EdgeCut Fillet<br>[5113, 5624, 8]"]
272["EdgeCut Fillet<br>[5113, 5624, 8]"]
273["EdgeCut Fillet<br>[5113, 5624, 8]"]
274["EdgeCut Fillet<br>[5113, 5624, 8]"]
275["EdgeCut Fillet<br>[5113, 5624, 8]"]
268["EdgeCut Fillet<br>[5113, 5630, 8]"]
269["EdgeCut Fillet<br>[5113, 5630, 8]"]
270["EdgeCut Fillet<br>[5113, 5630, 8]"]
271["EdgeCut Fillet<br>[5113, 5630, 8]"]
272["EdgeCut Fillet<br>[5113, 5630, 8]"]
273["EdgeCut Fillet<br>[5113, 5630, 8]"]
274["EdgeCut Fillet<br>[5113, 5630, 8]"]
275["EdgeCut Fillet<br>[5113, 5630, 8]"]
276["EdgeCut Fillet<br>[394, 452, 10]"]
277["EdgeCut Fillet<br>[394, 452, 10]"]
1 --- 8

View File

@ -3,6 +3,17 @@ source: kcl-lib/src/simulation_tests.rs
description: Operations executed bracket.kcl
---
[
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "sqrt",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"labeledArgs": {
"planeOrSolid": {
@ -341,5 +352,8 @@ description: Operations executed bracket.kcl
}
},
"sourceRange": []
},
{
"type": "GroupEnd"
}
]

View File

@ -608,7 +608,7 @@ flowchart LR
83 --- 246
83 --- 289
90 --- 159
90 x--> 193
90 x--> 192
90 --- 226
90 --- 271
104 --- 151
@ -906,7 +906,7 @@ flowchart LR
211 <--x 188
212 <--x 188
213 <--x 188
226 <--x 192
226 <--x 193
239 <--x 196
240 <--x 196
241 <--x 196

View File

@ -1,83 +1,83 @@
```mermaid
flowchart LR
subgraph path6 [Path]
6["Path<br>[1017, 1061, 0]"]
16["Segment<br>[1069, 1109, 0]"]
17["Segment<br>[1117, 1163, 0]"]
22["Segment<br>[1171, 1212, 0]"]
25["Segment<br>[1220, 1285, 0]"]
29["Segment<br>[1293, 1300, 0]"]
6["Path<br>[1029, 1073, 0]"]
16["Segment<br>[1081, 1121, 0]"]
17["Segment<br>[1129, 1175, 0]"]
22["Segment<br>[1183, 1224, 0]"]
25["Segment<br>[1232, 1297, 0]"]
29["Segment<br>[1305, 1312, 0]"]
56[Solid2d]
end
subgraph path7 [Path]
7["Path<br>[1017, 1061, 0]"]
15["Segment<br>[1069, 1109, 0]"]
19["Segment<br>[1117, 1163, 0]"]
24["Segment<br>[1171, 1212, 0]"]
26["Segment<br>[1220, 1285, 0]"]
30["Segment<br>[1293, 1300, 0]"]
7["Path<br>[1029, 1073, 0]"]
15["Segment<br>[1081, 1121, 0]"]
19["Segment<br>[1129, 1175, 0]"]
24["Segment<br>[1183, 1224, 0]"]
26["Segment<br>[1232, 1297, 0]"]
30["Segment<br>[1305, 1312, 0]"]
58[Solid2d]
end
subgraph path8 [Path]
8["Path<br>[1017, 1061, 0]"]
13["Segment<br>[1069, 1109, 0]"]
20["Segment<br>[1117, 1163, 0]"]
21["Segment<br>[1171, 1212, 0]"]
27["Segment<br>[1220, 1285, 0]"]
32["Segment<br>[1293, 1300, 0]"]
8["Path<br>[1029, 1073, 0]"]
13["Segment<br>[1081, 1121, 0]"]
20["Segment<br>[1129, 1175, 0]"]
21["Segment<br>[1183, 1224, 0]"]
27["Segment<br>[1232, 1297, 0]"]
32["Segment<br>[1305, 1312, 0]"]
59[Solid2d]
end
subgraph path9 [Path]
9["Path<br>[1017, 1061, 0]"]
14["Segment<br>[1069, 1109, 0]"]
18["Segment<br>[1117, 1163, 0]"]
23["Segment<br>[1171, 1212, 0]"]
28["Segment<br>[1220, 1285, 0]"]
31["Segment<br>[1293, 1300, 0]"]
9["Path<br>[1029, 1073, 0]"]
14["Segment<br>[1081, 1121, 0]"]
18["Segment<br>[1129, 1175, 0]"]
23["Segment<br>[1183, 1224, 0]"]
28["Segment<br>[1232, 1297, 0]"]
31["Segment<br>[1305, 1312, 0]"]
60[Solid2d]
end
subgraph path10 [Path]
10["Path<br>[1464, 1521, 0]"]
33["Segment<br>[1527, 1559, 0]"]
34["Segment<br>[1565, 1602, 0]"]
35["Segment<br>[1608, 1641, 0]"]
36["Segment<br>[1647, 1714, 0]"]
37["Segment<br>[1720, 1727, 0]"]
10["Path<br>[1476, 1533, 0]"]
33["Segment<br>[1539, 1571, 0]"]
34["Segment<br>[1577, 1614, 0]"]
35["Segment<br>[1620, 1653, 0]"]
36["Segment<br>[1659, 1726, 0]"]
37["Segment<br>[1732, 1739, 0]"]
57[Solid2d]
end
subgraph path11 [Path]
11["Path<br>[2760, 2816, 0]"]
38["Segment<br>[2822, 2881, 0]"]
39["Segment<br>[2887, 2922, 0]"]
40["Segment<br>[2928, 2961, 0]"]
41["Segment<br>[2967, 3026, 0]"]
42["Segment<br>[3032, 3068, 0]"]
43["Segment<br>[3074, 3098, 0]"]
44["Segment<br>[3104, 3111, 0]"]
11["Path<br>[2772, 2828, 0]"]
38["Segment<br>[2834, 2893, 0]"]
39["Segment<br>[2899, 2934, 0]"]
40["Segment<br>[2940, 2973, 0]"]
41["Segment<br>[2979, 3038, 0]"]
42["Segment<br>[3044, 3080, 0]"]
43["Segment<br>[3086, 3110, 0]"]
44["Segment<br>[3116, 3123, 0]"]
54[Solid2d]
end
subgraph path12 [Path]
12["Path<br>[3706, 3756, 0]"]
45["Segment<br>[3762, 3812, 0]"]
46["Segment<br>[3818, 3884, 0]"]
47["Segment<br>[3890, 3941, 0]"]
48["Segment<br>[3947, 4012, 0]"]
49["Segment<br>[4018, 4071, 0]"]
50["Segment<br>[4077, 4144, 0]"]
51["Segment<br>[4150, 4224, 0]"]
52["Segment<br>[4230, 4298, 0]"]
53["Segment<br>[4304, 4311, 0]"]
12["Path<br>[3718, 3768, 0]"]
45["Segment<br>[3774, 3824, 0]"]
46["Segment<br>[3830, 3896, 0]"]
47["Segment<br>[3902, 3953, 0]"]
48["Segment<br>[3959, 4024, 0]"]
49["Segment<br>[4030, 4083, 0]"]
50["Segment<br>[4089, 4156, 0]"]
51["Segment<br>[4162, 4236, 0]"]
52["Segment<br>[4242, 4310, 0]"]
53["Segment<br>[4316, 4323, 0]"]
55[Solid2d]
end
1["Plane<br>[1393, 1410, 0]"]
2["Plane<br>[2657, 2699, 0]"]
3["Plane<br>[3632, 3658, 0]"]
4["StartSketchOnPlane<br>[2643, 2700, 0]"]
5["StartSketchOnFace<br>[4468, 4507, 0]"]
61["Sweep Extrusion<br>[2332, 2382, 0]"]
62["Sweep Extrusion<br>[3145, 3189, 0]"]
63["Sweep Extrusion<br>[4367, 4409, 0]"]
64["Sweep Extrusion<br>[4644, 4694, 0]"]
1["Plane<br>[1405, 1422, 0]"]
2["Plane<br>[2669, 2711, 0]"]
3["Plane<br>[3644, 3670, 0]"]
4["StartSketchOnPlane<br>[2655, 2712, 0]"]
5["StartSketchOnFace<br>[4480, 4519, 0]"]
61["Sweep Extrusion<br>[2344, 2394, 0]"]
62["Sweep Extrusion<br>[3157, 3201, 0]"]
63["Sweep Extrusion<br>[4379, 4421, 0]"]
64["Sweep Extrusion<br>[4656, 4706, 0]"]
65[Wall]
66[Wall]
67[Wall]
@ -156,10 +156,10 @@ flowchart LR
140["SweepEdge Adjacent"]
141["SweepEdge Adjacent"]
142["SweepEdge Adjacent"]
143["EdgeCut Fillet<br>[2419, 2560, 0]"]
144["EdgeCut Fillet<br>[2419, 2560, 0]"]
145["EdgeCut Fillet<br>[3232, 3363, 0]"]
146["EdgeCut Fillet<br>[3232, 3363, 0]"]
143["EdgeCut Fillet<br>[2431, 2572, 0]"]
144["EdgeCut Fillet<br>[2431, 2572, 0]"]
145["EdgeCut Fillet<br>[3244, 3375, 0]"]
146["EdgeCut Fillet<br>[3244, 3375, 0]"]
1 --- 6
1 --- 8
1 --- 9

View File

@ -665,7 +665,15 @@ description: Result of parsing food-service-spatula.kcl
"start": 0,
"type": "Identifier"
},
"path": [],
"path": [
{
"commentStart": 0,
"end": 0,
"name": "math",
"start": 0,
"type": "Identifier"
}
],
"start": 0,
"type": "Name"
},
@ -875,7 +883,15 @@ description: Result of parsing food-service-spatula.kcl
"start": 0,
"type": "Identifier"
},
"path": [],
"path": [
{
"commentStart": 0,
"end": 0,
"name": "math",
"start": 0,
"type": "Identifier"
}
],
"start": 0,
"type": "Name"
},

View File

@ -36,6 +36,83 @@ description: Operations executed food-service-spatula.kcl
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "math::atan",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "math::atan",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "math::atan",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "sqrt",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "sqrt",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "sqrt",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "sqrt",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
@ -785,6 +862,27 @@ description: Operations executed food-service-spatula.kcl
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
}

View File

@ -27,9 +27,9 @@ description: Variables in memory after executing food-service-spatula.kcl
"id": "[uuid]",
"sourceRange": [],
"tag": {
"commentStart": 1592,
"end": 1601,
"start": 1592,
"commentStart": 1604,
"end": 1613,
"start": 1604,
"type": "TagDeclarator",
"value": "backEdge"
},
@ -90,9 +90,9 @@ description: Variables in memory after executing food-service-spatula.kcl
-30.0
],
"tag": {
"commentStart": 1592,
"end": 1601,
"start": 1592,
"commentStart": 1604,
"end": 1613,
"start": 1604,
"type": "TagDeclarator",
"value": "backEdge"
},
@ -299,9 +299,9 @@ description: Variables in memory after executing food-service-spatula.kcl
-30.0
],
"tag": {
"commentStart": 1592,
"end": 1601,
"start": 1592,
"commentStart": 1604,
"end": 1613,
"start": 1604,
"type": "TagDeclarator",
"value": "backEdge"
},
@ -551,9 +551,9 @@ description: Variables in memory after executing food-service-spatula.kcl
"id": "[uuid]",
"sourceRange": [],
"tag": {
"commentStart": 4211,
"end": 4223,
"start": 4211,
"commentStart": 4223,
"end": 4235,
"start": 4223,
"type": "TagDeclarator",
"value": "gripEdgeTop"
},
@ -713,9 +713,9 @@ description: Variables in memory after executing food-service-spatula.kcl
7.0
],
"tag": {
"commentStart": 4211,
"end": 4223,
"start": 4211,
"commentStart": 4223,
"end": 4235,
"start": 4223,
"type": "TagDeclarator",
"value": "gripEdgeTop"
},
@ -1058,9 +1058,9 @@ description: Variables in memory after executing food-service-spatula.kcl
"id": "[uuid]",
"sourceRange": [],
"tag": {
"commentStart": 4211,
"end": 4223,
"start": 4211,
"commentStart": 4223,
"end": 4235,
"start": 4223,
"type": "TagDeclarator",
"value": "gripEdgeTop"
},
@ -1220,9 +1220,9 @@ description: Variables in memory after executing food-service-spatula.kcl
7.0
],
"tag": {
"commentStart": 4211,
"end": 4223,
"start": 4211,
"commentStart": 4223,
"end": 4235,
"start": 4223,
"type": "TagDeclarator",
"value": "gripEdgeTop"
},
@ -1538,9 +1538,9 @@ description: Variables in memory after executing food-service-spatula.kcl
7.0
],
"tag": {
"commentStart": 4211,
"end": 4223,
"start": 4211,
"commentStart": 4223,
"end": 4235,
"start": 4223,
"type": "TagDeclarator",
"value": "gripEdgeTop"
},
@ -1729,9 +1729,9 @@ description: Variables in memory after executing food-service-spatula.kcl
"id": "[uuid]",
"sourceRange": [],
"tag": {
"commentStart": 2863,
"end": 2880,
"start": 2863,
"commentStart": 2875,
"end": 2892,
"start": 2875,
"type": "TagDeclarator",
"value": "handleBottomEdge"
},
@ -1756,9 +1756,9 @@ description: Variables in memory after executing food-service-spatula.kcl
"id": "[uuid]",
"sourceRange": [],
"tag": {
"commentStart": 3011,
"end": 3025,
"start": 3011,
"commentStart": 3023,
"end": 3037,
"start": 3023,
"type": "TagDeclarator",
"value": "handleTopEdge"
},
@ -1800,9 +1800,9 @@ description: Variables in memory after executing food-service-spatula.kcl
3.5
],
"tag": {
"commentStart": 2863,
"end": 2880,
"start": 2863,
"commentStart": 2875,
"end": 2892,
"start": 2875,
"type": "TagDeclarator",
"value": "handleBottomEdge"
},
@ -1863,9 +1863,9 @@ description: Variables in memory after executing food-service-spatula.kcl
91.3213
],
"tag": {
"commentStart": 3011,
"end": 3025,
"start": 3011,
"commentStart": 3023,
"end": 3037,
"start": 3023,
"type": "TagDeclarator",
"value": "handleTopEdge"
},
@ -2211,9 +2211,9 @@ description: Variables in memory after executing food-service-spatula.kcl
3.5
],
"tag": {
"commentStart": 2863,
"end": 2880,
"start": 2863,
"commentStart": 2875,
"end": 2892,
"start": 2875,
"type": "TagDeclarator",
"value": "handleBottomEdge"
},
@ -2274,9 +2274,9 @@ description: Variables in memory after executing food-service-spatula.kcl
91.3213
],
"tag": {
"commentStart": 3011,
"end": 3025,
"start": 3011,
"commentStart": 3023,
"end": 3037,
"start": 3023,
"type": "TagDeclarator",
"value": "handleTopEdge"
},
@ -2536,9 +2536,9 @@ description: Variables in memory after executing food-service-spatula.kcl
"id": "[uuid]",
"sourceRange": [],
"tag": {
"commentStart": 4211,
"end": 4223,
"start": 4211,
"commentStart": 4223,
"end": 4235,
"start": 4223,
"type": "TagDeclarator",
"value": "gripEdgeTop"
},
@ -2698,9 +2698,9 @@ description: Variables in memory after executing food-service-spatula.kcl
7.0
],
"tag": {
"commentStart": 4211,
"end": 4223,
"start": 4211,
"commentStart": 4223,
"end": 4235,
"start": 4223,
"type": "TagDeclarator",
"value": "gripEdgeTop"
},
@ -3370,9 +3370,9 @@ description: Variables in memory after executing food-service-spatula.kcl
-30.0
],
"tag": {
"commentStart": 1592,
"end": 1601,
"start": 1592,
"commentStart": 1604,
"end": 1613,
"start": 1604,
"type": "TagDeclarator",
"value": "backEdge"
},

View File

@ -1,234 +1,234 @@
```mermaid
flowchart LR
subgraph path4 [Path]
4["Path<br>[1441, 1491, 0]"]
7["Segment<br>[1441, 1491, 0]"]
4["Path<br>[1447, 1497, 0]"]
7["Segment<br>[1447, 1497, 0]"]
219[Solid2d]
end
subgraph path5 [Path]
5["Path<br>[1972, 2009, 0]"]
8["Segment<br>[1656, 1694, 0]"]
9["Segment<br>[1656, 1694, 0]"]
10["Segment<br>[1656, 1694, 0]"]
11["Segment<br>[1656, 1694, 0]"]
12["Segment<br>[1656, 1694, 0]"]
13["Segment<br>[1656, 1694, 0]"]
14["Segment<br>[1656, 1694, 0]"]
15["Segment<br>[1656, 1694, 0]"]
16["Segment<br>[1656, 1694, 0]"]
17["Segment<br>[1656, 1694, 0]"]
18["Segment<br>[1656, 1694, 0]"]
19["Segment<br>[1656, 1694, 0]"]
20["Segment<br>[1656, 1694, 0]"]
21["Segment<br>[1656, 1694, 0]"]
22["Segment<br>[1656, 1694, 0]"]
23["Segment<br>[1656, 1694, 0]"]
24["Segment<br>[1656, 1694, 0]"]
25["Segment<br>[1656, 1694, 0]"]
26["Segment<br>[1656, 1694, 0]"]
27["Segment<br>[1656, 1694, 0]"]
28["Segment<br>[1656, 1694, 0]"]
29["Segment<br>[1656, 1694, 0]"]
30["Segment<br>[1656, 1694, 0]"]
31["Segment<br>[1656, 1694, 0]"]
32["Segment<br>[1656, 1694, 0]"]
33["Segment<br>[1656, 1694, 0]"]
34["Segment<br>[1656, 1694, 0]"]
35["Segment<br>[1656, 1694, 0]"]
36["Segment<br>[1656, 1694, 0]"]
37["Segment<br>[1656, 1694, 0]"]
38["Segment<br>[1656, 1694, 0]"]
39["Segment<br>[1656, 1694, 0]"]
40["Segment<br>[1656, 1694, 0]"]
41["Segment<br>[1656, 1694, 0]"]
42["Segment<br>[1656, 1694, 0]"]
43["Segment<br>[1656, 1694, 0]"]
44["Segment<br>[1656, 1694, 0]"]
45["Segment<br>[1656, 1694, 0]"]
46["Segment<br>[1656, 1694, 0]"]
47["Segment<br>[1656, 1694, 0]"]
48["Segment<br>[1656, 1694, 0]"]
49["Segment<br>[1656, 1694, 0]"]
50["Segment<br>[1656, 1694, 0]"]
51["Segment<br>[1656, 1694, 0]"]
52["Segment<br>[1656, 1694, 0]"]
53["Segment<br>[1656, 1694, 0]"]
54["Segment<br>[1656, 1694, 0]"]
55["Segment<br>[1656, 1694, 0]"]
56["Segment<br>[1656, 1694, 0]"]
57["Segment<br>[1656, 1694, 0]"]
58["Segment<br>[1656, 1694, 0]"]
59["Segment<br>[1656, 1694, 0]"]
60["Segment<br>[1656, 1694, 0]"]
61["Segment<br>[1656, 1694, 0]"]
62["Segment<br>[1656, 1694, 0]"]
63["Segment<br>[1656, 1694, 0]"]
64["Segment<br>[1656, 1694, 0]"]
65["Segment<br>[1656, 1694, 0]"]
66["Segment<br>[1656, 1694, 0]"]
67["Segment<br>[1656, 1694, 0]"]
68["Segment<br>[1656, 1694, 0]"]
69["Segment<br>[1656, 1694, 0]"]
70["Segment<br>[1656, 1694, 0]"]
71["Segment<br>[1656, 1694, 0]"]
72["Segment<br>[1656, 1694, 0]"]
73["Segment<br>[1656, 1694, 0]"]
74["Segment<br>[1656, 1694, 0]"]
75["Segment<br>[1656, 1694, 0]"]
76["Segment<br>[1656, 1694, 0]"]
77["Segment<br>[1656, 1694, 0]"]
78["Segment<br>[1656, 1694, 0]"]
79["Segment<br>[1656, 1694, 0]"]
80["Segment<br>[1656, 1694, 0]"]
81["Segment<br>[1656, 1694, 0]"]
82["Segment<br>[1656, 1694, 0]"]
83["Segment<br>[1656, 1694, 0]"]
84["Segment<br>[1656, 1694, 0]"]
85["Segment<br>[1656, 1694, 0]"]
86["Segment<br>[1656, 1694, 0]"]
87["Segment<br>[1656, 1694, 0]"]
88["Segment<br>[1656, 1694, 0]"]
89["Segment<br>[1656, 1694, 0]"]
90["Segment<br>[1656, 1694, 0]"]
91["Segment<br>[1656, 1694, 0]"]
92["Segment<br>[1656, 1694, 0]"]
93["Segment<br>[1656, 1694, 0]"]
94["Segment<br>[1656, 1694, 0]"]
95["Segment<br>[1656, 1694, 0]"]
96["Segment<br>[1656, 1694, 0]"]
97["Segment<br>[1656, 1694, 0]"]
98["Segment<br>[1656, 1694, 0]"]
99["Segment<br>[1656, 1694, 0]"]
100["Segment<br>[1656, 1694, 0]"]
101["Segment<br>[1656, 1694, 0]"]
102["Segment<br>[1656, 1694, 0]"]
103["Segment<br>[1656, 1694, 0]"]
104["Segment<br>[1656, 1694, 0]"]
105["Segment<br>[1656, 1694, 0]"]
106["Segment<br>[1656, 1694, 0]"]
107["Segment<br>[1656, 1694, 0]"]
108["Segment<br>[1656, 1694, 0]"]
109["Segment<br>[1888, 1918, 0]"]
110["Segment<br>[1888, 1918, 0]"]
111["Segment<br>[1888, 1918, 0]"]
112["Segment<br>[1888, 1918, 0]"]
113["Segment<br>[1888, 1918, 0]"]
114["Segment<br>[1888, 1918, 0]"]
115["Segment<br>[1888, 1918, 0]"]
116["Segment<br>[1888, 1918, 0]"]
117["Segment<br>[1888, 1918, 0]"]
118["Segment<br>[1888, 1918, 0]"]
119["Segment<br>[1888, 1918, 0]"]
120["Segment<br>[1888, 1918, 0]"]
121["Segment<br>[1888, 1918, 0]"]
122["Segment<br>[1888, 1918, 0]"]
123["Segment<br>[1888, 1918, 0]"]
124["Segment<br>[1888, 1918, 0]"]
125["Segment<br>[1888, 1918, 0]"]
126["Segment<br>[1888, 1918, 0]"]
127["Segment<br>[1888, 1918, 0]"]
128["Segment<br>[1888, 1918, 0]"]
129["Segment<br>[1888, 1918, 0]"]
130["Segment<br>[1888, 1918, 0]"]
131["Segment<br>[1888, 1918, 0]"]
132["Segment<br>[1888, 1918, 0]"]
133["Segment<br>[1888, 1918, 0]"]
134["Segment<br>[1888, 1918, 0]"]
135["Segment<br>[1888, 1918, 0]"]
136["Segment<br>[1888, 1918, 0]"]
137["Segment<br>[1888, 1918, 0]"]
138["Segment<br>[1888, 1918, 0]"]
139["Segment<br>[1888, 1918, 0]"]
140["Segment<br>[1888, 1918, 0]"]
141["Segment<br>[1888, 1918, 0]"]
142["Segment<br>[1888, 1918, 0]"]
143["Segment<br>[1888, 1918, 0]"]
144["Segment<br>[1888, 1918, 0]"]
145["Segment<br>[1888, 1918, 0]"]
146["Segment<br>[1888, 1918, 0]"]
147["Segment<br>[1888, 1918, 0]"]
148["Segment<br>[1888, 1918, 0]"]
149["Segment<br>[1888, 1918, 0]"]
150["Segment<br>[1888, 1918, 0]"]
151["Segment<br>[1888, 1918, 0]"]
152["Segment<br>[1888, 1918, 0]"]
153["Segment<br>[1888, 1918, 0]"]
154["Segment<br>[1888, 1918, 0]"]
155["Segment<br>[1888, 1918, 0]"]
156["Segment<br>[1888, 1918, 0]"]
157["Segment<br>[1888, 1918, 0]"]
158["Segment<br>[1888, 1918, 0]"]
159["Segment<br>[1888, 1918, 0]"]
160["Segment<br>[1888, 1918, 0]"]
161["Segment<br>[1888, 1918, 0]"]
162["Segment<br>[1888, 1918, 0]"]
163["Segment<br>[1888, 1918, 0]"]
164["Segment<br>[1888, 1918, 0]"]
165["Segment<br>[1888, 1918, 0]"]
166["Segment<br>[1888, 1918, 0]"]
167["Segment<br>[1888, 1918, 0]"]
168["Segment<br>[1888, 1918, 0]"]
169["Segment<br>[1888, 1918, 0]"]
170["Segment<br>[1888, 1918, 0]"]
171["Segment<br>[1888, 1918, 0]"]
172["Segment<br>[1888, 1918, 0]"]
173["Segment<br>[1888, 1918, 0]"]
174["Segment<br>[1888, 1918, 0]"]
175["Segment<br>[1888, 1918, 0]"]
176["Segment<br>[1888, 1918, 0]"]
177["Segment<br>[1888, 1918, 0]"]
178["Segment<br>[1888, 1918, 0]"]
179["Segment<br>[1888, 1918, 0]"]
180["Segment<br>[1888, 1918, 0]"]
181["Segment<br>[1888, 1918, 0]"]
182["Segment<br>[1888, 1918, 0]"]
183["Segment<br>[1888, 1918, 0]"]
184["Segment<br>[1888, 1918, 0]"]
185["Segment<br>[1888, 1918, 0]"]
186["Segment<br>[1888, 1918, 0]"]
187["Segment<br>[1888, 1918, 0]"]
188["Segment<br>[1888, 1918, 0]"]
189["Segment<br>[1888, 1918, 0]"]
190["Segment<br>[1888, 1918, 0]"]
191["Segment<br>[1888, 1918, 0]"]
192["Segment<br>[1888, 1918, 0]"]
193["Segment<br>[1888, 1918, 0]"]
194["Segment<br>[1888, 1918, 0]"]
195["Segment<br>[1888, 1918, 0]"]
196["Segment<br>[1888, 1918, 0]"]
197["Segment<br>[1888, 1918, 0]"]
198["Segment<br>[1888, 1918, 0]"]
199["Segment<br>[1888, 1918, 0]"]
200["Segment<br>[1888, 1918, 0]"]
201["Segment<br>[1888, 1918, 0]"]
202["Segment<br>[1888, 1918, 0]"]
203["Segment<br>[1888, 1918, 0]"]
204["Segment<br>[1888, 1918, 0]"]
205["Segment<br>[1888, 1918, 0]"]
206["Segment<br>[1888, 1918, 0]"]
207["Segment<br>[1888, 1918, 0]"]
208["Segment<br>[1888, 1918, 0]"]
209["Segment<br>[1888, 1918, 0]"]
210["Segment<br>[2075, 2144, 0]"]
211["Segment<br>[2204, 2211, 0]"]
5["Path<br>[1990, 2027, 0]"]
8["Segment<br>[1662, 1700, 0]"]
9["Segment<br>[1662, 1700, 0]"]
10["Segment<br>[1662, 1700, 0]"]
11["Segment<br>[1662, 1700, 0]"]
12["Segment<br>[1662, 1700, 0]"]
13["Segment<br>[1662, 1700, 0]"]
14["Segment<br>[1662, 1700, 0]"]
15["Segment<br>[1662, 1700, 0]"]
16["Segment<br>[1662, 1700, 0]"]
17["Segment<br>[1662, 1700, 0]"]
18["Segment<br>[1662, 1700, 0]"]
19["Segment<br>[1662, 1700, 0]"]
20["Segment<br>[1662, 1700, 0]"]
21["Segment<br>[1662, 1700, 0]"]
22["Segment<br>[1662, 1700, 0]"]
23["Segment<br>[1662, 1700, 0]"]
24["Segment<br>[1662, 1700, 0]"]
25["Segment<br>[1662, 1700, 0]"]
26["Segment<br>[1662, 1700, 0]"]
27["Segment<br>[1662, 1700, 0]"]
28["Segment<br>[1662, 1700, 0]"]
29["Segment<br>[1662, 1700, 0]"]
30["Segment<br>[1662, 1700, 0]"]
31["Segment<br>[1662, 1700, 0]"]
32["Segment<br>[1662, 1700, 0]"]
33["Segment<br>[1662, 1700, 0]"]
34["Segment<br>[1662, 1700, 0]"]
35["Segment<br>[1662, 1700, 0]"]
36["Segment<br>[1662, 1700, 0]"]
37["Segment<br>[1662, 1700, 0]"]
38["Segment<br>[1662, 1700, 0]"]
39["Segment<br>[1662, 1700, 0]"]
40["Segment<br>[1662, 1700, 0]"]
41["Segment<br>[1662, 1700, 0]"]
42["Segment<br>[1662, 1700, 0]"]
43["Segment<br>[1662, 1700, 0]"]
44["Segment<br>[1662, 1700, 0]"]
45["Segment<br>[1662, 1700, 0]"]
46["Segment<br>[1662, 1700, 0]"]
47["Segment<br>[1662, 1700, 0]"]
48["Segment<br>[1662, 1700, 0]"]
49["Segment<br>[1662, 1700, 0]"]
50["Segment<br>[1662, 1700, 0]"]
51["Segment<br>[1662, 1700, 0]"]
52["Segment<br>[1662, 1700, 0]"]
53["Segment<br>[1662, 1700, 0]"]
54["Segment<br>[1662, 1700, 0]"]
55["Segment<br>[1662, 1700, 0]"]
56["Segment<br>[1662, 1700, 0]"]
57["Segment<br>[1662, 1700, 0]"]
58["Segment<br>[1662, 1700, 0]"]
59["Segment<br>[1662, 1700, 0]"]
60["Segment<br>[1662, 1700, 0]"]
61["Segment<br>[1662, 1700, 0]"]
62["Segment<br>[1662, 1700, 0]"]
63["Segment<br>[1662, 1700, 0]"]
64["Segment<br>[1662, 1700, 0]"]
65["Segment<br>[1662, 1700, 0]"]
66["Segment<br>[1662, 1700, 0]"]
67["Segment<br>[1662, 1700, 0]"]
68["Segment<br>[1662, 1700, 0]"]
69["Segment<br>[1662, 1700, 0]"]
70["Segment<br>[1662, 1700, 0]"]
71["Segment<br>[1662, 1700, 0]"]
72["Segment<br>[1662, 1700, 0]"]
73["Segment<br>[1662, 1700, 0]"]
74["Segment<br>[1662, 1700, 0]"]
75["Segment<br>[1662, 1700, 0]"]
76["Segment<br>[1662, 1700, 0]"]
77["Segment<br>[1662, 1700, 0]"]
78["Segment<br>[1662, 1700, 0]"]
79["Segment<br>[1662, 1700, 0]"]
80["Segment<br>[1662, 1700, 0]"]
81["Segment<br>[1662, 1700, 0]"]
82["Segment<br>[1662, 1700, 0]"]
83["Segment<br>[1662, 1700, 0]"]
84["Segment<br>[1662, 1700, 0]"]
85["Segment<br>[1662, 1700, 0]"]
86["Segment<br>[1662, 1700, 0]"]
87["Segment<br>[1662, 1700, 0]"]
88["Segment<br>[1662, 1700, 0]"]
89["Segment<br>[1662, 1700, 0]"]
90["Segment<br>[1662, 1700, 0]"]
91["Segment<br>[1662, 1700, 0]"]
92["Segment<br>[1662, 1700, 0]"]
93["Segment<br>[1662, 1700, 0]"]
94["Segment<br>[1662, 1700, 0]"]
95["Segment<br>[1662, 1700, 0]"]
96["Segment<br>[1662, 1700, 0]"]
97["Segment<br>[1662, 1700, 0]"]
98["Segment<br>[1662, 1700, 0]"]
99["Segment<br>[1662, 1700, 0]"]
100["Segment<br>[1662, 1700, 0]"]
101["Segment<br>[1662, 1700, 0]"]
102["Segment<br>[1662, 1700, 0]"]
103["Segment<br>[1662, 1700, 0]"]
104["Segment<br>[1662, 1700, 0]"]
105["Segment<br>[1662, 1700, 0]"]
106["Segment<br>[1662, 1700, 0]"]
107["Segment<br>[1662, 1700, 0]"]
108["Segment<br>[1662, 1700, 0]"]
109["Segment<br>[1906, 1936, 0]"]
110["Segment<br>[1906, 1936, 0]"]
111["Segment<br>[1906, 1936, 0]"]
112["Segment<br>[1906, 1936, 0]"]
113["Segment<br>[1906, 1936, 0]"]
114["Segment<br>[1906, 1936, 0]"]
115["Segment<br>[1906, 1936, 0]"]
116["Segment<br>[1906, 1936, 0]"]
117["Segment<br>[1906, 1936, 0]"]
118["Segment<br>[1906, 1936, 0]"]
119["Segment<br>[1906, 1936, 0]"]
120["Segment<br>[1906, 1936, 0]"]
121["Segment<br>[1906, 1936, 0]"]
122["Segment<br>[1906, 1936, 0]"]
123["Segment<br>[1906, 1936, 0]"]
124["Segment<br>[1906, 1936, 0]"]
125["Segment<br>[1906, 1936, 0]"]
126["Segment<br>[1906, 1936, 0]"]
127["Segment<br>[1906, 1936, 0]"]
128["Segment<br>[1906, 1936, 0]"]
129["Segment<br>[1906, 1936, 0]"]
130["Segment<br>[1906, 1936, 0]"]
131["Segment<br>[1906, 1936, 0]"]
132["Segment<br>[1906, 1936, 0]"]
133["Segment<br>[1906, 1936, 0]"]
134["Segment<br>[1906, 1936, 0]"]
135["Segment<br>[1906, 1936, 0]"]
136["Segment<br>[1906, 1936, 0]"]
137["Segment<br>[1906, 1936, 0]"]
138["Segment<br>[1906, 1936, 0]"]
139["Segment<br>[1906, 1936, 0]"]
140["Segment<br>[1906, 1936, 0]"]
141["Segment<br>[1906, 1936, 0]"]
142["Segment<br>[1906, 1936, 0]"]
143["Segment<br>[1906, 1936, 0]"]
144["Segment<br>[1906, 1936, 0]"]
145["Segment<br>[1906, 1936, 0]"]
146["Segment<br>[1906, 1936, 0]"]
147["Segment<br>[1906, 1936, 0]"]
148["Segment<br>[1906, 1936, 0]"]
149["Segment<br>[1906, 1936, 0]"]
150["Segment<br>[1906, 1936, 0]"]
151["Segment<br>[1906, 1936, 0]"]
152["Segment<br>[1906, 1936, 0]"]
153["Segment<br>[1906, 1936, 0]"]
154["Segment<br>[1906, 1936, 0]"]
155["Segment<br>[1906, 1936, 0]"]
156["Segment<br>[1906, 1936, 0]"]
157["Segment<br>[1906, 1936, 0]"]
158["Segment<br>[1906, 1936, 0]"]
159["Segment<br>[1906, 1936, 0]"]
160["Segment<br>[1906, 1936, 0]"]
161["Segment<br>[1906, 1936, 0]"]
162["Segment<br>[1906, 1936, 0]"]
163["Segment<br>[1906, 1936, 0]"]
164["Segment<br>[1906, 1936, 0]"]
165["Segment<br>[1906, 1936, 0]"]
166["Segment<br>[1906, 1936, 0]"]
167["Segment<br>[1906, 1936, 0]"]
168["Segment<br>[1906, 1936, 0]"]
169["Segment<br>[1906, 1936, 0]"]
170["Segment<br>[1906, 1936, 0]"]
171["Segment<br>[1906, 1936, 0]"]
172["Segment<br>[1906, 1936, 0]"]
173["Segment<br>[1906, 1936, 0]"]
174["Segment<br>[1906, 1936, 0]"]
175["Segment<br>[1906, 1936, 0]"]
176["Segment<br>[1906, 1936, 0]"]
177["Segment<br>[1906, 1936, 0]"]
178["Segment<br>[1906, 1936, 0]"]
179["Segment<br>[1906, 1936, 0]"]
180["Segment<br>[1906, 1936, 0]"]
181["Segment<br>[1906, 1936, 0]"]
182["Segment<br>[1906, 1936, 0]"]
183["Segment<br>[1906, 1936, 0]"]
184["Segment<br>[1906, 1936, 0]"]
185["Segment<br>[1906, 1936, 0]"]
186["Segment<br>[1906, 1936, 0]"]
187["Segment<br>[1906, 1936, 0]"]
188["Segment<br>[1906, 1936, 0]"]
189["Segment<br>[1906, 1936, 0]"]
190["Segment<br>[1906, 1936, 0]"]
191["Segment<br>[1906, 1936, 0]"]
192["Segment<br>[1906, 1936, 0]"]
193["Segment<br>[1906, 1936, 0]"]
194["Segment<br>[1906, 1936, 0]"]
195["Segment<br>[1906, 1936, 0]"]
196["Segment<br>[1906, 1936, 0]"]
197["Segment<br>[1906, 1936, 0]"]
198["Segment<br>[1906, 1936, 0]"]
199["Segment<br>[1906, 1936, 0]"]
200["Segment<br>[1906, 1936, 0]"]
201["Segment<br>[1906, 1936, 0]"]
202["Segment<br>[1906, 1936, 0]"]
203["Segment<br>[1906, 1936, 0]"]
204["Segment<br>[1906, 1936, 0]"]
205["Segment<br>[1906, 1936, 0]"]
206["Segment<br>[1906, 1936, 0]"]
207["Segment<br>[1906, 1936, 0]"]
208["Segment<br>[1906, 1936, 0]"]
209["Segment<br>[1906, 1936, 0]"]
210["Segment<br>[2093, 2162, 0]"]
211["Segment<br>[2222, 2229, 0]"]
218[Solid2d]
end
subgraph path6 [Path]
6["Path<br>[2692, 2804, 0]"]
212["Segment<br>[2810, 2837, 0]"]
213["Segment<br>[2843, 2871, 0]"]
214["Segment<br>[2877, 2905, 0]"]
215["Segment<br>[2911, 3005, 0]"]
216["Segment<br>[3011, 3094, 0]"]
217["Segment<br>[3100, 3107, 0]"]
6["Path<br>[2716, 2828, 0]"]
212["Segment<br>[2834, 2861, 0]"]
213["Segment<br>[2867, 2895, 0]"]
214["Segment<br>[2901, 2929, 0]"]
215["Segment<br>[2935, 3029, 0]"]
216["Segment<br>[3035, 3118, 0]"]
217["Segment<br>[3124, 3131, 0]"]
220[Solid2d]
end
1["Plane<br>[1418, 1435, 0]"]
2["Plane<br>[1949, 1966, 0]"]
3["StartSketchOnFace<br>[2655, 2686, 0]"]
221["Sweep Extrusion<br>[1497, 1525, 0]"]
222["Sweep Extrusion<br>[2217, 2245, 0]"]
223["Sweep Extrusion<br>[3113, 3142, 0]"]
1["Plane<br>[1424, 1441, 0]"]
2["Plane<br>[1967, 1984, 0]"]
3["StartSketchOnFace<br>[2679, 2710, 0]"]
221["Sweep Extrusion<br>[1503, 1531, 0]"]
222["Sweep Extrusion<br>[2235, 2263, 0]"]
223["Sweep Extrusion<br>[3137, 3166, 0]"]
224[Wall]
225[Wall]
226[Wall]

View File

@ -886,7 +886,15 @@ description: Result of parsing gear.kcl
"start": 0,
"type": "Identifier"
},
"path": [],
"path": [
{
"commentStart": 0,
"end": 0,
"name": "math",
"start": 0,
"type": "Identifier"
}
],
"start": 0,
"type": "Name"
},
@ -2405,7 +2413,15 @@ description: Result of parsing gear.kcl
"start": 0,
"type": "Identifier"
},
"path": [],
"path": [
{
"commentStart": 0,
"end": 0,
"name": "math",
"start": 0,
"type": "Identifier"
}
],
"start": 0,
"type": "Name"
},
@ -2642,7 +2658,15 @@ description: Result of parsing gear.kcl
"start": 0,
"type": "Identifier"
},
"path": [],
"path": [
{
"commentStart": 0,
"end": 0,
"name": "math",
"start": 0,
"type": "Identifier"
}
],
"start": 0,
"type": "Name"
},
@ -3936,7 +3960,15 @@ description: Result of parsing gear.kcl
"start": 0,
"type": "Identifier"
},
"path": [],
"path": [
{
"commentStart": 0,
"end": 0,
"name": "math",
"start": 0,
"type": "Identifier"
}
],
"start": 0,
"type": "Name"
},

File diff suppressed because it is too large Load Diff

View File

@ -44,23 +44,23 @@ flowchart LR
87[Solid2d]
end
subgraph path14 [Path]
14["Path<br>[865, 1030, 10]"]
47["Segment<br>[865, 1030, 10]"]
14["Path<br>[865, 1036, 10]"]
47["Segment<br>[865, 1036, 10]"]
90[Solid2d]
end
subgraph path15 [Path]
15["Path<br>[1239, 1376, 10]"]
48["Segment<br>[1239, 1376, 10]"]
15["Path<br>[1245, 1388, 10]"]
48["Segment<br>[1245, 1388, 10]"]
101[Solid2d]
end
subgraph path16 [Path]
16["Path<br>[1688, 1852, 10]"]
49["Segment<br>[1688, 1852, 10]"]
16["Path<br>[1706, 1876, 10]"]
49["Segment<br>[1706, 1876, 10]"]
95[Solid2d]
end
subgraph path17 [Path]
17["Path<br>[2077, 2117, 10]"]
50["Segment<br>[2077, 2117, 10]"]
17["Path<br>[2101, 2141, 10]"]
50["Segment<br>[2101, 2141, 10]"]
96[Solid2d]
end
subgraph path18 [Path]
@ -158,7 +158,7 @@ flowchart LR
1["Plane<br>[201, 218, 8]"]
2["Plane<br>[174, 197, 10]"]
3["Plane<br>[464, 487, 10]"]
4["Plane<br>[2048, 2071, 10]"]
4["Plane<br>[2072, 2095, 10]"]
5["Plane<br>[222, 245, 11]"]
6["Plane<br>[242, 265, 12]"]
112["Sweep Extrusion<br>[724, 771, 8]"]
@ -174,13 +174,13 @@ flowchart LR
122["Sweep Extrusion<br>[2252, 2299, 8]"]
123["Sweep Extrusion<br>[277, 315, 10]"]
124["Sweep Extrusion<br>[778, 808, 10]"]
125["Sweep Extrusion<br>[1044, 1076, 10]"]
126["Sweep Extrusion<br>[1599, 1631, 10]"]
127["Sweep Extrusion<br>[1599, 1631, 10]"]
128["Sweep Extrusion<br>[1599, 1631, 10]"]
129["Sweep Extrusion<br>[1599, 1631, 10]"]
130["Sweep Extrusion<br>[1866, 1899, 10]"]
131["Sweep Extrusion<br>[2119, 2150, 10]"]
125["Sweep Extrusion<br>[1050, 1082, 10]"]
126["Sweep Extrusion<br>[1617, 1649, 10]"]
127["Sweep Extrusion<br>[1617, 1649, 10]"]
128["Sweep Extrusion<br>[1617, 1649, 10]"]
129["Sweep Extrusion<br>[1617, 1649, 10]"]
130["Sweep Extrusion<br>[1890, 1923, 10]"]
131["Sweep Extrusion<br>[2143, 2174, 10]"]
132["Sweep Extrusion<br>[709, 757, 11]"]
133["Sweep Extrusion<br>[895, 928, 11]"]
134["Sweep Extrusion<br>[1267, 1297, 11]"]
@ -399,8 +399,8 @@ flowchart LR
347["EdgeCut Chamfer<br>[777, 1054, 8]"]
348["EdgeCut Fillet<br>[1294, 1355, 8]"]
349["EdgeCut Fillet<br>[321, 383, 10]"]
350["EdgeCut Fillet<br>[1082, 1144, 10]"]
351["EdgeCut Fillet<br>[1905, 1967, 10]"]
350["EdgeCut Fillet<br>[1088, 1150, 10]"]
351["EdgeCut Fillet<br>[1929, 1991, 10]"]
352["EdgeCut Fillet<br>[934, 996, 11]"]
353["EdgeCut Fillet<br>[1303, 1365, 11]"]
354["EdgeCut Fillet<br>[1189, 1251, 12]"]

View File

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

View File

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View File

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View File

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

@ -3,6 +3,17 @@ source: kcl-lib/src/simulation_tests.rs
description: Operations executed parametric.kcl
---
[
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "sqrt",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"labeledArgs": {
"planeOrSolid": {
@ -49,5 +60,8 @@ description: Operations executed parametric.kcl
},
"sourceRange": []
}
},
{
"type": "GroupEnd"
}
]

View File

@ -3,6 +3,17 @@ source: kcl-lib/src/simulation_tests.rs
description: Operations executed parametric_with_tan_arc.kcl
---
[
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "sqrt",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"labeledArgs": {
"planeOrSolid": {
@ -49,5 +60,8 @@ description: Operations executed parametric_with_tan_arc.kcl
},
"sourceRange": []
}
},
{
"type": "GroupEnd"
}
]

View File

@ -3,6 +3,17 @@ source: kcl-lib/src/simulation_tests.rs
description: Operations executed sketch_on_face_after_fillets_referencing_face.kcl
---
[
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "sqrt",
"functionSourceRange": [],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"labeledArgs": {
"planeOrSolid": {
@ -193,5 +204,8 @@ description: Operations executed sketch_on_face_after_fillets_referencing_face.k
},
"sourceRange": []
}
},
{
"type": "GroupEnd"
}
]

View File

@ -347,28 +347,28 @@ describe('testing math operators', () => {
expect(mem['myVar']?.value).toBe(12.5)
})
it('with callExpression at start', async () => {
const code = 'myVar = min([4, 100]) + 2'
const code = 'myVar = math::min([4, 100]) + 2'
const mem = await exe(code)
expect(mem['myVar']?.value).toBe(6)
})
it('with callExpression at end', async () => {
const code = 'myVar = 2 + min([4, 100])'
const code = 'myVar = 2 + math::min([4, 100])'
const mem = await exe(code)
expect(mem['myVar']?.value).toBe(6)
})
it('with nested callExpression', async () => {
const code = 'myVar = 2 + min([100, legLen(hypotenuse = 5, leg = 3)])'
const code = 'myVar = 2 + math::min([100, legLen(hypotenuse = 5, leg = 3)])'
const mem = await exe(code)
expect(mem['myVar']?.value).toBe(6)
})
it('with unaryExpression', async () => {
const code = 'myVar = -min([100, 3])'
const code = 'myVar = -math::min([100, 3])'
const mem = await exe(code)
expect(mem['myVar']?.value).toBe(-3)
})
it('with unaryExpression in callExpression', async () => {
const code = 'myVar = min([-legLen(hypotenuse = 5, leg = 4), 5])'
const code2 = 'myVar = min([5 , -legLen(hypotenuse = 5, leg = 4)])'
const code = 'myVar = math::min([-legLen(hypotenuse = 5, leg = 4), 5])'
const code2 = 'myVar = math::min([5 , -legLen(hypotenuse = 5, leg = 4)])'
const mem = await exe(code)
const mem2 = await exe(code2)
expect(mem['myVar']?.value).toBe(-3)
@ -394,7 +394,7 @@ describe('testing math operators', () => {
const code = [
'part001 = startSketchOn(XY)',
' |> startProfile(at = [0, 0])',
'|> line(end = [-2.21, -legLen(hypotenuse = 5, leg = min([3, 999]))])',
'|> line(end = [-2.21, -legLen(hypotenuse = 5, leg = math::min([3, 999]))])',
].join('\n')
const mem = await exe(code)
const sketch = sketchFromKclValue(mem['part001'], 'part001')
@ -409,7 +409,7 @@ describe('testing math operators', () => {
` |> startProfile(at = [0, 0])`,
` |> line(end = [3, 4], tag = $seg01)`,
` |> line(end = [`,
` min([segLen(seg01), myVar]),`,
` math::min([segLen(seg01), myVar]),`,
` -legLen(hypotenuse = segLen(seg01), leg = myVar)`,
`])`,
``,
@ -433,7 +433,7 @@ describe('testing math operators', () => {
expect((removedUnaryExpMemSketch as Sketch).paths?.[1]?.to).toEqual([6, 8])
})
it('with nested callExpression and binaryExpression', async () => {
const code = 'myVar = 2 + min([100, -1 + legLen(hypotenuse = 5, leg = 3)])'
const code = 'myVar = 2 + math::min([100, -1 + legLen(hypotenuse = 5, leg = 3)])'
const mem = await exe(code)
expect(mem['myVar']?.value).toBe(5)
})