Files
modeling-app/rust/kcl-lib/tests/bad_units_in_annotation/input.kcl
Nick Cameron bae875382c Replace plane strings with literals (#6592)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-04-30 05:13:11 +00:00

29 lines
1.0 KiB
Plaintext

@settings(defaultLengthUnit = nm)
// Generated by Text-to-CAD: draw a water molecule
// Constants for the water molecule
oxygenRadius = 0.066 // Approximate radius of an oxygen atom
hydrogenRadius = 0.053 // Approximate radius of a hydrogen atom
oxygenHydrogenDistance = 0.096 // Approximate distance between oxygen and hydrogen atoms
bondAngle = 104.5 // Bond angle in degrees
// Function to create a sphere representing an atom
fn createAtom(center, radius) {
return startSketchOn(XY)
|> circle(center = center, radius = radius)
|> extrude(length = radius * 2)
}
// Create the oxygen atom at the origin
oxygenAtom = createAtom([0, 0], oxygenRadius)
// Calculate the positions of the hydrogen atoms
hydrogenOffsetX = oxygenHydrogenDistance * cos(toRadians(bondAngle / 2))
hydrogenOffsetY = oxygenHydrogenDistance * sin(toRadians(bondAngle / 2))
// Create the hydrogen atoms
hydrogenAtom1 = createAtom([hydrogenOffsetX, hydrogenOffsetY], hydrogenRadius)
hydrogenAtom2 = createAtom([-hydrogenOffsetX, hydrogenOffsetY], hydrogenRadius)