It is currently March 28th, 2024, 3:16 pm

[Feature] new function DEG

Report bugs with the Rainmeter application and suggest features.
Post Reply
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

[Feature] new function DEG

Post by ikarus1969 »

Hi!

As there is a function "RAD" which converts x degrees to radians, i kindly suggest to implement the opposite function "DEG" which would convert x radians to degrees.

thanks for consideration!

(ok, ok, i can multiply with 180 and divide the result by "PI" but why should i? ;-) )
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Feature] new function DEG

Post by Brian »

I am trying to understand why anyone would really want this.

The purpose of the RAD function is to make it easier to convert degrees to radians. It's easier for most people to think in terms of degrees than it is in terms of radians. 15 degrees is easier than π / 12 or 0.261799. No one is going use something like DEG(PI/12) or DEG(0.261799) over 15.

I guess it might be useful if parsing a radian value from a website, but that is about it. I really don't think there are enough people out there that work in radians to justify this.

[Serious questions]
Does anyone really work with radians?
Does anyone think this might be useful beyond 'calculator' skins?
Are there any examples out there where this makes sense?
[/Serious questions]

-Brian

PS - I realize it's confusing that some of our options require radians, and some require degrees. This is mostly due to some built-in Windows API functions that require radians over degrees. We should have used degrees from the start and then internally converted to radians, but that ship has sailed.
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: [Feature] new function DEG

Post by ikarus1969 »

SIN / ASIN, COS / ACOS, TAN / ATAN, .. gives a value in radians.

I am calculating the angle of a gradient for a rectangle (stroke of a shape) to simulate light from upper-left corner to the lower-right corner.
Because i have several rectangles with different widths an heights, each angle is different depending, well, on the width and height.

I am using the law of sines / wikipedia formula to calculate the angle i need, and i need to convert the radians i get from ASIN to get degrees.

edit: added a picture:
Screenshot Rainmeter - part of a clock.jpg
Shapes with stroke LinearGradient for simulating light from upper-left to lower-right corner
The angle of the box with the time is about 73 degrees, the angle of the box on the right is about 43 degrees (dependig on with / height as i have said)

Brian, please forgive me, i know that jsmorley and you are currently the only ones (beside theazack) coding for rainmeter, and time is precious.
DEG would be just the opposite for RAD like with MIN / MAX or FLOOR / CEIL. I wonder if implementing one of those functions was based on if it makes sense or is useful to have them
Last edited by ikarus1969 on May 5th, 2017, 8:42 am, edited 1 time in total.
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: [Feature] new function DEG

Post by ikarus1969 »

another thing that comes to my mind:
Brian wrote:I really don't think there are enough people out there that work in radians to justify this.
just a question: you do think that bitwise operators are used by "enough" people?
How much people are "enough" for a "DEG" function? :confused:
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Feature] new function DEG

Post by Brian »

ikarus1969 wrote:SIN / ASIN, COS / ACOS, TAN / ATAN, .. gives a value in radians.

I am calculating the angle of a gradient for a rectangle (stroke of a shape) to simulate light from upper-left corner to the lower-right corner.
Because i have several rectangles with different widths an heights, each angle is different depending, well, on the width and height.

I am using the law of sines / wikipedia formula to calculate the angle i need, and i need to convert the radians i get from ASIN to get degrees.
Great point. I wasn't thinking about the other functions that return a value in radians or 'stacking' any functions for that matter. DEG(SIN(X)) for use in the Shape meter makes perfect sense!

ikarus1969 wrote:just a question: you do think that bitwise operators are used by "enough" people?
How much people are "enough" for a "DEG" function?
I highly doubt anyone has used the bitwise operators (maybe a calculator skin uses them) - however, these functions were built-in to our math library, so it's not a matter of 'we thought it would be good to have', more of a 'hey, these math functions are available' type of thing. The original math library we use did not have a RAD or DEG function. Now that we have some options that natively use degrees, and given that some of our functions return radians (as you have shown above), I think moving forward with this probably makes a lot more sense.

-Brian
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Feature] new function DEG

Post by balala »

Brian wrote:Great point. I wasn't thinking about the other functions that return a value in radians or 'stacking' any functions for that matter. DEG(SIN(X)) for use in the Shape meter makes perfect sense!
Brian, please be careful, because the DEG(SIN(X)) expression has no sense at all. SIN(X) returns not an angle, but the sinus of an angle, which is a number between -1 and 1. It has nothing to do with a DEG(X) function, which would convert to degrees a value of an angle, expressed into radians. But eg DEG(ASIN(X)), would be a perfect example, because the result of ASIN(x) is an angle and the Deg function could work with it.
Furtherly, just mention, that, if I'm not wrong only two options use the angles expressed into degrees (or maybe I forgot any other?): the ImageRotate and the GradientAngle. I don't say a Deg function wouldn't have any practical purposes, it definitely would have, but definitely wouldn't be very much used.
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Feature] new function DEG

Post by Brian »

balala wrote:Brian, please be careful, because the DEG(SIN(X)) expression has no sense at all. SIN(X) returns not an angle, but the sinus of an angle, which is a number between -1 and 1. It has nothing to do with a DEG(X) function, which would convert to degrees a value of an angle, expressed into radians. But eg DEG(ASIN(X)), would be a perfect example, because the result of ASIN(x) is an angle and the Deg function could work with it.
Thanks for this. It wasn't meant as a literal example, but more of a example to show that other functions return a value expressed in radians, and some of our options are expressed in degrees.

balala wrote:Furtherly, just mention, that, if I'm not wrong only two options use the angles expressed into degrees (or maybe I forgot any other?): the ImageRotate and the GradientAngle. I don't say a Deg function wouldn't have any practical purposes, it definitely would have, but definitely wouldn't be very much used.
Some of the newer Shape options accept degrees as well. Fill and Stroke gradients and the Rotate modifier come to mind.

-Brian
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Feature] new function DEG

Post by balala »

Brian wrote:Some of the newer Shape options accept degrees as well. Fill and Stroke gradients and the Rotate modifier come to mind.
You're right, I completely forgot those new options, but they indeed are.
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Feature] new function DEG

Post by Brian »

This has been added for the next beta.

-Brian
Post Reply