Box example

wheatstone.box

A simple electric circuit

Figure: the output produced by Box.

// Under a shell type: box wheatstone.box -l g

// ---

// This example shows how to use Window.Put to place figures.

include "g"

include "electric"

// This is not a real Wheatstone bridge.

// We replace some of the resistors with other components, just to make

// the thing more interesting!

wheatstone = Window["fig"][

d1 = 20.0 // d1 = half diagonal

p1 = (0, -d1), p2 = (d1, 0), p3 = (0, d1), p4 = (-d1, 0)

// Places the four components.

// Each component has two connections. Here we want to rotate and translate

// ("rt") a resistor such that the first of its terminals is near to

// the point p1 and the second one is near to p2.

r12 = .Put[resistor, "rt", .Near[1, p1], .Near[2, p2]]

// We proceed in a similar way for the other components:

r23 = .Put[diode, "rt", .Near[1, p2], .Near[2, p3]]

r34 = .Put[inductance, "rt", .Near[1, p3], .Near[2, p4]]

r41 = .Put[resistor, "rt", .Near[1, p4], .Near[2, p1]]

// Connecting the four resistors

\ .Line[0.2, p1, r12.Get[1]; r12.Get[2], p2; p2, r23.Get[1]; r23.Get[2], p3;

p3, r34.Get[1]; r34.Get[2], p4; p4, r41.Get[1]; r41.Get[2], p1]

// Drawing small circles on the nodes

// Here you see how a single Circle instruction can be used to draw many

// circles. To start a new circle one should use the separator ";" and

// specify only the quantities that changed with respect to the previous

// circle. Here we change only the center, so we need to specify the radius

// only once!

\ .Circle[0.8, p1; p2; p3; p4]

.Save["wheatstone.eps"] // Saving to eps file

]