It is currently October 24th, 2018, 1:57 am

Atan2 math function

Changes made during the Rainmeter 3.2 beta cycle.
mistic100
Posts: 13
Joined: October 12th, 2014, 5:27 pm

Re: Atan2 math function

mistic100 » October 3rd, 2016, 7:20 pm

I think you don't really understand what I ask : I (now) know how to draw every line I want, even vertical ones.

I just suggest you update the FIRST example of this thread for future people who would want to do the same thing, and will eventually don't understand why it does not work when X1=X2 because the actual solution is given further in the thread. I know it's only 3 post further but let's be practical and give a actually working guide at the begining.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 2956
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Atan2 math function

eclectic-tech » October 3rd, 2016, 7:23 pm

We'll have to see if JSMorley will make that change... :x

Sorry for misunderstanding your request, I agree it would be helpful for future readers of this thread... :thumbup:
User avatar
balala
Rainmeter Sage
Posts: 6878
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Atan2 math function

balala » October 3rd, 2016, 7:25 pm

If I'm not wrong eclectic-tech, mistic100 is not talking about jsmorley's initial code, but your initial code, with the supposed issue. Am I right mistic100?
If I am, here it is:

Code: Select all

; This skin draws a center red point and draws lines to random secondary points every 3 seconds
; Corrected to use different formula for LineLength and eliminate drawing error
[Rainmeter]
Update=3000
BackgroundMode=2
SkinWidth=312
SkinHeight=180
SolidColor=20,30,40,255

[MeasureCounterX]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=156
HighBound=156

[MeasureCounterY]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=90
HighBound=90

[MeasureCounterX1]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=[MeasureCounterX]
HighBound=[MeasureCounterX]
DynamicVariables=1

[MeasureCounterY1]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=20
HighBound=170

[MeterPointA]
Meter=Image
X=[MeasureCounterX]
Y=[MeasureCounterY]
W=6
H=6
SolidColor=255,0,0,255
DynamicVariables=1

[MeterPointB]
Meter=Image
X=[MeasureCounterX1]
Y=[MeasureCounterY1]
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=(([MeterPointB:X]-[MeterPointA:X])/Cos(Atan2([MeterPointB:Y]-[MeterPointA:Y], [MeterPointB:X]-[MeterPointA:X])))
StartAngle=Rad(360)
RotationAngle=(Atan2([MeterPointB:Y]-[MeterPointA:Y], [MeterPointB:X]-[MeterPointA:X]))
AntiAlias=1
DynamicVariables=1

[MeterLabel]
Meter=String
MeasureName=MeasureCounterX1
MeasureName2=MeasureCounterY1
FontColor=255,255,255
Text=PointB: ( %1, %2 )
mistic100
Posts: 13
Joined: October 12th, 2014, 5:27 pm

Re: Atan2 math function

mistic100 » October 3rd, 2016, 7:35 pm

Sorry you are wrong, I am actually talking about @jsmorley code, which is, I repeat, the first thing people see, when reading this thread.

As you said earlier, @eclectic-tech already includes the fix.
User avatar
jsmorley
Developer
Posts: 18161
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Atan2 math function

jsmorley » October 3rd, 2016, 9:35 pm

eclectic-tech wrote:We'll have to see if JSMorley will make that change... :x

Sorry for misunderstanding your request, I agree it would be helpful for future readers of this thread... :thumbup:
I think I properly fixed the code blocks in the first post of the thread... ;-)
mistic100
Posts: 13
Joined: October 12th, 2014, 5:27 pm

Re: Atan2 math function

mistic100 » October 3rd, 2016, 9:38 pm

Thanks :thumbup: