# How to insert a graphics between two points?

How can I insert the resistor between points {1,1} and {2,1} without modifying res (zoom is okay if needed)?

res = Graphics[{AbsoluteThickness[2], Line[{{-1, 0}, {0, 0}}],
Line[{{3, 0}, {4, 0}}],
Line[{{0, 0}, {1/4, 1}, {1/2, 0}, {3/4, -1}, {1, 0}, {5/4,
1}, {3/2, 0}, {7/4, -1}, {2, 0},
{9/4, 1}, {5/2, 0}, {11/4, -1}, {3, 0}}]}, ImageSize -> 50];
Graphics[Inset[res, {1, 1}, Automatic, Scaled[1/5]],
PlotRange -> {{0, 3}, {0, 2}}, ImageSize -> 300, Axes -> True,
Ticks -> {Range[0, 3, 1], Range[0, 2, 1]}, AxesOrigin -> {0, 0},
GridLines -> {Range[0, 3, 1], Range[0, 2, 1]}
]


## 1 Answer

First, remove any paddings and margins from res by setting PlotRangePadding -> None, ImagePadding -> 0. Then specify the third argument of Offset as {-1, 0}, because this is where the left point of your resistor lies at.

res = Graphics[{AbsoluteThickness[2], Line[{{-1, 0}, {0, 0}}],
Line[{{3, 0}, {4, 0}}],
Line[{{0, 0}, {1/4, 1}, {1/2, 0}, {3/4, -1}, {1, 0}, {5/4,
1}, {3/2, 0}, {7/4, -1}, {2, 0}, {9/4, 1}, {5/2,
0}, {11/4, -1}, {3, 0}}]}, PlotRangePadding -> None,
ImagePadding -> 0]

Graphics[Inset[res, {1, 1}, {-1, 0}, 1],
PlotRange -> {{0, 3}, {0, 2}}, Axes -> True, GridLines -> Automatic,
ImageSize -> 400]


Additionaly, you can use the fourth argument of Inset if you want to have rotated resistors.

plotResistor[p1_, p2_] :=
Inset[res, p1, {-1, 0}, EuclideanDistance[p1, p2], p2 - p1]

Graphics[{
plotResistor[{1/2, 0}, {1/2, 1}],
plotResistor[{1/2, 1}, {1, 1}],
plotResistor[{1, 1}, {2, 2}]
}, PlotRange -> {{0, 3}, {0, 2}}, Axes -> True,
GridLines -> Automatic, ImageSize -> 400]