# 3D scaling using sine based on time

This topic is 2384 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
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).

##### Share on other sites
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

##### Share on other sites
Awesome it works and scales properly! Thanks a ton!

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633702
• Total Posts
3013448
×