* try python unit test Signed-off-by: Jess Frazelle <github@jessfraz.com> * try python unit test Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes; Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes; Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
29 lines
1.0 KiB
Plaintext
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)
|