3D scaling using sine based on time

Started by
2 comments, last by kbenderoth89 11 years, 11 months ago
So I'm trying to make my teapot scale properly when testing my HLSL shader effect.

currently I have this:


float4x4 scale = {(sin(gTime)*sin(gTime)),0,0,0,
0,sin(gTime)*sin(gTime),0,0,
0,0,sin(gTime)*sin(gTime),0,
0,0,0,1};
where gTime is the time elapsed since the program started.
Basically what I want it to do is scale from about 0.5 of its original state to 1.0 (the original size) constantly.
you could probably guess that what I currently have scales it from 1.0 to 0.0
is also tried using the absolute value and, well, it partially works, only the full scaling takes about 4 seconds and it takes 3 seconds before it moves
can anyone help me scale it smoothly from half its size to its full size using sin, cos, or tan?
Advertisement
sin^2(t) varies from 0 to 1, so to get a scaling factor that varies between 0.5 and 1 you need to have the scaling factor equal to 0.5+0.5*sin^2(t).
Keep in mind that squaring the sine function also doubles its frequency, and there is no need to actually square the sine because you can rescale and shift the unmodified sine function using (3 + sin(t)) / 4 to get a range of values between 0.5 and 1.0.

-Josh

--www.physicaluncertainty.com
--linkedin
--irc.freenode.net#gdnet

Awesome it works and scales properly! Thanks a ton!

This topic is closed to new replies.

Advertisement