**dgrace**for the code to add the Atan2(y,x) function to the math formulas.

Atan2(y,x) Returns the radians of arc tangent between points Y and X in the Cartesian plane. The sign of the elements determines the quadrant.

This can be useful for a lot of things, but one way to demonstrate how you might use it is to "draw an angled line between two points" in your skin.

If you have two points (meters) on your skin, a red one and a blue one in this instance:

You might want to draw a line between them;

To do this with a Roundline meter, you basically need to take these steps:

1) Get the X and Y positions of the two points.

2) Get the width and height of the triangle this creates. This gives you two of the sides of the "triangle", you just need the

third side. That will be the "line".

3) Use a formula to calculate the length (LineLength) of the third side of the triangle.

4) Use a formula to calculate the "arc angle" (RotationAngle) in radians between the two points.

So if we start with this code:

Code: Select all

```
[MeterPointA]
Meter=Image
X=0
Y=136
W=6
H=6
SolidColor=255,0,0,255
[MeterPointB]
Meter=Image
X=283
Y=0
W=6
H=6
SolidColor=191,235,255,255
```

Now we can create our Roundline meter, using the new Atan2 function to get our RotationAngle value.

Code: Select all

```
[MeterLineAtoB]
Meter=Roundline
X=([MeterPointA:X]+([MeterPointA:W]/2))
Y=([MeterPointA:Y]+([MeterPointA:H]/2))
LineColor=255,255,255,255
LineWidth=2
LineLength=(Sqrt((([MeterPointA:X]-[MeterPointB:X])**2)+(([MeterPointA:Y]-[MeterPointB:Y])**2)))
StartAngle=Rad(360)
RotationAngle=(Atan2([MeterPointB:Y]-[MeterPointA:Y], [MeterPointB:X]-[MeterPointA:X]))
AntiAlias=1
DynamicVariables=1
```

We can add some "dynamic" values for the positions of A and B, and see it in action:

Code: Select all

```
[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=20,30,40,255
[MeasureCounterX]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=100
HighBound=300
[MeasureCounterY]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=50
HighBound=150
[MeterPointA]
Meter=Image
X=0
Y=[MeasureCounterY]
W=6
H=6
SolidColor=255,0,0,255
DynamicVariables=1
[MeterPointB]
Meter=Image
X=[MeasureCounterX]
Y=0
W=6
H=6
SolidColor=191,235,255,255
DynamicVariables=1
[MeterLineAtoB]
Meter=Roundline
X=([MeterPointA:X]+([MeterPointA:W]/2))
Y=([MeterPointA:Y]+([MeterPointA:H]/2))
LineColor=255,255,255,255
LineWidth=2
LineLength=(Sqrt((([MeterPointA:X]-[MeterPointB:X])**2)+(([MeterPointA:Y]-[MeterPointB:Y])**2)))
StartAngle=Rad(360)
RotationAngle=(Atan2([MeterPointB:Y]-[MeterPointA:Y], [MeterPointB:X]-[MeterPointA:X]))
AntiAlias=1
DynamicVariables=1
```