Add math functions back to the prelude (#6595)

* Add math functions back to the prelude

* Update output

* Update docs
This commit is contained in:
Jonathan Tran
2025-04-30 11:07:05 -04:00
committed by GitHub
parent f1fdf48834
commit ccd5b0272d
111 changed files with 4002 additions and 4335 deletions

View File

@ -144,15 +144,15 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
///
/// // Start the decagon sketch at this point.
/// startOfDecagonSketch = startSketchOn(XY)
/// |> startProfile(at = [(math::cos(0)*radius), (math::sin(0) * radius)])
/// |> startProfile(at = [(cos(0)*radius), (sin(0) * radius)])
///
/// // Use a `reduce` to draw the remaining decagon sides.
/// // For each number in the array 1..10, run the given function,
/// // which takes a partially-sketched decagon and adds one more edge to it.
/// fullDecagon = reduce([1..10], initial = startOfDecagonSketch, f = fn(i, partialDecagon) {
/// // Draw one edge of the decagon.
/// x = math::cos(stepAngle * i) * radius
/// y = math::sin(stepAngle * i) * radius
/// x = cos(stepAngle * i) * radius
/// y = sin(stepAngle * i) * radius
/// return line(partialDecagon, end = [x, y])
/// })
///
@ -165,13 +165,13 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// fn decagon(radius):
/// stepAngle = ((1/10) * TAU): number(rad)
/// plane = startSketchOn(XY)
/// startOfDecagonSketch = startProfile(plane, at = [(math::cos(0)*radius), (math::sin(0) * radius)])
/// startOfDecagonSketch = startProfile(plane, at = [(cos(0)*radius), (sin(0) * radius)])
///
/// // Here's the reduce part.
/// partialDecagon = startOfDecagonSketch
/// for i in [1..10]:
/// x = math::cos(stepAngle * i) * radius
/// y = math::sin(stepAngle * i) * radius
/// x = cos(stepAngle * i) * radius
/// y = sin(stepAngle * i) * radius
/// partialDecagon = line(partialDecagon, end = [x, y])
/// fullDecagon = partialDecagon // it's now full
/// return fullDecagon