It is currently July 27th, 2021, 4:28 pm

Transformation matrix and circle issue

Help with creating, editing & fixing problems with skins
User avatar
FreeRaider
Posts: 816
Joined: November 20th, 2012, 11:58 pm

Re: Transformation matrix and circle issue

Post by FreeRaider »

Yincognito wrote: July 21st, 2021, 8:35 pm Removing or commenting out AntiAlias=1 from the meter should fix it, because it's about the rounding errors when it comes to pixels ... but then the circle's contour / edges will not be that smooth, so there is a drawback to it. Why not using the Ellipse shape to draw a full (and either filled or not) circle though?

Code: Select all

[MeterBG]
Meter=Shape
X=(#Radius#*0.0)
Y=(#Radius#*0.0)
Shape=Ellipse #Radius#,#Radius#,#Radius# | Fill Color 1,6,135,255 | StrokeWidth 0
AntiAlias=1
Also, just curious, is there a reason why you use TransformationMatrix for the dials and texts? Do you envision some other transformation, i.e. scaling or skewing for the future maybe? The dials can be drawn very easy just by modifiying the StartAngle option accordingly for each one of them, and Strings can also be rotated directly.
This worked. I don't use shape meter for making circle. I'm old school about it.
User avatar
Yincognito
Rainmeter Sage
Posts: 3650
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Transformation matrix and circle issue

Post by Yincognito »

FreeRaider wrote: July 21st, 2021, 9:27 pm This worked. I don't use shape meter for making circle. I'm old school about it.
Ah, ok, no problem about it - you do as you wish. I just emphasized that the Shape meters are built precisely for ... well, drawing all kinds of shapes. I was too old school back in the day and used to draw a circle point by point using Sin() and Cos(), but that was just because that very old and rudimentar computer I had then didn't have a Circle function at all. :confused:

P.S. You can post this as a bug in the Bugs And Feature Suggestion section of the forum, by the way, since it's you who discovered it. Maybe the devs will fix it if they decide it's indeed a bug.
User avatar
balala
Rainmeter Sage
Posts: 12972
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Transformation matrix and circle issue

Post by balala »

Yincognito wrote: July 21st, 2021, 9:15 pm Yes, that's true, but wouldn't this be eased by setting the StringAlign to CenterCenter? Didn't try it, but it should work in theory, shouldn't it? :???:
If the above is true, it would only leave the angle to be taken care of in that Angle option, and that is just as easy as for the TransformationMatrix, if I'm not mistaken.
Setting the StringAlign to CenterCenter doesn't help. There are more problems with the Angle option, I personally never used it. For instance here is an extremely simple String meter (I added this to FreeRaider's code), which when clicked rotates the letter by 90 degrees. This rotation can be done either by the Angle option, or by TransformationMatrx. The code is this:

Code: Select all

[MeterP]
Meter=STRING
X=#Radius#
Y=#Radius#
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=28
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=CenterCenter
AntiAlias=1
Text=P
DynamicVariables=1
LeftMouseUpAction=[!SetVariable Rotate "(1-#Rotate#)"][!UpdateMeter "MeterP"][!Redraw]
;Angle=(#Rotate#*PI/2)
TransformationMatrix=(Cos(#Rotate#*PI/2));(-Sin(#Rotate#*PI/2));(Sin(#Rotate#*PI/2));(Cos(#Rotate#*PI/2));(#Radius#-(#Radius#*Cos(#Rotate#*PI/2))-(#Radius#*Sin(#Rotate#*PI/2)));(#Radius#+(#Radius#*Sin(#Rotate#*PI/2))-(#Radius#*Cos(#Rotate#*PI/2)))
One of the Angle and TransformationMatrix options has to be commented out (in the above example angle is commented out, while TransformationMatrix is applied), in order to get the other applying. With TransformationMatrix this is what I get:
TransformationMatrix.gif
But with Angle the rotation goes on a little bit different:
Angle.gif
As you can see the Angle rotates the letter around another point as the TransfpormationMatrix does. In case of TransformationMatrix setting up the center of rotation is quite easy, while on Angle I don't know how can it be done (yes, I admit since as said I don't work with Angle, I'm not sure about this question, however the TransformationMatrix solves this problem quite easy). Another difference is the rotation direction: see in the above code that both options uses an angle of (PI/2) = 90 degrees, however the two options rotate the letter in different directions.
I don't sustain that any of these options would be better or worst, however I sustain that TransformationMatrix is much more versatile and if one clarifies the math behind, it's much easier. My opinion...
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 3650
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Transformation matrix and circle issue

Post by Yincognito »

Thanks for the example, balala, now I understand what you mean. I'm on mobile now so I can't test to see where the problem is, but I'll do it ASAP when I get back to my laptop. Probably some combination between the actual Y of the meter and possibly padding. A solution for this surely exists, it remains to be seen if it's simple or a bit more complicated. In any case, the TM variant is already somewhat similarly complex, so it can't be worse than that (I'm talking from a regular user POV, those using the such methods will be fine with it, of course).
User avatar
FreeRaider
Posts: 816
Joined: November 20th, 2012, 11:58 pm

Re: Transformation matrix and circle issue

Post by FreeRaider »

Balala, your code works very well. Only a thing. if I want to change the rotation of the 6 (it currently looks like a 9), how should I do?
User avatar
balala
Rainmeter Sage
Posts: 12972
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Transformation matrix and circle issue

Post by balala »

FreeRaider wrote: July 22nd, 2021, 10:51 am if I want to change the rotation of the 6 (it currently looks like a 9), how should I do?
Definitely can be done, but there is a small problem. The [MeterSquare30] meter (showing the number 6) is placed onto another point where you see it after applying the TransformationMatrix, so you have to rotate it again. Unfortunately right now have no time to work with it, but later today I'm gonna modify the code in order to get it as desired (if in meantime someone else doesn't do it). Stay tuned...
User avatar
FreeRaider
Posts: 816
Joined: November 20th, 2012, 11:58 pm

Re: Transformation matrix and circle issue

Post by FreeRaider »

balala wrote: July 22nd, 2021, 11:26 am Definitely can be done, but there is a small problem. The [MeterSquare30] meter (showing the number 6) is placed onto another point where you see it after applying the TransformationMatrix, so you have to rotate it again. Unfortunately right now have no time to work with it, but later today I'm gonna modify the code in order to get it as desired (if in meantime someone else doesn't do it). Stay tuned...
Don't worry...it's just a curiosity
User avatar
Yincognito
Rainmeter Sage
Posts: 3650
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Transformation matrix and circle issue

Post by Yincognito »

Just out of curiosity ... changing the rotation angle will break consistency with the style of the other dial+square pairs, so it's probably not worth doing (the rotation is a nice feature to have, but from a practical POV nobody is going to break his neck to actually try to read the numbers, unless the whole clock is spinning and save them of the effort). That being said, there are other possible alternatives to clear the confusion due to string rotation:
- use roman numerals for each string
- use different font colors for each string
- use different solid colors for each string
- use different font size for each string
- place strings similarly, but don't rotate them
- use different fonts for each string
- use a vertical gradient for each string's "box"
- use an InlineSetting underline effect to make it clear where is the "bottom" of the string
Or, you could flip strings, but this involves multiplicating 2 matrices and again it's not really worth the effort.

The last two variants illustrated here, since they only required simple changes to [StringStyle]:

Code: Select all

[Variables]
Radius=300
Rotate=0

[Rainmeter]
Update=-1
AccurateText=1
DynamicWindowSize=1

---Styles---

[RoundlineStyle]
RotationAngle=0
X=0
Y=0
H=(#Radius#*2.0)
W=(#Radius#*2.0)
LineLength=#Radius#
LineStart=(#Radius#*0.50)
LineWidth=(#Radius#*0.01)
StartAngle=((Rad(270)))
LineColor=afafaf
AntiAlias=1
Solid=0

[StringStyle]
X=#Radius#
Y=(#Radius#/3)
SolidColor=255,0,0,255
SolidColor2=0,255,0,255
GradientAngle=90
InlineSetting=Underline
FontFace=Courier New
FontSize=12
AntiAlias=1
StringAlign=CenterCenter

---Meters---

; [MeterBG]
; Meter=Shape
; X=(#Radius#*0.0)
; Y=(#Radius#*0.0)
; Shape=Ellipse #Radius#,#Radius#,#Radius# | Fill Color 1,6,135,255 | StrokeWidth 0
; AntiAlias=1

[MeterBG]
Meter=RoundLine
X=(#Radius#*0.0)
Y=(#Radius#*0.0)
H=(#Radius#*2.0)
W=(#Radius#*2.0)
LineLength=(#Radius#)
StartAngle=((Rad(270)))
LineColor=1,6,135,255
Solid=1
;AntiAlias=1

[MeterDial_12]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(12*Rad(-360)/12));(-Sin(12*Rad(-360)/12));(Sin(12*Rad(-360)/12));(Cos(12*Rad(-360)/12));(#Radius#-(#Radius#*Cos(12*Rad(-360)/12))-(#Radius#*Sin(12*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(12*Rad(-360)/12))-(#Radius#*Cos(12*Rad(-360)/12)))

[MeterSquare12]
Meter=string
MeterStyle=StringStyle
TransformationMatrix=(Cos(12*Rad(-360)/12));(-Sin(12*Rad(-360)/12));(Sin(12*Rad(-360)/12));(Cos(12*Rad(-360)/12));(#Radius#-(#Radius#*Cos(12*Rad(-360)/12))-(#Radius#*Sin(12*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(12*Rad(-360)/12))-(#Radius#*Cos(12*Rad(-360)/12)))
Text=12

[MeterDial_5]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(1*Rad(-360)/12));(-Sin(1*Rad(-360)/12));(Sin(1*Rad(-360)/12));(Cos(1*Rad(-360)/12));(#Radius#-(#Radius#*Cos(1*Rad(-360)/12))-(#Radius#*Sin(1*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(1*Rad(-360)/12))-(#Radius#*Cos(1*Rad(-360)/12)))

[MeterSquare5]
Meter=string
MeterStyle=StringStyle
Text=1
TransformationMatrix=(Cos(1*Rad(-360)/12));(-Sin(1*Rad(-360)/12));(Sin(1*Rad(-360)/12));(Cos(1*Rad(-360)/12));(#Radius#-(#Radius#*Cos(1*Rad(-360)/12))-(#Radius#*Sin(1*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(1*Rad(-360)/12))-(#Radius#*Cos(1*Rad(-360)/12)))

[MeterDial_10]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(2*Rad(-360)/12));(-Sin(2*Rad(-360)/12));(Sin(2*Rad(-360)/12));(Cos(2*Rad(-360)/12));(#Radius#-(#Radius#*Cos(2*Rad(-360)/12))-(#Radius#*Sin(2*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(2*Rad(-360)/12))-(#Radius#*Cos(2*Rad(-360)/12)))

[MeterSquare10]
Meter=string
MeterStyle=StringStyle
Text=2
TransformationMatrix=(Cos(2*Rad(-360)/12));(-Sin(2*Rad(-360)/12));(Sin(2*Rad(-360)/12));(Cos(2*Rad(-360)/12));(#Radius#-(#Radius#*Cos(2*Rad(-360)/12))-(#Radius#*Sin(2*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(2*Rad(-360)/12))-(#Radius#*Cos(2*Rad(-360)/12)))

[MeterDial_15]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(3*Rad(-360)/12));(-Sin(3*Rad(-360)/12));(Sin(3*Rad(-360)/12));(Cos(3*Rad(-360)/12));(#Radius#-(#Radius#*Cos(3*Rad(-360)/12))-(#Radius#*Sin(3*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(3*Rad(-360)/12))-(#Radius#*Cos(3*Rad(-360)/12)))

[MeterSquare15]
Meter=string
MeterStyle=StringStyle
Text=3
TransformationMatrix=(Cos(3*Rad(-360)/12));(-Sin(3*Rad(-360)/12));(Sin(3*Rad(-360)/12));(Cos(3*Rad(-360)/12));(#Radius#-(#Radius#*Cos(3*Rad(-360)/12))-(#Radius#*Sin(3*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(3*Rad(-360)/12))-(#Radius#*Cos(3*Rad(-360)/12)))

[MeterDial_20]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(4*Rad(-360)/12));(-Sin(4*Rad(-360)/12));(Sin(4*Rad(-360)/12));(Cos(4*Rad(-360)/12));(#Radius#-(#Radius#*Cos(4*Rad(-360)/12))-(#Radius#*Sin(4*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(4*Rad(-360)/12))-(#Radius#*Cos(4*Rad(-360)/12)))

[MeterSquare20]
Meter=string
MeterStyle=StringStyle
Text=4
TransformationMatrix=(Cos(4*Rad(-360)/12));(-Sin(4*Rad(-360)/12));(Sin(4*Rad(-360)/12));(Cos(4*Rad(-360)/12));(#Radius#-(#Radius#*Cos(4*Rad(-360)/12))-(#Radius#*Sin(4*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(4*Rad(-360)/12))-(#Radius#*Cos(4*Rad(-360)/12)))

[MeterDial_25]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(5*Rad(-360)/12));(-Sin(5*Rad(-360)/12));(Sin(5*Rad(-360)/12));(Cos(5*Rad(-360)/12));(#Radius#-(#Radius#*Cos(5*Rad(-360)/12))-(#Radius#*Sin(5*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(5*Rad(-360)/12))-(#Radius#*Cos(5*Rad(-360)/12)))

[MeterSquare25]
Meter=string
MeterStyle=StringStyle
Text=5
TransformationMatrix=(Cos(5*Rad(-360)/12));(-Sin(5*Rad(-360)/12));(Sin(5*Rad(-360)/12));(Cos(5*Rad(-360)/12));(#Radius#-(#Radius#*Cos(5*Rad(-360)/12))-(#Radius#*Sin(5*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(5*Rad(-360)/12))-(#Radius#*Cos(5*Rad(-360)/12)))

[MeterDial_30]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(6*Rad(-360)/12));(-Sin(6*Rad(-360)/12));(Sin(6*Rad(-360)/12));(Cos(6*Rad(-360)/12));(#Radius#-(#Radius#*Cos(6*Rad(-360)/12))-(#Radius#*Sin(6*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(6*Rad(-360)/12))-(#Radius#*Cos(6*Rad(-360)/12)))

[MeterSquare30]
Meter=string
MeterStyle=StringStyle
Text=6
TransformationMatrix=(Cos(6*Rad(-360)/12));(-Sin(6*Rad(-360)/12));(Sin(6*Rad(-360)/12));(Cos(6*Rad(-360)/12));(#Radius#-(#Radius#*Cos(6*Rad(-360)/12))-(#Radius#*Sin(6*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(6*Rad(-360)/12))-(#Radius#*Cos(6*Rad(-360)/12)))

[MeterDial_35]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(7*Rad(-360)/12));(-Sin(7*Rad(-360)/12));(Sin(7*Rad(-360)/12));(Cos(7*Rad(-360)/12));(#Radius#-(#Radius#*Cos(7*Rad(-360)/12))-(#Radius#*Sin(7*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(7*Rad(-360)/12))-(#Radius#*Cos(7*Rad(-360)/12)))

[MeterSquare35]
Meter=string
MeterStyle=StringStyle
Text=7
TransformationMatrix=(Cos(7*Rad(-360)/12));(-Sin(7*Rad(-360)/12));(Sin(7*Rad(-360)/12));(Cos(7*Rad(-360)/12));(#Radius#-(#Radius#*Cos(7*Rad(-360)/12))-(#Radius#*Sin(7*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(7*Rad(-360)/12))-(#Radius#*Cos(7*Rad(-360)/12)))

[MeterDial_40]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(8*Rad(-360)/12));(-Sin(8*Rad(-360)/12));(Sin(8*Rad(-360)/12));(Cos(8*Rad(-360)/12));(#Radius#-(#Radius#*Cos(8*Rad(-360)/12))-(#Radius#*Sin(8*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(8*Rad(-360)/12))-(#Radius#*Cos(8*Rad(-360)/12)))

[MeterSquare40]
Meter=string
MeterStyle=StringStyle
Text=8
TransformationMatrix=(Cos(8*Rad(-360)/12));(-Sin(8*Rad(-360)/12));(Sin(8*Rad(-360)/12));(Cos(8*Rad(-360)/12));(#Radius#-(#Radius#*Cos(8*Rad(-360)/12))-(#Radius#*Sin(8*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(8*Rad(-360)/12))-(#Radius#*Cos(8*Rad(-360)/12)))

[MeterDial_45]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(9*Rad(-360)/12));(-Sin(9*Rad(-360)/12));(Sin(9*Rad(-360)/12));(Cos(9*Rad(-360)/12));(#Radius#-(#Radius#*Cos(9*Rad(-360)/12))-(#Radius#*Sin(9*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(9*Rad(-360)/12))-(#Radius#*Cos(9*Rad(-360)/12)))

[MeterSquare45]
Meter=string
MeterStyle=StringStyle
Text=9
TransformationMatrix=(Cos(9*Rad(-360)/12));(-Sin(9*Rad(-360)/12));(Sin(9*Rad(-360)/12));(Cos(9*Rad(-360)/12));(#Radius#-(#Radius#*Cos(9*Rad(-360)/12))-(#Radius#*Sin(9*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(9*Rad(-360)/12))-(#Radius#*Cos(9*Rad(-360)/12)))

[MeterDial_50]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(10*Rad(-360)/12));(-Sin(10*Rad(-360)/12));(Sin(10*Rad(-360)/12));(Cos(10*Rad(-360)/12));(#Radius#-(#Radius#*Cos(10*Rad(-360)/12))-(#Radius#*Sin(10*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(10*Rad(-360)/12))-(#Radius#*Cos(10*Rad(-360)/12)))

[MeterSquare50]
Meter=string
MeterStyle=StringStyle
Text=10
TransformationMatrix=(Cos(10*Rad(-360)/12));(-Sin(10*Rad(-360)/12));(Sin(10*Rad(-360)/12));(Cos(10*Rad(-360)/12));(#Radius#-(#Radius#*Cos(10*Rad(-360)/12))-(#Radius#*Sin(10*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(10*Rad(-360)/12))-(#Radius#*Cos(10*Rad(-360)/12)))

[MeterDial_55]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(11*Rad(-360)/12));(-Sin(11*Rad(-360)/12));(Sin(11*Rad(-360)/12));(Cos(11*Rad(-360)/12));(#Radius#-(#Radius#*Cos(11*Rad(-360)/12))-(#Radius#*Sin(11*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(11*Rad(-360)/12))-(#Radius#*Cos(11*Rad(-360)/12)))

[MeterSquare55]
Meter=string
MeterStyle=StringStyle
Text=11
TransformationMatrix=(Cos(11*Rad(-360)/12));(-Sin(11*Rad(-360)/12));(Sin(11*Rad(-360)/12));(Cos(11*Rad(-360)/12));(#Radius#-(#Radius#*Cos(11*Rad(-360)/12))-(#Radius#*Sin(11*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(11*Rad(-360)/12))-(#Radius#*Cos(11*Rad(-360)/12)))

; [MeterP]
; Meter=STRING
; X=#Radius#
; Y=#Radius#
; Padding=15,5,15,5
; FontColor=220,220,220
; FontEffectColor=0,0,0
; StringEffect=Shadow
; SolidColor=0,0,0,150
; FontSize=28
; FontFace=Segoe UI
; StringStyle=BOLD
; StringAlign=CenterCenter
; AntiAlias=1
; Text=P
; DynamicVariables=1
; LeftMouseUpAction=[!SetVariable Rotate "(1-#Rotate#)"][!UpdateMeter "MeterP"][!Redraw]
; Angle=(#Rotate#*PI/2)
; TransformationMatrix=(Cos(#Rotate#*PI/2));(-Sin(#Rotate#*PI/2));(Sin(#Rotate#*PI/2));(Cos(#Rotate#*PI/2));(#Radius#-(#Radius#*Cos(#Rotate#*PI/2))-(#Radius#*Sin(#Rotate#*PI/2)));(#Radius#+(#Radius#*Sin(#Rotate#*PI/2))-(#Radius#*Cos(#Rotate#*PI/2)))
Clock.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 3650
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Transformation matrix and circle issue

Post by Yincognito »

balala wrote: July 22nd, 2021, 9:03 amSetting the StringAlign to CenterCenter doesn't help.
I believe you're right, it's a bit of a problem to do it right for the String meter's Angle option. While in itself the matter is not at all complicated (basically it's about the fact that the center of rotation is at: left top of the meter for similarly aligned strings, at middle top for center center strings, and so on) and the translation formulas aren't complicated by themselves, there are a couple of issues:
- the rotation is performed only for the string and not for its "box", i.e. the solid color one
- the formulas slightly differ based on string alignment, padding, etc., which makes a consistent formula impossible
- the formulas will also slightly differ if you choose a different center of rotation instead of around the string's own center
- the rotation itself is not as fluid as the TM one (this might be because I didn't add some needed element in the formula though, so it's debatable)
Your sample, animated (the P letter will rotate around its center just fine, albeit with the drawbacks mentioned above):

Code: Select all

[Variables]
Radius=300
Rotate=0

[Rainmeter]
Update=25
AccurateText=1
DynamicWindowSize=1

---Measures---

[Angle]
Measure=Calc
Formula=((360+Angle+1)%360)

---Styles---

[RoundlineStyle]
RotationAngle=0
X=0
Y=0
H=(#Radius#*2.0)
W=(#Radius#*2.0)
LineLength=#Radius#
LineStart=(#Radius#*0.50)
LineWidth=(#Radius#*0.01)
StartAngle=((Rad(270)))
LineColor=afafaf
AntiAlias=1
Solid=0

[StringStyle]
X=#Radius#
Y=(#Radius#/3)
SolidColor=255,0,0,255
SolidColor2=0,255,0,255
GradientAngle=90
InlineSetting=Underline
FontFace=Courier New
FontSize=12
AntiAlias=1
StringAlign=CenterCenter

---Meters---

; [MeterBG]
; Meter=Shape
; X=(#Radius#*0.0)
; Y=(#Radius#*0.0)
; Shape=Ellipse #Radius#,#Radius#,#Radius# | Fill Color 1,6,135,255 | StrokeWidth 0
; AntiAlias=1

[MeterBG]
Meter=RoundLine
X=(#Radius#*0.0)
Y=(#Radius#*0.0)
H=(#Radius#*2.0)
W=(#Radius#*2.0)
LineLength=(#Radius#)
StartAngle=((Rad(270)))
LineColor=1,6,135,255
Solid=1
;AntiAlias=1

[MeterDial_12]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(12*Rad(-360)/12));(-Sin(12*Rad(-360)/12));(Sin(12*Rad(-360)/12));(Cos(12*Rad(-360)/12));(#Radius#-(#Radius#*Cos(12*Rad(-360)/12))-(#Radius#*Sin(12*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(12*Rad(-360)/12))-(#Radius#*Cos(12*Rad(-360)/12)))

[MeterSquare12]
Meter=string
MeterStyle=StringStyle
TransformationMatrix=(Cos(12*Rad(-360)/12));(-Sin(12*Rad(-360)/12));(Sin(12*Rad(-360)/12));(Cos(12*Rad(-360)/12));(#Radius#-(#Radius#*Cos(12*Rad(-360)/12))-(#Radius#*Sin(12*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(12*Rad(-360)/12))-(#Radius#*Cos(12*Rad(-360)/12)))
Text=12

[MeterDial_5]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(1*Rad(-360)/12));(-Sin(1*Rad(-360)/12));(Sin(1*Rad(-360)/12));(Cos(1*Rad(-360)/12));(#Radius#-(#Radius#*Cos(1*Rad(-360)/12))-(#Radius#*Sin(1*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(1*Rad(-360)/12))-(#Radius#*Cos(1*Rad(-360)/12)))

[MeterSquare5]
Meter=string
MeterStyle=StringStyle
Text=1
TransformationMatrix=(Cos(1*Rad(-360)/12));(-Sin(1*Rad(-360)/12));(Sin(1*Rad(-360)/12));(Cos(1*Rad(-360)/12));(#Radius#-(#Radius#*Cos(1*Rad(-360)/12))-(#Radius#*Sin(1*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(1*Rad(-360)/12))-(#Radius#*Cos(1*Rad(-360)/12)))

[MeterDial_10]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(2*Rad(-360)/12));(-Sin(2*Rad(-360)/12));(Sin(2*Rad(-360)/12));(Cos(2*Rad(-360)/12));(#Radius#-(#Radius#*Cos(2*Rad(-360)/12))-(#Radius#*Sin(2*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(2*Rad(-360)/12))-(#Radius#*Cos(2*Rad(-360)/12)))

[MeterSquare10]
Meter=string
MeterStyle=StringStyle
Text=2
TransformationMatrix=(Cos(2*Rad(-360)/12));(-Sin(2*Rad(-360)/12));(Sin(2*Rad(-360)/12));(Cos(2*Rad(-360)/12));(#Radius#-(#Radius#*Cos(2*Rad(-360)/12))-(#Radius#*Sin(2*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(2*Rad(-360)/12))-(#Radius#*Cos(2*Rad(-360)/12)))

[MeterDial_15]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(3*Rad(-360)/12));(-Sin(3*Rad(-360)/12));(Sin(3*Rad(-360)/12));(Cos(3*Rad(-360)/12));(#Radius#-(#Radius#*Cos(3*Rad(-360)/12))-(#Radius#*Sin(3*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(3*Rad(-360)/12))-(#Radius#*Cos(3*Rad(-360)/12)))

[MeterSquare15]
Meter=string
MeterStyle=StringStyle
Text=3
TransformationMatrix=(Cos(3*Rad(-360)/12));(-Sin(3*Rad(-360)/12));(Sin(3*Rad(-360)/12));(Cos(3*Rad(-360)/12));(#Radius#-(#Radius#*Cos(3*Rad(-360)/12))-(#Radius#*Sin(3*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(3*Rad(-360)/12))-(#Radius#*Cos(3*Rad(-360)/12)))

[MeterDial_20]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(4*Rad(-360)/12));(-Sin(4*Rad(-360)/12));(Sin(4*Rad(-360)/12));(Cos(4*Rad(-360)/12));(#Radius#-(#Radius#*Cos(4*Rad(-360)/12))-(#Radius#*Sin(4*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(4*Rad(-360)/12))-(#Radius#*Cos(4*Rad(-360)/12)))

[MeterSquare20]
Meter=string
MeterStyle=StringStyle
Text=4
TransformationMatrix=(Cos(4*Rad(-360)/12));(-Sin(4*Rad(-360)/12));(Sin(4*Rad(-360)/12));(Cos(4*Rad(-360)/12));(#Radius#-(#Radius#*Cos(4*Rad(-360)/12))-(#Radius#*Sin(4*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(4*Rad(-360)/12))-(#Radius#*Cos(4*Rad(-360)/12)))

[MeterDial_25]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(5*Rad(-360)/12));(-Sin(5*Rad(-360)/12));(Sin(5*Rad(-360)/12));(Cos(5*Rad(-360)/12));(#Radius#-(#Radius#*Cos(5*Rad(-360)/12))-(#Radius#*Sin(5*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(5*Rad(-360)/12))-(#Radius#*Cos(5*Rad(-360)/12)))

[MeterSquare25]
Meter=string
MeterStyle=StringStyle
Text=5
TransformationMatrix=(Cos(5*Rad(-360)/12));(-Sin(5*Rad(-360)/12));(Sin(5*Rad(-360)/12));(Cos(5*Rad(-360)/12));(#Radius#-(#Radius#*Cos(5*Rad(-360)/12))-(#Radius#*Sin(5*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(5*Rad(-360)/12))-(#Radius#*Cos(5*Rad(-360)/12)))

[MeterDial_30]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(6*Rad(-360)/12));(-Sin(6*Rad(-360)/12));(Sin(6*Rad(-360)/12));(Cos(6*Rad(-360)/12));(#Radius#-(#Radius#*Cos(6*Rad(-360)/12))-(#Radius#*Sin(6*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(6*Rad(-360)/12))-(#Radius#*Cos(6*Rad(-360)/12)))

[MeterSquare30]
Meter=string
MeterStyle=StringStyle
Text=6
TransformationMatrix=(Cos(6*Rad(-360)/12));(-Sin(6*Rad(-360)/12));(Sin(6*Rad(-360)/12));(Cos(6*Rad(-360)/12));(#Radius#-(#Radius#*Cos(6*Rad(-360)/12))-(#Radius#*Sin(6*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(6*Rad(-360)/12))-(#Radius#*Cos(6*Rad(-360)/12)))

[MeterDial_35]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(7*Rad(-360)/12));(-Sin(7*Rad(-360)/12));(Sin(7*Rad(-360)/12));(Cos(7*Rad(-360)/12));(#Radius#-(#Radius#*Cos(7*Rad(-360)/12))-(#Radius#*Sin(7*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(7*Rad(-360)/12))-(#Radius#*Cos(7*Rad(-360)/12)))

[MeterSquare35]
Meter=string
MeterStyle=StringStyle
Text=7
TransformationMatrix=(Cos(7*Rad(-360)/12));(-Sin(7*Rad(-360)/12));(Sin(7*Rad(-360)/12));(Cos(7*Rad(-360)/12));(#Radius#-(#Radius#*Cos(7*Rad(-360)/12))-(#Radius#*Sin(7*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(7*Rad(-360)/12))-(#Radius#*Cos(7*Rad(-360)/12)))

[MeterDial_40]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(8*Rad(-360)/12));(-Sin(8*Rad(-360)/12));(Sin(8*Rad(-360)/12));(Cos(8*Rad(-360)/12));(#Radius#-(#Radius#*Cos(8*Rad(-360)/12))-(#Radius#*Sin(8*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(8*Rad(-360)/12))-(#Radius#*Cos(8*Rad(-360)/12)))

[MeterSquare40]
Meter=string
MeterStyle=StringStyle
Text=8
TransformationMatrix=(Cos(8*Rad(-360)/12));(-Sin(8*Rad(-360)/12));(Sin(8*Rad(-360)/12));(Cos(8*Rad(-360)/12));(#Radius#-(#Radius#*Cos(8*Rad(-360)/12))-(#Radius#*Sin(8*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(8*Rad(-360)/12))-(#Radius#*Cos(8*Rad(-360)/12)))

[MeterDial_45]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(9*Rad(-360)/12));(-Sin(9*Rad(-360)/12));(Sin(9*Rad(-360)/12));(Cos(9*Rad(-360)/12));(#Radius#-(#Radius#*Cos(9*Rad(-360)/12))-(#Radius#*Sin(9*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(9*Rad(-360)/12))-(#Radius#*Cos(9*Rad(-360)/12)))

[MeterSquare45]
Meter=string
MeterStyle=StringStyle
Text=9
TransformationMatrix=(Cos(9*Rad(-360)/12));(-Sin(9*Rad(-360)/12));(Sin(9*Rad(-360)/12));(Cos(9*Rad(-360)/12));(#Radius#-(#Radius#*Cos(9*Rad(-360)/12))-(#Radius#*Sin(9*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(9*Rad(-360)/12))-(#Radius#*Cos(9*Rad(-360)/12)))

[MeterDial_50]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(10*Rad(-360)/12));(-Sin(10*Rad(-360)/12));(Sin(10*Rad(-360)/12));(Cos(10*Rad(-360)/12));(#Radius#-(#Radius#*Cos(10*Rad(-360)/12))-(#Radius#*Sin(10*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(10*Rad(-360)/12))-(#Radius#*Cos(10*Rad(-360)/12)))

[MeterSquare50]
Meter=string
MeterStyle=StringStyle
Text=10
TransformationMatrix=(Cos(10*Rad(-360)/12));(-Sin(10*Rad(-360)/12));(Sin(10*Rad(-360)/12));(Cos(10*Rad(-360)/12));(#Radius#-(#Radius#*Cos(10*Rad(-360)/12))-(#Radius#*Sin(10*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(10*Rad(-360)/12))-(#Radius#*Cos(10*Rad(-360)/12)))

[MeterDial_55]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(11*Rad(-360)/12));(-Sin(11*Rad(-360)/12));(Sin(11*Rad(-360)/12));(Cos(11*Rad(-360)/12));(#Radius#-(#Radius#*Cos(11*Rad(-360)/12))-(#Radius#*Sin(11*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(11*Rad(-360)/12))-(#Radius#*Cos(11*Rad(-360)/12)))

[MeterSquare55]
Meter=string
MeterStyle=StringStyle
Text=11
TransformationMatrix=(Cos(11*Rad(-360)/12));(-Sin(11*Rad(-360)/12));(Sin(11*Rad(-360)/12));(Cos(11*Rad(-360)/12));(#Radius#-(#Radius#*Cos(11*Rad(-360)/12))-(#Radius#*Sin(11*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(11*Rad(-360)/12))-(#Radius#*Cos(11*Rad(-360)/12)))

[MeterP]
Meter=STRING
X=(#Radius#+Sin(Rad([Angle]))*([MeterP:H]-5*2)/2)
Y=(#Radius#+([MeterP:H]-5*2)/2-Cos(Rad([Angle]))*([MeterP:H]-5*2)/2)
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=28
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=CenterCenter
AntiAlias=1
Text=P
Angle=(Rad([Angle]))
DynamicVariables=1
As you can see, for this specific case things are relatively easy in the X and Y formulas of [MeterP] (the -5*2 part is subtracting the top and bottom padding, by the way), but as I said, they will differ for various specific cases. Too bad. :confused:
User avatar
balala
Rainmeter Sage
Posts: 12972
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Transformation matrix and circle issue

Post by balala »

balala wrote: July 22nd, 2021, 11:26 am Unfortunately right now have no time to work with it, but later today I'm gonna modify the code in order to get it as desired (if in meantime someone else doesn't do it). Stay tuned...
Finally here is the promised code. Note that this time two transformation matrices are applied, the one posted into my code and the other which rotates the string with 180 degrees, but keeps it unmoved. This second transformation matrix is the following one: TransformationMatrix=(Cos(Rad(180)));(-Sin(Rad(180)));(Sin(Rad(180)));(Cos(Rad(180)));([#CURRENTSECTION#:X]-([#CURRENTSECTION#:X]*Cos(Rad(180)))-([#CURRENTSECTION#:Y]*Sin(Rad(180))));([#CURRENTSECTION#:Y]+([#CURRENTSECTION#:X]*Sin(Rad(180)))-([#CURRENTSECTION#:Y]*Cos(Rad(180)))).
Now having these two matrices, in order to get them applied both, you have to multiply them together, according to matrices multiplication rules (probably average people don't know these rules, so I multiplied them together). Here is the result:

Code: Select all

[MeterSquare30]
...
TransformationMatrix=((Cos(6*Rad(-360)/12))*(Cos(Rad(180)))-(Sin(6*Rad(-360)/12))*(Sin(Rad(180))));((-Sin(6*Rad(-360)/12))*(Cos(Rad(180)))-(Cos(6*Rad(-360)/12))*(Sin(Rad(180))));((Cos(6*Rad(-360)/12))*(Sin(Rad(180)))+(Sin(6*Rad(-360)/12))*(Cos(Rad(180))));((-Sin(6*Rad(-360)/12))*(Sin(Rad(180)))+(Cos(6*Rad(-360)/12))*(Cos(Rad(180))));((Cos(6*Rad(-360)/12))*([#CURRENTSECTION#:X]-([#CURRENTSECTION#:X]*Cos(Rad(180)))-([#CURRENTSECTION#:Y]*Sin(Rad(180))))+(Sin(6*Rad(-360)/12))*([#CURRENTSECTION#:Y]+([#CURRENTSECTION#:X]*Sin(Rad(180)))-([#CURRENTSECTION#:Y]*Cos(Rad(180))))+(#Radius#-(#Radius#*Cos(6*Rad(-360)/12))-(#Radius#*Sin(6*Rad(-360)/12))));((-Sin(6*Rad(-360)/12))*([#CURRENTSECTION#:X]-([#CURRENTSECTION#:X]*Cos(Rad(180)))-([#CURRENTSECTION#:Y]*Sin(Rad(180))))+(Cos(6*Rad(-360)/12))*([#CURRENTSECTION#:Y]+([#CURRENTSECTION#:X]*Sin(Rad(180)))-([#CURRENTSECTION#:Y]*Cos(Rad(180))))+(#Radius#+(#Radius#*Sin(6*Rad(-360)/12))-(#Radius#*Cos(6*Rad(-360)/12))))
Definitely not easy, but I assure you it does work. Try it out and let me know if it does. However note that it's a little bit weird to have all numbers rotated, except one single, which looks unrotated.