|
ha! Yeah, I'm kind of going into high school next year so...
-----
*** Never give me an answer having anything to do with Visual Studio. I don't have this because I have two computers, one being my dad's mac, which is connected to the internet, the other being my pc, which is, sadly, not connected to the internet. The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program. THEREFORE I cannot install this program onto my pc.***
|
|
|
|
|
max29297 wrote: I'm kind of going into high school next year so...
Good luck to you, and any questions about your maths studies are welcome here.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Thanks!
-----
*** Never give me an answer having anything to do with Visual Studio. I don't have this because I have two computers, one being my dad's mac, which is connected to the internet, the other being my pc, which is, sadly, not connected to the internet. The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program. THEREFORE I cannot install this program onto my pc.***
|
|
|
|
|
No problem. I'd look at the Douglas Downing book that I posted about earlier. He has an Algebra one, and Calculus one which is really good.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
How do you "kind of" go into high school?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi
I am monitoring CPU performance and disaplying it in a colour ('cos we don't care about the poor sighted where I work!).
0% = Green.
100% = Red.
and anywhere in between should be a mixed shade of these two. I tried setting the mid point as yellow, so:-
RGB
0% 00,255,00
50% 255,255,00
100% 255,00,00
formula for this was
n < 50 : r = n * 5, g = 255 , b = 0;
n >=50 : r = 255 , g = (255-((n-50) * 5)) , b = 0;
near enough, and I could handle the maths, but the results looked ****. The green was going lighter as it headed towards yellow, not darker (redder?). The type of affect i am after is best shown in Microsoft Word, Gradient fill, where you select two colours, the first green, the second red.
(Now if Luc answers this, he might as well have written the whole class for me!!)
Cheers
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
You rang for me, my lord ?
What you want is a gradient in HSB space; take S=100% B=100% and let hue vary from
yourGreen.Hue (probably 33%) to yourRed.Hue (probably 0)
I leave the coding to you tho.
|
|
|
|
|
HSB space is all new to me - I sense another nights googling and reading ahead.
Cheers Luc
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Malcolm,
Would this article help? Colorspace[^], it's right here on CP...
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
It certainly would. I've read it before, some time ago, and as usual, didn't bookmark as I didn't need it at the time. Amazing how a little request from the boss about cpu monitoring has turned into learning about color manipulation.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Malcolm Smart wrote: didn't bookmark
I bookmark alot of articles around here. Nice to bookmark but out of fear of losing the bookmarks, I added an entry into my CP blog on my profile page to act as a bookmark to an extent.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
|
I think (on empirical grounds) that you can try to use the following formula:
g(n)= (int) ( 255 * cos( n * pi / 200) + .5)
r(n)= (int) ( 255 * sin( n * pi / 200) + .5)
where:
double pi = 3.14159..........
0 <= n <= 100
The starting point for the above formulas was the fact that at the middle point of the Microsoft Word's gradiend there is no pure yellow, but a darker one.
So I made the following hypothesis (maybe are wrong, maybe that are, neverthless, useful):
(1) You have to pass from Red to Green keeping constant intensity.
(2) Intensity is proportional to the square root of the summed up squares of the rgb components, namely:
i(r,g,b) = sqrt( r*r + g*g + b*b)
I don't know if the above formulas give a good gradient approximation, I have not yet made a test...
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi CPallini,
There is lots of discussion about brightness, luminance, intensity, etc,
most often the formulas used are linear ones, or they rely on MAX(r,g,b) and/or MIN(r,g,b).
Your sqrt is an interesting twist.
Here are five samples of your formulas
n = 0% 25% 50% 75% 100%
g(n) 100% 92% 70% 38% 0%
r(n) 0% 38% 70% 92% 100%
and they match very closely with what MS Word is offering with their "Fill Gradient between
Two Colors".
Well done !
BTW: curious how you would solve it if you are not as lucky as to find one of (r,g,b)
at a constant value tho.
|
|
|
|
|
Thanks all - I can feel my first CP article coming on now. Not specifically to do with this control, but the whole concept of doing something, hitting problems, the investigation, the questions asked, teh answers, the application of the answers to the problem etc.
Thanks again.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
You're welcome.
Looking forward to your article; please make sure it ends on "12".
|
|
|
|
|
Luc Pattyn wrote: and they match very closely with what MS Word is offering with their "Fill Gradient between
Two Colors".
I know, I made a little test after posting my answer (I was a bit confident...).
Luc Pattyn wrote: Well done !
Thank you very much.
Luc Pattyn wrote: BTW: curious how you would solve it if you are not as lucky as to find one of (r,g,b)
at a constant value tho.
Well, maybe with a little help of my friend sphere ...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Just plugged the formula in and it worked a treat, just had to use 100-n instead of n to reverse the gradient.
Thanks again.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Malcolm Smart wrote: Just plugged the formula in and it worked a treat, just had to use 100-n instead of n to reverse the gradient.
Sure? You asked for:
0% = Green.
100% = Red.
My formula was:
g(n)= (int) ( 255 * cos( n * pi / 200) + .5)
r(n)= (int) ( 255 * sin( n * pi / 200) + .5)
i.e. full green when n==0.
Anyway, of course, use whatever you find to fit better you needs!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
That's because you wrongly assumed I have the ability to copy your formula correctly.
If I had, then I wouldn't have needed the 100-n change. I somehow managed to switch the Cos and Sin between the Red and the Green, in which case, I needed the 100-n .
Switched them back, removed the 100-n , and as you said it would, so long ago, it worked.
Thanks for the help....again.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Malcolm Smart wrote: That's because you wrongly assumed I have the ability to copy your formula correctly.
Well, I correctly assumed that you have such ability (after all you're Malcom Smart...) since eventually you did.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hello
Can any one plz give me an algorithm to find all the elements in an array that are repeated atleast once?
Thanks in advance
Rocky
|
|
|
|
|
Rocky71 wrote: Can any one plz give me an algorithm to find all the elements in an array that are repeated atleast once?
brute force: read all, check for match on all.
Now if you want minimal search, now you are talking fun....
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Just add a sort pass. With potential duplicates adjacent to each other an O(n) detection routine is trivial.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
dan neely wrote: Just add a sort pass.
true, it said nothing about order.
There you go, two algorithms, issue solved.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|