|
Hi all,
Upon the start of my windows application I would like the splash screen window to move along the path of a cosine curve.
More precisely I would like it to work like this:
My splash window is positioned at the lower right corner of the screen. Now image a cosine graph under the interval of 0 <= degrees <= 180. I want the upper left corner of the splash screen to initially correspond to the coordinate of [180, cosine(180)]. Then, at some intervals I want the window to move to the "left" along the cosine curve all the way up to the top left corner of the screen, making a horizontally flipped S-shaped path (almost a flash-logo-like path).
Since screens vary in sizes I need to know how to transpose a cosine curve to "fit" all screens.
Any help would be greatly appreciated!!!!!
/Tommy
|
|
|
|
|
I don't know what language you're using, but I've always used ::GetSystemMetrics(SM_CXSCREEN) to get the screen width and similar calls to get other screen dimensions. For your problem, since cos(180)=-1 and cos(0)=1, you will want to find the center of the screen to pivot from, but to do this you will need to subtract off the height of the splash screen and any borders. The following worked in a dialog based app:
void CTestSplashDlg::SetPosition(double dDegrees)<br />
{<br />
const double pi = 3.1415926535;<br />
double dRadians = (2 * dDegrees * pi)/360;<br />
double dCos = cos(dRadians);<br />
<br />
CRect rect;<br />
GetClientRect(&rect);<br />
<br />
long nNewWidth = (long)(::GetSystemMetrics(SM_CXSCREEN) - rect.Width() - ::GetSystemMetrics(SM_CXDLGFRAME)) * (dDegrees/180);<br />
<br />
long nHeightCenter = (long)(::GetSystemMetrics(SM_CYSCREEN) - rect.Height() - ::GetSystemMetrics(SM_CYDLGFRAME) - ::GetSystemMetrics(SM_CYCAPTION))/2;<br />
long nNewHeight = (long)(nHeightCenter - (dCos * (nHeightCenter)));<br />
<br />
SetWindowPos(NULL, nNewWidth, nNewHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);<br />
}
when called with:
for (double i = 180; i >= 0; i--)<br />
{<br />
SetPosition(i);<br />
Sleep(10);<br />
}
Note that you would probably call this from a timer instead of a for loop and the starting position does not take into account the taskbar that may be at the bottom of the screen.
|
|
|
|
|
hi this is my first post here
i want to change the frequency of part of a wave file
as you know we can change the Header of wave file and change the frequency of file totally and also it's possible by directsound palyback option
(buffer.setfrequency) but i want to do it dirctly in sample waves i mean i need some algorithm to change the frequency of given samples
any idea or algorithm?
(sorry for my bad english)
|
|
|
|
|
Hi,
You ask a very general question, so, to limit the possibilities, you must define more precisely your objective and any limitations:
1) Is your signal comfortably sampled, or is it on the limits? For example, a 44.1 KHz sampling rate has a signal limit of about 21 Khz or so, so these signals do not "fit inside" the sampling rate comfortably. If, on the other hand, you sampled a 10 KHz sound (voice) with a 44.1 KHz then it fits comfortably.
2) Is the new frequency always a multiple/submultiple of the original? Or is it arbitrarily diferent? If arbitrarily diferent then is it static or variable? For example, starting at 2:1 ratio and ending at 3:1 ratio?
3) Is the resulting quality very important? Or is it mathematical accuracy more important? Better accuracy implies better quality of course, but if you just want your resulting file to sound good then you may allow lower accuracy to simplify the algorithm.
4) Will you be able to use floating point? Or are you constrainded to using integers? Is performance important? If so, how many samples do you want to process per second? Or what is the real-time factor? If performance is very important then MMX/SSE may be necessary, that is why I ask.
5) Do you want to keep the same precision or can you use more precision in the result? For example, your source samples may be 16-bit and you may want the result in 32-bit floating point. If you want the sound to simply sound ok then I sugest you keep the original precision. If you want true mathematical accuracy then, in general, you should use higher precision than the original.
A lot more question could be asked before determining exactly what you want. Anyway, let me point out the most relevant aspects of the algorithm you need:
a) If the frequency is to be raised then the signal must be filtered to remove the frequencies that, after the frequency change, exceed half of the sampling rate. Variable filters (or parametric filters) may have a lowered performance and may be more complex to design.
b) After filtering the signal you generaly need to expand it into a new buffer (if the frequency is lowered), or, if the frequency is raised then you may do it in place. The most general form is to simply allocate a new buffer for both cases of lowering and raising the frequency.
c) Now that you have a destination buffer you must compute the new sample values. There are many ways to acomplish this, but maybe 2 can be considered interesting: linear interpolation and "real" interpolation. The first is simple but not very accurate, the second is complex but very accurate.
If you need more help on any of the questions (1->5) or steps (a->c) above then don't hesitate to ask. I kept the answer general while I don't know exactly what you want, but when you tell me what you want then I can give you a detailed algorithm.
I hope this helps,
Rilhas
|
|
|
|
|
Problem in question:
You may solve this problem with or without programming, but it has been optimised for solution with a programming method.
The Fibonacci sequence of numbers is defined as:
F[0]=0<br />
F[1]=1<br />
and for all x>1,<br />
F[x]=F[x-1]+F[x-2]
PLEASE do not post the answer.
What is the smallest value of x>0 such that F[x]=0 mod 2^32
PLEASE do not post the answer.
I never thought I'd revert to posting here to get help with this question from a Puzzel Challange Site[^]. The history behind it, I've been stuck on this for a year. Not a solid year but off and on. I've written a LongMath Class[^] to help me solve it but I still haven't found the the answer. I've read through the posts on the challange site and they're talk'n about, "If you understand the Fibonacci sequence you won't need a program to figure it out.
I'm looking for help in solving the problem on my own. The site is older and not alot of visitors to the forums. I've applied my LonMath Class to a sandbox app to help solve it but I'm not sure if I'm performing F[x]=0 mod 2^32 correctly. Fibonacci Pilot[^]
I'm listening but I only speak GEEK.
|
|
|
|
|
I'm intrigued, but I'm not about to log on to that site, is that the full text of the puzzle?
I ask because it seems to me that 0 mod 2^32 equals 0; so, as stated, the puzzle has no solution.
|
|
|
|
|
Nono, in real life as well as in maths, numbers have no upper bound and no limit as
to the number of bits; so there might well be non-zero Fibonnacci numbers
that take a divisor of 2^32. In fact, I can assure you there are infinitely many
solutions to this one, and the smallest of them can be calculated with a simple calculator !
The puzzle site is very challenging, and yes, most often the problem descriptions are
short, and sometimes very ... puzzling.
Luc Pattyn
|
|
|
|
|
Yes, but as stated, we're not dividing (or MODing) the xth Fibonnacci number by 2^32, but comparing it with 0 mod 2^32 which ought to be 0; isn't 0 mod anything (except 0) always 0? So the mod 2^32 is unnecessary.
That simplifies the puzzle to F[x]=0 , but that's only true when x=0, and the puzzle is to find a solution where x>0 , that's why I see no solution.
Certainly, if the puzzle stated F[x] mod 2^32 = 0 , then I would understand it.
|
|
|
|
|
mathematician use a lot of different notations for modulo arithmetic.
All of the following are equivalent:
a ≡ b (mod M)
a = b (mod M)
a ≡ b mod M
a = b mod M
and they all actually mean:
a % M = b % M
so the modulo operator is often mentioned only once,
and sometimes not at all (but just implied by text or context)
Therefore the problem at hand is really asking for the first Fibonacci number
that is a multiple of 2^32.
Of course, a more programmer-friendly notation would have been:
find x such that F(x) mod 2^32 = 0
instead of: F(x) = 0 mod 2^32
Luc Pattyn
|
|
|
|
|
Aside:
Well, if a = b mod M means a % M = b % M how would I express a = b % M ?
|
|
|
|
|
Program statements must be accurate and unambiguous; thats what compilers need,
and programmers must provide.
Mathematical equations must also be accurate and unambiguous. However math publications
try to come up with the clearest and/or shortest notation, often at the expence of
some ambiguity (which then should be resolved by adding a textual description of the
local conventions, if necessary).
It is important to recognize which is which. On most of the CP message boards, there
is no doubt, it is code in one of the many standard programming languages.
On the Maths and Algos board, some of it is math equations, and must be treated as such.
Luc Pattyn
|
|
|
|
|
Luc Pattyn wrote: find x such that F(x) mod 2^32 = 0
Your correct that the author mentions that the above equation is another way to look at it. Thank you for the help in this puzzle. I've been reviewing the series for a pattern of numbers that follow a power of 2, but I'm not much of a mathematician.
I'm listening but I only speak GEEK.
|
|
|
|
|
That would be why I asked if you could post the full actual text of the puzzle.
|
|
|
|
|
Hi,
there are several bulletin boards on the caesum site, there is one per level,
and one per problem (only accessible once you solved it!).
The fibber problem can be cracked easily by programming; there are tsraightforward
ways, and even better ones.
It can also be solved by hand using a simple calculator (hint: scan the Fibonacci
sequence looking for a pattern in the powers of 2).
Luc Pattyn
|
|
|
|
|
I've been running the squence and squaring each number looking for an noticable pattern but I'm not seeing anything. Most of the puzzles I've run into have an underlying reson for the puzzle. Would you know where else this information would be used? Why would I be looking at a pattern of squared numbers?
I'm listening but I only speak GEEK.
|
|
|
|
|
Squaring ??
Just look at the Fib numbers in binary...
Luc Pattyn
|
|
|
|
|
sorry just miss typed, was meaning, (power of 2) not squared.
I'm listening but I only speak GEEK.
|
|
|
|
|
|
will you help me about 3d modelling application devlopment,i have requirment to devlop 3d modelling applicationj just like any presentation software.
Hi manish Here.
|
|
|
|
|
You can have look at openGL section on this site.
|
|
|
|
|
Well, i know it's not a part of this site and i don't want to advertise (i really don't have to gain anything) but i'm using TrueVision3D, a DX wrapper (free for demo, 160$ for a single license, no royalties). It's quite fast and extremelly easy to use in vb6, c++, c# and .NET. It's current version is 6.2 but with a license you can get the beta 6.5 which is amazing. Anyway, it has all you'll ever need for creating a 3D modelling software.
PS: To avoid sounding biased, there are also many other engines out there like Torque, Ogre, .. etc but as far as i know they're oriented towards C++. Don't know for sure though. Also you could go for OGL or DX if you can spare the time learning.
|
|
|
|
|
I think Torque can now release code that runs on the XBox 360. That's pretty cool.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
ms raj wrote: will you help me about 3d modelling application devlopment,
a bit late to reply, but you can always try: http://www.openscenegraph.org/[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Click here.[^]
"Marge, don't discourage the boy! Weasling out of things is important to learn. It's what separates us from the animals! Except the weasel." - Homer Simpson
Web - Blog - RSS - Math - LinkedIn - BM
|
|
|
|
|
amount is too small
Luc Pattyn
|
|
|
|