49
docs/kcl/atan2.md
Normal file
49
docs/kcl/atan2.md
Normal file
File diff suppressed because one or more lines are too long
@ -30,6 +30,7 @@ layout: manual
|
|||||||
* [`assertLessThan`](kcl/assertLessThan)
|
* [`assertLessThan`](kcl/assertLessThan)
|
||||||
* [`assertLessThanOrEq`](kcl/assertLessThanOrEq)
|
* [`assertLessThanOrEq`](kcl/assertLessThanOrEq)
|
||||||
* [`atan`](kcl/atan)
|
* [`atan`](kcl/atan)
|
||||||
|
* [`atan2`](kcl/atan2)
|
||||||
* [`bezierCurve`](kcl/bezierCurve)
|
* [`bezierCurve`](kcl/bezierCurve)
|
||||||
* [`ceil`](kcl/ceil)
|
* [`ceil`](kcl/ceil)
|
||||||
* [`chamfer`](kcl/chamfer)
|
* [`chamfer`](kcl/chamfer)
|
||||||
|
|||||||
@ -43523,6 +43523,58 @@
|
|||||||
"sketch001 = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> angledLine({\n angle = toDegrees(atan(1.25)),\n length = 20\n }, %)\n |> yLineTo(0, %)\n |> close(%)\n\nextrude001 = extrude(5, sketch001)"
|
"sketch001 = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> angledLine({\n angle = toDegrees(atan(1.25)),\n length = 20\n }, %)\n |> yLineTo(0, %)\n |> close(%)\n\nextrude001 = extrude(5, sketch001)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "atan2",
|
||||||
|
"summary": "Compute the four quadrant arctangent of Y and X (in radians).",
|
||||||
|
"description": "",
|
||||||
|
"tags": [
|
||||||
|
"math"
|
||||||
|
],
|
||||||
|
"keywordArguments": false,
|
||||||
|
"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,
|
||||||
|
"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,
|
||||||
|
"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,
|
||||||
|
"labelRequired": true
|
||||||
|
},
|
||||||
|
"unpublished": false,
|
||||||
|
"deprecated": false,
|
||||||
|
"examples": [
|
||||||
|
"sketch001 = startSketchOn('XZ')\n |> startProfileAt([0, 0], %)\n |> angledLine({\n angle = toDegrees(atan2(1.25, 2)),\n length = 20\n }, %)\n |> yLineTo(0, %)\n |> close(%)\n\nextrude001 = extrude(5, sketch001)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "bezierCurve",
|
"name": "bezierCurve",
|
||||||
"summary": "Draw a smooth, continuous, curved line segment from the current origin to",
|
"summary": "Draw a smooth, continuous, curved line segment from the current origin to",
|
||||||
|
|||||||
@ -597,6 +597,8 @@ fn clean_function_name(name: &str) -> String {
|
|||||||
fn_name = fn_name.replace("seg_", "segment_");
|
fn_name = fn_name.replace("seg_", "segment_");
|
||||||
} else if fn_name.starts_with("log_") {
|
} else if fn_name.starts_with("log_") {
|
||||||
fn_name = fn_name.replace("log_", "log");
|
fn_name = fn_name.replace("log_", "log");
|
||||||
|
} else if fn_name.ends_with("tan_2") {
|
||||||
|
fn_name = fn_name.replace("tan_2", "tan2");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_name
|
fn_name
|
||||||
|
|||||||
@ -9,6 +9,8 @@ use crate::{
|
|||||||
std::Args,
|
std::Args,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::args::FromArgs;
|
||||||
|
|
||||||
/// Compute the remainder after dividing `num` by `div`.
|
/// Compute the remainder after dividing `num` by `div`.
|
||||||
/// If `num` is negative, the result will be too.
|
/// If `num` is negative, the result will be too.
|
||||||
pub async fn rem(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
pub async fn rem(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||||
@ -512,6 +514,36 @@ fn inner_atan(num: f64) -> Result<f64, KclError> {
|
|||||||
Ok(num.atan())
|
Ok(num.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, x) = FromArgs::from_args(&args, 0)?;
|
||||||
|
let result = inner_atan2(y, x)?;
|
||||||
|
|
||||||
|
Ok(args.make_user_val_from_f64(result))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Compute the four quadrant arctangent of Y and X (in radians).
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// sketch001 = startSketchOn('XZ')
|
||||||
|
/// |> startProfileAt([0, 0], %)
|
||||||
|
/// |> angledLine({
|
||||||
|
/// angle = toDegrees(atan2(1.25, 2)),
|
||||||
|
/// length = 20,
|
||||||
|
/// }, %)
|
||||||
|
/// |> yLineTo(0, %)
|
||||||
|
/// |> close(%)
|
||||||
|
///
|
||||||
|
/// extrude001 = extrude(5, sketch001)
|
||||||
|
/// ```
|
||||||
|
#[stdlib {
|
||||||
|
name = "atan2",
|
||||||
|
tags = ["math"],
|
||||||
|
}]
|
||||||
|
fn inner_atan2(y: f64, x: f64) -> Result<f64, KclError> {
|
||||||
|
Ok(y.atan2(x))
|
||||||
|
}
|
||||||
|
|
||||||
/// Compute the logarithm of the number with respect to an arbitrary base.
|
/// Compute the logarithm of the number with respect to an arbitrary base.
|
||||||
///
|
///
|
||||||
/// The result might not be correctly rounded owing to implementation
|
/// The result might not be correctly rounded owing to implementation
|
||||||
|
|||||||
@ -125,6 +125,7 @@ lazy_static! {
|
|||||||
Box::new(crate::std::math::Acos),
|
Box::new(crate::std::math::Acos),
|
||||||
Box::new(crate::std::math::Asin),
|
Box::new(crate::std::math::Asin),
|
||||||
Box::new(crate::std::math::Atan),
|
Box::new(crate::std::math::Atan),
|
||||||
|
Box::new(crate::std::math::Atan2),
|
||||||
Box::new(crate::std::math::Pi),
|
Box::new(crate::std::math::Pi),
|
||||||
Box::new(crate::std::math::E),
|
Box::new(crate::std::math::E),
|
||||||
Box::new(crate::std::math::Tau),
|
Box::new(crate::std::math::Tau),
|
||||||
|
|||||||
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_atan20.png
Normal file
BIN
src/wasm-lib/kcl/tests/outputs/serial_test_example_atan20.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
Reference in New Issue
Block a user