From 3731713cfaf42ed8a46b106854d3550416c464f9 Mon Sep 17 00:00:00 2001 From: benjamaan476 Date: Wed, 13 Aug 2025 13:07:32 +0100 Subject: [PATCH 01/12] add majorDiameter and minorDiameter to ellipse fns --- rust/kcl-lib/src/std/sketch.rs | 48 +++++++++++++++++++++++++++++++--- rust/kcl-lib/std/sketch.kcl | 31 ++++++++++++++++------ 2 files changed, 67 insertions(+), 12 deletions(-) diff --git a/rust/kcl-lib/src/std/sketch.rs b/rust/kcl-lib/src/std/sketch.rs index ba17e8101f3..f3970b216a5 100644 --- a/rust/kcl-lib/src/std/sketch.rs +++ b/rust/kcl-lib/src/std/sketch.rs @@ -1921,9 +1921,28 @@ async fn inner_subtract_2d( pub async fn elliptic_point(exec_state: &mut ExecState, args: Args) -> Result { let x = args.get_kw_arg_opt("x", &RuntimeType::length(), exec_state)?; let y = args.get_kw_arg_opt("y", &RuntimeType::length(), exec_state)?; - let major_radius = args.get_kw_arg("majorRadius", &RuntimeType::num_any(), exec_state)?; - let minor_radius = args.get_kw_arg("minorRadius", &RuntimeType::num_any(), exec_state)?; + let major_radius = args.get_kw_arg_opt("majorRadius", &RuntimeType::num_any(), exec_state)?; + let major_diameter: Option = args.get_kw_arg_opt("majorDiameter", &RuntimeType::num_any(), exec_state)?; + let minor_radius = args.get_kw_arg_opt("minorRadius", &RuntimeType::num_any(), exec_state)?; + let minor_diameter: Option = args.get_kw_arg_opt("minorDiameter", &RuntimeType::num_any(), exec_state)?; + + let major_radius = match (major_radius, major_diameter) { + (Some(_), Some(_)) | (None, None) => return Err(KclError::new_type(KclErrorDetails::new( + "Provide either `majorDiameter` or `majorRadius`, not both.".to_string(), + vec![args.source_range], + ))), + (Some(major_radius), _) => major_radius, + (_, Some(major_diameter)) => TyF64 { n: 0.5 * major_diameter.n, ty: major_diameter.ty }, + }; + let minor_radius = match (minor_radius, minor_diameter) { + (Some(_), Some(_)) | (None, None) => return Err(KclError::new_type(KclErrorDetails::new( + "Provide either `minorDiameter` or `minorRadius`, not both.".to_string(), + vec![args.source_range], + ))), + (Some(minor_radius), _) => minor_radius, + (_, Some(minor_diameter)) => TyF64 { n: 0.5 * minor_diameter.n, ty: minor_diameter.ty }, + }; let elliptic_point = inner_elliptic_point(x, y, major_radius, minor_radius, &args).await?; args.make_kcl_val_from_point(elliptic_point, exec_state.length_unit().into()) @@ -2004,10 +2023,31 @@ pub async fn elliptic(exec_state: &mut ExecState, args: Args) -> Result = args.get_kw_arg_opt("majorDiameter", &RuntimeType::length(), exec_state)?; let major_axis = args.get_kw_arg_opt("majorAxis", &RuntimeType::point2d(), exec_state)?; - let minor_radius = args.get_kw_arg("minorRadius", &RuntimeType::length(), exec_state)?; + let minor_radius = args.get_kw_arg_opt("minorRadius", &RuntimeType::length(), exec_state)?; + let minor_diameter: Option = args.get_kw_arg_opt("minorDiameter", &RuntimeType::length(), exec_state)?; let tag = args.get_kw_arg_opt("tag", &RuntimeType::tag_decl(), exec_state)?; + let major_radius = match (major_radius, major_diameter) { + (Some(_), Some(_)) => return Err(KclError::new_type(KclErrorDetails::new( + "Provide either `majorDiameter` or `majorRadius`, not both.".to_string(), + vec![args.source_range], + ))), + (None, None) => None, + (Some(major_radius), _) => Some(major_radius), + (_, Some(major_diameter)) => Some(TyF64 { n: 0.5 * major_diameter.n, ty: major_diameter.ty }), + }; + + let minor_radius = match (minor_radius, minor_diameter) { + (Some(_), Some(_)) | (None, None) => return Err(KclError::new_type(KclErrorDetails::new( + "Provide either `minorDiameter` or `minorRadius`, not both.".to_string(), + vec![args.source_range], + ))), + (Some(minor_radius), _) => minor_radius, + (_, Some(minor_diameter)) => TyF64 { n: 0.5 * minor_diameter.n, ty: minor_diameter.ty }, + }; + let new_sketch = inner_elliptic( sketch, center, @@ -2047,7 +2087,7 @@ pub(crate) async fn inner_elliptic( let major_axis = match (major_axis, major_radius) { (Some(_), Some(_)) | (None, None) => { return Err(KclError::new_type(KclErrorDetails::new( - "Provide either `majorAxis` or `majorRadius`.".to_string(), + "Provide either `majorAxis` or `majorRadius`, not both.".to_string(), vec![args.source_range], ))); } diff --git a/rust/kcl-lib/std/sketch.kcl b/rust/kcl-lib/std/sketch.kcl index e23818b4657..f450cdd93ff 100644 --- a/rust/kcl-lib/std/sketch.kcl +++ b/rust/kcl-lib/std/sketch.kcl @@ -355,6 +355,11 @@ export fn circle( /// exampleSketch = startSketchOn(XY) /// |> ellipse(center = [0, 0], majorRadius = 50, minorRadius = 20) /// ``` +/// +/// ``` +/// exampleSketch = startSketchOn(YZ) +/// |> ellipse(center = [10, 10], majorDiameter = 40, minorRadius = 10) +/// ``` @(impl = std_rust) export fn ellipse( /// Sketch to extend, or plane or surface to sketch on. @@ -362,10 +367,14 @@ export fn ellipse( /// The center of the ellipse. @(snippetArray = ["0", "0"]) center: Point2d, - /// The minor radius of the ellipse. - minorRadius: number(Length), - /// The major radius of the ellipse. Equivalent to majorAxis = [majorRadius, 0]. + /// The minor radius of the ellipse. Incompatible with `minorDiameter`. + minorRadius?: number(Length), + /// The minor diameter of the ellipse. Incompatible with `minorRadius`. + minorDiameter?: number(Length), + /// The major radius of the ellipse. Equivalent to majorAxis = [majorRadius, 0]. Incompatible with `majorDiameter`. majorRadius?: number(Length), + /// The major diameter of the ellipse. Equivalent to 2.0 * majorRadius. Incompatible with `majorRadius`. + majorDiameter?: number(Length), /// The major axis of the ellipse. majorAxis?: Point2d, /// Create a new tag which refers to this ellipse. @@ -2230,11 +2239,15 @@ export fn elliptic( /// Where along the ellptic should this segment end? @(includeInSnippet = true) angleEnd: number(Angle), - /// The minor radius, b, of the elliptic equation x^2 / a^2 + y^2 / b^2 = 1. + /// The minor radius, b, of the elliptic equation x^2 / a^2 + y^2 / b^2 = 1. Incompatible with `minorDiameter`. @(includeInSnippet = true) - minorRadius: number(Length), - /// The major radius, a, of the elliptic equation x^2 / a^2 + y^2 / b^2 = 1. Equivalent to majorAxis = [majorRadius, 0]. + minorRadius?: number(Length), + /// Them minor diameter of the elliptic equation. Incompatible with `minorRadius`. + minorDiameter?: number(Length), + /// The major radius, a, of the elliptic equation x^2 / a^2 + y^2 / b^2 = 1. Equivalent to majorAxis = [majorRadius, 0]. Incompatible with `majorDiameter`. majorRadius?: number(Length), + /// The major diameter of the elliptic equation. Incompatible with `majorRadius`. + majorDiameter?: number(Length), /// The major axis of the elliptic. @(includeInSnippet = true) majorAxis?: Point2d, @@ -2252,8 +2265,10 @@ export fn elliptic( ///``` @(impl = std_rust) export fn ellipticPoint( - /// The major radius, a, of the elliptic equation x^2 / a ^ 2 + y^2 / b^2 = 1. - majorRadius: number, + /// The major radius, a, of the elliptic equation x^2 / a ^ 2 + y^2 / b^2 = 1. Incompatible with `majorDiameter`. + majorRadius?: number, + /// Them major diameter of the elliptic equation. Incompatible with `majorRadius`. + majorDiameter?: number, /// The minor radius, b, of the hyperbolic equation x^2 / a ^ 2 + y^2 / b^2 = 1. minorRadius: number, /// The x value. Calculates y and returns (x, y). Incompatible with `y`. From 84f7a48ef25374762e24f6cb720c6ee4ca8fc8a0 Mon Sep 17 00:00:00 2001 From: benjamaan476 Date: Wed, 13 Aug 2025 13:09:08 +0100 Subject: [PATCH 02/12] fmt --- rust/kcl-lib/src/std/sketch.rs | 44 ++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/rust/kcl-lib/src/std/sketch.rs b/rust/kcl-lib/src/std/sketch.rs index f3970b216a5..dbfd3b7cf4c 100644 --- a/rust/kcl-lib/src/std/sketch.rs +++ b/rust/kcl-lib/src/std/sketch.rs @@ -1927,21 +1927,31 @@ pub async fn elliptic_point(exec_state: &mut ExecState, args: Args) -> Result = args.get_kw_arg_opt("minorDiameter", &RuntimeType::num_any(), exec_state)?; let major_radius = match (major_radius, major_diameter) { - (Some(_), Some(_)) | (None, None) => return Err(KclError::new_type(KclErrorDetails::new( + (Some(_), Some(_)) | (None, None) => { + return Err(KclError::new_type(KclErrorDetails::new( "Provide either `majorDiameter` or `majorRadius`, not both.".to_string(), vec![args.source_range], - ))), + ))); + } (Some(major_radius), _) => major_radius, - (_, Some(major_diameter)) => TyF64 { n: 0.5 * major_diameter.n, ty: major_diameter.ty }, + (_, Some(major_diameter)) => TyF64 { + n: 0.5 * major_diameter.n, + ty: major_diameter.ty, + }, }; let minor_radius = match (minor_radius, minor_diameter) { - (Some(_), Some(_)) | (None, None) => return Err(KclError::new_type(KclErrorDetails::new( + (Some(_), Some(_)) | (None, None) => { + return Err(KclError::new_type(KclErrorDetails::new( "Provide either `minorDiameter` or `minorRadius`, not both.".to_string(), vec![args.source_range], - ))), + ))); + } (Some(minor_radius), _) => minor_radius, - (_, Some(minor_diameter)) => TyF64 { n: 0.5 * minor_diameter.n, ty: minor_diameter.ty }, + (_, Some(minor_diameter)) => TyF64 { + n: 0.5 * minor_diameter.n, + ty: minor_diameter.ty, + }, }; let elliptic_point = inner_elliptic_point(x, y, major_radius, minor_radius, &args).await?; @@ -2030,22 +2040,32 @@ pub async fn elliptic(exec_state: &mut ExecState, args: Args) -> Result return Err(KclError::new_type(KclErrorDetails::new( + (Some(_), Some(_)) => { + return Err(KclError::new_type(KclErrorDetails::new( "Provide either `majorDiameter` or `majorRadius`, not both.".to_string(), vec![args.source_range], - ))), + ))); + } (None, None) => None, (Some(major_radius), _) => Some(major_radius), - (_, Some(major_diameter)) => Some(TyF64 { n: 0.5 * major_diameter.n, ty: major_diameter.ty }), + (_, Some(major_diameter)) => Some(TyF64 { + n: 0.5 * major_diameter.n, + ty: major_diameter.ty, + }), }; let minor_radius = match (minor_radius, minor_diameter) { - (Some(_), Some(_)) | (None, None) => return Err(KclError::new_type(KclErrorDetails::new( + (Some(_), Some(_)) | (None, None) => { + return Err(KclError::new_type(KclErrorDetails::new( "Provide either `minorDiameter` or `minorRadius`, not both.".to_string(), vec![args.source_range], - ))), + ))); + } (Some(minor_radius), _) => minor_radius, - (_, Some(minor_diameter)) => TyF64 { n: 0.5 * minor_diameter.n, ty: minor_diameter.ty }, + (_, Some(minor_diameter)) => TyF64 { + n: 0.5 * minor_diameter.n, + ty: minor_diameter.ty, + }, }; let new_sketch = inner_elliptic( From 72c69ceb2d7e963a83872b0982a60351a1218ef9 Mon Sep 17 00:00:00 2001 From: benjamaan476 Date: Wed, 13 Aug 2025 13:26:07 +0100 Subject: [PATCH 03/12] add missing kwarg processing --- rust/kcl-lib/src/std/shapes.rs | 30 ++++++++++++++++++++++++++++++ rust/kcl-lib/std/sketch.kcl | 6 ++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/rust/kcl-lib/src/std/shapes.rs b/rust/kcl-lib/src/std/shapes.rs index 89ee1ac148e..1d7eb99a044 100644 --- a/rust/kcl-lib/src/std/shapes.rs +++ b/rust/kcl-lib/src/std/shapes.rs @@ -539,10 +539,40 @@ pub async fn ellipse(exec_state: &mut ExecState, args: Args) -> Result = args.get_kw_arg_opt("majorDiameter", &RuntimeType::length(), exec_state)?; let major_axis = args.get_kw_arg_opt("majorAxis", &RuntimeType::point2d(), exec_state)?; let minor_radius = args.get_kw_arg("minorRadius", &RuntimeType::length(), exec_state)?; + let minor_diameter: Option = args.get_kw_arg_opt("minorDiameter", &RuntimeType::length(), exec_state)?; let tag = args.get_kw_arg_opt("tag", &RuntimeType::tag_decl(), exec_state)?; + let major_radius = match (major_radius, major_diameter) { + (Some(_), Some(_)) | (None, None) => { + return Err(KclError::new_type(KclErrorDetails::new( + "Provide either `majorDiameter` or `majorRadius`, not both.".to_string(), + vec![args.source_range], + ))); + } + (Some(major_radius), _) => Some(major_radius), + (_, Some(major_diameter)) => Some(TyF64 { + n: 0.5 * major_diameter.n, + ty: major_diameter.ty, + }), + }; + + let minor_radius = match (minor_radius, minor_diameter) { + (Some(_), Some(_)) | (None, None) => { + return Err(KclError::new_type(KclErrorDetails::new( + "Provide either `minorDiameter` or `minorRadius`, not both.".to_string(), + vec![args.source_range], + ))); + } + (Some(minor_radius), _) => minor_radius, + (_, Some(minor_diameter)) => TyF64 { + n: 0.5 * minor_diameter.n, + ty: minor_diameter.ty, + }, + }; + let sketch = inner_ellipse( sketch_or_surface, center, diff --git a/rust/kcl-lib/std/sketch.kcl b/rust/kcl-lib/std/sketch.kcl index f450cdd93ff..c73086fe399 100644 --- a/rust/kcl-lib/std/sketch.kcl +++ b/rust/kcl-lib/std/sketch.kcl @@ -2269,8 +2269,10 @@ export fn ellipticPoint( majorRadius?: number, /// Them major diameter of the elliptic equation. Incompatible with `majorRadius`. majorDiameter?: number, - /// The minor radius, b, of the hyperbolic equation x^2 / a ^ 2 + y^2 / b^2 = 1. - minorRadius: number, + /// The minor radius, b, of the elliptic equation x^2 / a ^ 2 + y^2 / b^2 = 1. Incompatible with `minorDiameter`. + minorRadius?: number, + /// The minor diameter of the elliptic equation. Incompatible with `minorRadius`. + minorDiameter?: number, /// The x value. Calculates y and returns (x, y). Incompatible with `y`. x?: number(Length), /// The y value. Calculates x and returns (x, y). Incompatible with `x`. From 4b8f2ceefca0a800090469351f5becd3c8c031d8 Mon Sep 17 00:00:00 2001 From: benjamaan476 Date: Wed, 13 Aug 2025 13:29:39 +0100 Subject: [PATCH 04/12] missing opt --- rust/kcl-lib/src/std/shapes.rs | 2 +- rust/kcl-lib/std/sketch.kcl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/kcl-lib/src/std/shapes.rs b/rust/kcl-lib/src/std/shapes.rs index 1d7eb99a044..509c2af7f4e 100644 --- a/rust/kcl-lib/src/std/shapes.rs +++ b/rust/kcl-lib/src/std/shapes.rs @@ -541,7 +541,7 @@ pub async fn ellipse(exec_state: &mut ExecState, args: Args) -> Result = args.get_kw_arg_opt("majorDiameter", &RuntimeType::length(), exec_state)?; let major_axis = args.get_kw_arg_opt("majorAxis", &RuntimeType::point2d(), exec_state)?; - let minor_radius = args.get_kw_arg("minorRadius", &RuntimeType::length(), exec_state)?; + let minor_radius = args.get_kw_arg_opt("minorRadius", &RuntimeType::length(), exec_state)?; let minor_diameter: Option = args.get_kw_arg_opt("minorDiameter", &RuntimeType::length(), exec_state)?; let tag = args.get_kw_arg_opt("tag", &RuntimeType::tag_decl(), exec_state)?; diff --git a/rust/kcl-lib/std/sketch.kcl b/rust/kcl-lib/std/sketch.kcl index c73086fe399..2f4d1e36c62 100644 --- a/rust/kcl-lib/std/sketch.kcl +++ b/rust/kcl-lib/std/sketch.kcl @@ -2242,7 +2242,7 @@ export fn elliptic( /// The minor radius, b, of the elliptic equation x^2 / a^2 + y^2 / b^2 = 1. Incompatible with `minorDiameter`. @(includeInSnippet = true) minorRadius?: number(Length), - /// Them minor diameter of the elliptic equation. Incompatible with `minorRadius`. + /// The minor diameter of the elliptic equation. Incompatible with `minorRadius`. minorDiameter?: number(Length), /// The major radius, a, of the elliptic equation x^2 / a^2 + y^2 / b^2 = 1. Equivalent to majorAxis = [majorRadius, 0]. Incompatible with `majorDiameter`. majorRadius?: number(Length), From ca30487fe1207ed52df77366a0bcfbf6970cb9d7 Mon Sep 17 00:00:00 2001 From: benjamaan476 Date: Wed, 13 Aug 2025 14:16:42 +0100 Subject: [PATCH 05/12] redo docs --- ..._test_example_fn_std-sketch-parabolic0.png | Bin 19675 -> 19682 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/rust/kcl-lib/tests/outputs/serial_test_example_fn_std-sketch-parabolic0.png b/rust/kcl-lib/tests/outputs/serial_test_example_fn_std-sketch-parabolic0.png index fa23a443c20c0eaff911597ee15d7f85c0869625..35f573564c4bd0a8cb4312549e4afed01a599bde 100644 GIT binary patch delta 113 zcmcaTlkw3^#tABnD>th8su_N*ztX+;M)%%t&+Fbj|0fn6TY5DVN_^G-vF7}*HP?Us z-v9si{b#FIuiN$Nzue@HEYhqm9QmsRCO_noWc1wJ$n-;ba|73RMzQ}Kp>D!Ij-=}b PG5~?6tDnm{r-UW|%!4?Q delta 104 zcmaDflkxUU#tABni#DqIs!d+N$*%lg+y0}led4_S^MB5qubEr_qrLt|?z&yCR;`8* zzxKCGzQ`%fT6LjW?#N_ACP_x2&57)S@|zcM-enU%YR`1_uka5of0hmgAn Date: Wed, 13 Aug 2025 14:38:17 +0100 Subject: [PATCH 06/12] typo --- rust/kcl-lib/std/sketch.kcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/kcl-lib/std/sketch.kcl b/rust/kcl-lib/std/sketch.kcl index 2f4d1e36c62..c86a5a17fab 100644 --- a/rust/kcl-lib/std/sketch.kcl +++ b/rust/kcl-lib/std/sketch.kcl @@ -2267,7 +2267,7 @@ export fn elliptic( export fn ellipticPoint( /// The major radius, a, of the elliptic equation x^2 / a ^ 2 + y^2 / b^2 = 1. Incompatible with `majorDiameter`. majorRadius?: number, - /// Them major diameter of the elliptic equation. Incompatible with `majorRadius`. + /// The major diameter of the elliptic equation. Incompatible with `majorRadius`. majorDiameter?: number, /// The minor radius, b, of the elliptic equation x^2 / a ^ 2 + y^2 / b^2 = 1. Incompatible with `minorDiameter`. minorRadius?: number, From b9d4894a4bec306efcba090bde27ed6803d94021 Mon Sep 17 00:00:00 2001 From: benjamaan476 Date: Wed, 13 Aug 2025 14:44:52 +0100 Subject: [PATCH 07/12] add missing image --- ...test_example_fn_std-sketch-hyperbolic0.png | Bin 19675 -> 19682 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/rust/kcl-lib/tests/outputs/serial_test_example_fn_std-sketch-hyperbolic0.png b/rust/kcl-lib/tests/outputs/serial_test_example_fn_std-sketch-hyperbolic0.png index fa23a443c20c0eaff911597ee15d7f85c0869625..35f573564c4bd0a8cb4312549e4afed01a599bde 100644 GIT binary patch delta 113 zcmcaTlkw3^#tABnD>th8su_N*ztX+;M)%%t&+Fbj|0fn6TY5DVN_^G-vF7}*HP?Us z-v9si{b#FIuiN$Nzue@HEYhqm9QmsRCO_noWc1wJ$n-;ba|73RMzQ}Kp>D!Ij-=}b PG5~?6tDnm{r-UW|%!4?Q delta 104 zcmaDflkxUU#tABni#DqIs!d+N$*%lg+y0}led4_S^MB5qubEr_qrLt|?z&yCR;`8* zzxKCGzQ`%fT6LjW?#N_ACP_x2&57)S@|zcM-enU%YR`1_uka5of0hmgAn Date: Wed, 13 Aug 2025 15:23:16 +0100 Subject: [PATCH 08/12] add missing test --- rust/kcl-derive-docs/src/example_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/kcl-derive-docs/src/example_tests.rs b/rust/kcl-derive-docs/src/example_tests.rs index 660897af889..a41c3bbf7ab 100644 --- a/rust/kcl-derive-docs/src/example_tests.rs +++ b/rust/kcl-derive-docs/src/example_tests.rs @@ -189,6 +189,7 @@ pub const TEST_NAMES: &[&str] = &[ "std-sketch-hyperbolic-0", "std-sketch-hyperbolicPoint-0", "std-sketch-ellipse-0", + "std-sketch-ellipse-1", "std-sketch-elliptic-0", "std-sketch-ellipticPoint-0", "std-sketch-tangentialArc-0", From c1064ffc702792c7189fab33641e0a405b7f0836 Mon Sep 17 00:00:00 2001 From: benjamaan476 Date: Wed, 13 Aug 2025 15:32:23 +0100 Subject: [PATCH 09/12] redo docs --- docs/kcl-std/functions/std-sketch-ellipse.md | 30 ++++++++++++++++-- docs/kcl-std/functions/std-sketch-elliptic.md | 10 ++++-- .../functions/std-sketch-ellipticPoint.md | 12 ++++--- ...al_test_example_fn_std-sketch-ellipse1.png | Bin 0 -> 19674 bytes 4 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 rust/kcl-lib/tests/outputs/serial_test_example_fn_std-sketch-ellipse1.png diff --git a/docs/kcl-std/functions/std-sketch-ellipse.md b/docs/kcl-std/functions/std-sketch-ellipse.md index 1cddb79b0a3..908602d1248 100644 --- a/docs/kcl-std/functions/std-sketch-ellipse.md +++ b/docs/kcl-std/functions/std-sketch-ellipse.md @@ -11,8 +11,10 @@ Construct a 2-dimensional ellipse, of the specified major/minor radius, centered ellipse( @sketchOrSurface: Sketch | Plane | Face, center: Point2d, - minorRadius: number(Length), + minorRadius?: number(Length), + minorDiameter?: number(Length), majorRadius?: number(Length), + majorDiameter?: number(Length), majorAxis?: Point2d, tag?: tag, ): Sketch @@ -26,8 +28,10 @@ ellipse( |----------|------|-------------|----------| | `sketchOrSurface` | [`Sketch`](/docs/kcl-std/types/std-types-Sketch) or [`Plane`](/docs/kcl-std/types/std-types-Plane) or [`Face`](/docs/kcl-std/types/std-types-Face) | Sketch to extend, or plane or surface to sketch on. | Yes | | `center` | [`Point2d`](/docs/kcl-std/types/std-types-Point2d) | The center of the ellipse. | Yes | -| `minorRadius` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The minor radius of the ellipse. | Yes | -| `majorRadius` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The major radius of the ellipse. Equivalent to majorAxis = [majorRadius, 0]. | No | +| `minorRadius` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The minor radius of the ellipse. Incompatible with `minorDiameter`. | No | +| `minorDiameter` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The minor diameter of the ellipse. Incompatible with `minorRadius`. | No | +| `majorRadius` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The major radius of the ellipse. Equivalent to majorAxis = [majorRadius, 0]. Incompatible with `majorDiameter`. | No | +| `majorDiameter` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The major diameter of the ellipse. Equivalent to 2.0 * majorRadius. Incompatible with `majorRadius`. | No | | `majorAxis` | [`Point2d`](/docs/kcl-std/types/std-types-Point2d) | The major axis of the ellipse. | No | | `tag` | `tag` | Create a new tag which refers to this ellipse. | No | @@ -58,4 +62,24 @@ exampleSketch = startSketchOn(XY) > +```kcl +exampleSketch = startSketchOn(YZ) + |> ellipse(center = [10, 10], majorDiameter = 40, minorRadius = 10) + +``` + + + + + diff --git a/docs/kcl-std/functions/std-sketch-elliptic.md b/docs/kcl-std/functions/std-sketch-elliptic.md index 0ecc5ef079f..51789db57ac 100644 --- a/docs/kcl-std/functions/std-sketch-elliptic.md +++ b/docs/kcl-std/functions/std-sketch-elliptic.md @@ -13,8 +13,10 @@ elliptic( center: Point2d, angleStart: number(Angle), angleEnd: number(Angle), - minorRadius: number(Length), + minorRadius?: number(Length), + minorDiameter?: number(Length), majorRadius?: number(Length), + majorDiameter?: number(Length), majorAxis?: Point2d, tag?: tag, ): Sketch @@ -30,8 +32,10 @@ elliptic( | `center` | [`Point2d`](/docs/kcl-std/types/std-types-Point2d) | The center of the ellipse. | Yes | | `angleStart` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | Where along the ellptic should this segment start? | Yes | | `angleEnd` | [`number(Angle)`](/docs/kcl-std/types/std-types-number) | Where along the ellptic should this segment end? | Yes | -| `minorRadius` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The minor radius, b, of the elliptic equation x^2 / a^2 + y^2 / b^2 = 1. | Yes | -| `majorRadius` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The major radius, a, of the elliptic equation x^2 / a^2 + y^2 / b^2 = 1. Equivalent to majorAxis = [majorRadius, 0]. | No | +| `minorRadius` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The minor radius, b, of the elliptic equation x^2 / a^2 + y^2 / b^2 = 1. Incompatible with `minorDiameter`. | No | +| `minorDiameter` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The minor diameter of the elliptic equation. Incompatible with `minorRadius`. | No | +| `majorRadius` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The major radius, a, of the elliptic equation x^2 / a^2 + y^2 / b^2 = 1. Equivalent to majorAxis = [majorRadius, 0]. Incompatible with `majorDiameter`. | No | +| `majorDiameter` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The major diameter of the elliptic equation. Incompatible with `majorRadius`. | No | | `majorAxis` | [`Point2d`](/docs/kcl-std/types/std-types-Point2d) | The major axis of the elliptic. | No | | `tag` | `tag` | Create a new tag which refers to this arc. | No | diff --git a/docs/kcl-std/functions/std-sketch-ellipticPoint.md b/docs/kcl-std/functions/std-sketch-ellipticPoint.md index 5cc04b2d526..a7002453a63 100644 --- a/docs/kcl-std/functions/std-sketch-ellipticPoint.md +++ b/docs/kcl-std/functions/std-sketch-ellipticPoint.md @@ -9,8 +9,10 @@ Calculate the point (x, y) on an ellipse given x or y and the center and major/m ```kcl ellipticPoint( - majorRadius: number, - minorRadius: number, + majorRadius?: number, + majorDiameter?: number, + minorRadius?: number, + minorDiameter?: number, x?: number(Length), y?: number(Length), ): Point2d @@ -22,8 +24,10 @@ ellipticPoint( | Name | Type | Description | Required | |----------|------|-------------|----------| -| `majorRadius` | [`number`](/docs/kcl-std/types/std-types-number) | The major radius, a, of the elliptic equation x^2 / a ^ 2 + y^2 / b^2 = 1. | Yes | -| `minorRadius` | [`number`](/docs/kcl-std/types/std-types-number) | The minor radius, b, of the hyperbolic equation x^2 / a ^ 2 + y^2 / b^2 = 1. | Yes | +| `majorRadius` | [`number`](/docs/kcl-std/types/std-types-number) | The major radius, a, of the elliptic equation x^2 / a ^ 2 + y^2 / b^2 = 1. Incompatible with `majorDiameter`. | No | +| `majorDiameter` | [`number`](/docs/kcl-std/types/std-types-number) | The major diameter of the elliptic equation. Incompatible with `majorRadius`. | No | +| `minorRadius` | [`number`](/docs/kcl-std/types/std-types-number) | The minor radius, b, of the elliptic equation x^2 / a ^ 2 + y^2 / b^2 = 1. Incompatible with `minorDiameter`. | No | +| `minorDiameter` | [`number`](/docs/kcl-std/types/std-types-number) | The minor diameter of the elliptic equation. Incompatible with `minorRadius`. | No | | `x` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The x value. Calculates y and returns (x, y). Incompatible with `y`. | No | | `y` | [`number(Length)`](/docs/kcl-std/types/std-types-number) | The y value. Calculates x and returns (x, y). Incompatible with `x`. | No | diff --git a/rust/kcl-lib/tests/outputs/serial_test_example_fn_std-sketch-ellipse1.png b/rust/kcl-lib/tests/outputs/serial_test_example_fn_std-sketch-ellipse1.png new file mode 100644 index 0000000000000000000000000000000000000000..45c216eb7ee3e1303ac844741128834cbb3c79dc GIT binary patch literal 19674 zcmeI4F=!KE7>3VQYY7yg(xszh$|QDhkXkAUX;gwrVl7x&aH^$CC0Yt?z(pfwv||$; zR191OQE5TiNkjy@WC~qM1xc`=C}_a^y-4By*W4hTIy?|AN8oaIU%v0X?|uINPwrAO z-V^E%IgZnl7>QnSoFm?D$3}OT_x5RF^Qz-qe4L05r{)fQUGFT0$CloGGk13K?>|19 zy>P>wslMKOO+8#*I$vHsHE?3*_w6?~=bzp?GhHd4{W5%P>qW_3t+j6&L%9#>(eX^B zee*Nh_bB+F)tZS!f)C16Oga^KChzQ~^!$3znY_=;=;f7w%WGY7v;1T>;PP5u^k*XW zx&5C0-e+U&0XJqvlwVBJpH#GRgBp|ED7lD-3P0i@34(Ya9&{dd14yrEM}sC>(#fL)tu#Vn?pqyqaRcFhm{*1 z&8FV`-0=3`AMg+OhuySeVeDwYKQtQf4>5EM+lrwZM?AD#;2%;h@DC{$_y_z0KZYM; z!kDcCsG=PWS}KVKeoPxo{FpSD_%UfP5f8)z#4QabbMOWDGe7vBMHl!nDHq1aq+D3Q zBjv*2I)m#VZgC(WZgC*M9C09wk14)DJP?onUK4FjFK)*dw_n<;tIhEr#iN7w^)c-C zC??F}Za*5J0P!}U0P!}U0IO13f&vPVasdTMxqt$sTtETZgCHJ=2lF~?^9u^FqruRu gMB^aM>&PCiU+cZ~YNr0(`_D2b5lcqhbCY*>0p!FdmH+?% literal 0 HcmV?d00001 From 684acefb5cb88c17fc79802a9c4cf158146d33c8 Mon Sep 17 00:00:00 2001 From: benjamaan476 Date: Mon, 1 Sep 2025 15:19:02 +0100 Subject: [PATCH 10/12] correct mistake in markdown --- docs/kcl-std/functions/std-sketch-ellipse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/kcl-std/functions/std-sketch-ellipse.md b/docs/kcl-std/functions/std-sketch-ellipse.md index 3d8684a6e5a..29dc44d1377 100644 --- a/docs/kcl-std/functions/std-sketch-ellipse.md +++ b/docs/kcl-std/functions/std-sketch-ellipse.md @@ -75,7 +75,7 @@ exampleSketch = startSketchOn(YZ) Date: Mon, 1 Sep 2025 15:44:42 +0100 Subject: [PATCH 11/12] allow experimental for ellipse test --- rust/kcl-lib/std/sketch.kcl | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/kcl-lib/std/sketch.kcl b/rust/kcl-lib/std/sketch.kcl index 737563eb357..603d2c34d57 100644 --- a/rust/kcl-lib/std/sketch.kcl +++ b/rust/kcl-lib/std/sketch.kcl @@ -359,6 +359,7 @@ export fn circle( /// ``` /// /// ``` +/// @settings(experimentalFeatures = allow) /// exampleSketch = startSketchOn(YZ) /// |> ellipse(center = [10, 10], majorDiameter = 40, minorRadius = 10) /// ``` From 72c1f8f70b16dfe618593911278893daf13cb30e Mon Sep 17 00:00:00 2001 From: benjamaan476 Date: Thu, 4 Sep 2025 12:37:45 +0100 Subject: [PATCH 12/12] update md fo ellipse fn --- docs/kcl-std/functions/std-sketch-ellipse.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/kcl-std/functions/std-sketch-ellipse.md b/docs/kcl-std/functions/std-sketch-ellipse.md index d8ea31cf037..cbe1144bf9b 100644 --- a/docs/kcl-std/functions/std-sketch-ellipse.md +++ b/docs/kcl-std/functions/std-sketch-ellipse.md @@ -67,6 +67,8 @@ exampleSketch = startSketchOn(XY) ```kcl +@settings(experimentalFeatures = allow) + exampleSketch = startSketchOn(YZ) |> ellipse(center = [10, 10], majorDiameter = 40, minorRadius = 10)